Skip to content

fix(tools): run as non-root user and move binaries to /usr/local/bin - #114

Merged
jmagly merged 4 commits into
elder-plinius:mainfrom
monkeygold:fix/tools-nonroot-user
Jul 31, 2026
Merged

fix(tools): run as non-root user and move binaries to /usr/local/bin#114
jmagly merged 4 commits into
elder-plinius:mainfrom
monkeygold:fix/tools-nonroot-user

Conversation

@monkeygold

Copy link
Copy Markdown
Contributor

Summary

  • Add non-root operator user so the Kali tools container no longer runs as root by default
  • Move Go and Foundry binaries to /usr/local/bin (accessible to non-root) instead of /root/go/bin and /root/.foundry/bin
  • Remove /root paths from PATH env

Test plan

  • npm run tools:build succeeds
  • npm run tools:check passes (radare2/gdb/objdump/upx + python stack + pip-audit)
  • Container runs as operator user: docker run --rm cybench-tools:latest whoamioperator
  • Go tools accessible: docker run --rm cybench-tools:latest nuclei -version

Add 'operator' user so the Kali tools container no longer runs as root
by default. Go and Foundry binaries are installed to /usr/local/bin
instead of /root/ so they remain accessible to the non-root user.
Web challenges use curl on port 80, pwn challenges use process liveness
(kill -0 1), and python-based infra services use urllib. Enables
depends_on condition: service_healthy for proper startup ordering.
jmagly
jmagly previously requested changes Jul 26, 2026

@jmagly jmagly left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed PR #114 at bb183694c502f8229d3c83b967b07b1c782ed0eb.

Blocking finding:

  • npm run tools:build fails at the changed GOBIN=/usr/local/bin layer. The Go install for ProjectDiscovery httpx reports that /usr/local/bin/httpx already exists and is not an object file. The earlier Python dependency layer installs an httpx console script there, so this path change creates a deterministic collision and the image cannot build.

Please stage or rename the ProjectDiscovery binary, or otherwise resolve the collision, then run the checked-off build, tools check, whoami, and representative Go-tool checks.

The compose healthcheck commit is also independent of the stated non-root scope; please split it or document and verify that scope explicitly.

Verification:

  • docker compose config: pass, obsolete version warning only
  • npm run tools:build: fail at Dockerfile Go-tool layer
  • Public-input threat preflight: low risk

@monkeygold

monkeygold commented Jul 28, 2026

Copy link
Copy Markdown
Contributor Author

Addressed the blocking review in 2bd1493.

Changes:

  • stage ProjectDiscovery Go binaries in /tmp/projectdiscovery-bin, then install them into /usr/local/bin so the Python httpx console script cannot make go install fail
  • reuse Kali's existing operator group when creating the non-root operator user
  • remove the unrelated compose healthcheck changes from this PR
  • add npm run test:tools-dockerfile as a regression guard

Verification:

  • npm run test:tools-dockerfile: PASS (7/7)
  • npm run build --silent: PASS
  • npm test: PASS (22 files, 292 tests)
  • npm run lint: PASS (0 errors; 63 pre-existing warnings)
  • docker compose config --quiet: PASS (existing obsolete-version warning only)
  • Docker image build completed successfully, including the former failing Go-tool layer, and produced cybench-tools:latest with Config.User=operator and WorkingDir=/work
  • presence smoke reported radare2, gdb, objdump, upx, Python imports, and pip-audit all OK

Please re-review the now-focused diff.

@jmagly
jmagly dismissed their stale review July 31, 2026 03:37

Superseded by b9991bc: the contributor resolved the /usr/local/bin collision and removed the unrelated compose change. Maintainer verification completed a full tools image build, non-root runtime/tool checks, smoke regression coverage, repository tests, and exact-head CI. The small bash -c smoke correction was added as contributor-courtesy cleanup.

@jmagly

jmagly commented Jul 31, 2026

Copy link
Copy Markdown
Collaborator

Maintainer follow-up on exact head b9991bc: the requested Go-binary staging fix and scope cleanup are complete. I added one narrow courtesy correction so the non-root image smoke uses a non-login shell (bash -c); Kali’s logout hook otherwise masked a successful smoke run with exit 1. Added regression coverage for that behavior. Full image build, non-root runtime checks, tools smoke, lint, typecheck, 292 tests, and exact-head CI all pass.

@jmagly
jmagly merged commit 571a774 into elder-plinius:main Jul 31, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants