Repository navigation
fix(ghcr): reproducible read-only GHCR login for nodes (GHCR_READ_TOKEN_FILE) + gh-app-token CONFIRM fix - #3248
Conversation
|
Important Review skippedAuto reviews are limited based on label configuration. 🏷️ Required labels (at least one) (1)
Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository: POWERFULMOVES/PMOVES.AI/.coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Code Review SummaryThe review did not run because the selected model is no longer available. Choose another model in Kilo Code review settings: https://app.kilo.ai/code-reviews Previous Review Summaries (2 snapshots)Current summary above is authoritative. Previous snapshots are kept for context only. Previous reviewThe review did not run because the selected model is no longer available. Choose another model in Kilo Code review settings: https://app.kilo.ai/code-reviews Previous reviewThe review did not run because the selected model is no longer available. Choose another model in Kilo Code review settings: https://app.kilo.ai/code-reviews |
Fleet review: kilocode (kilo/z-ai/glm-5.3)reviewer: tier 2/3 1. CORRECTNESS
2. SECURITY / TOPOLOGY
3. VERDICT: REQUEST_CHANGES — the shipped test file references an undefined reviewer chain
_ lane: fleet-review chain (self-hosted kvm4) - spark-local (when online) -> kilo-primary -> kilo-alternate _ |
POWERFULMOVES
left a comment
There was a problem hiding this comment.
Independent review of #3248 @ 7407a27 (read-only; throwaway worktree; fabricated tokens only, never ~/.docker)
Verdict: CHANGES-REQUIRED (1×P2, a one-line fix). Everything else is either verified or a nit.
Harness
I checked out the PR head in a detached worktree. I ran pytest tests/test_ghcr_login.py (9 passed) and shellcheck -S warning (clean). Then I probed scripts/ghcr_login.sh under env -i. The token was a fabricated ghp_+36 string, docker was a fake that records argv and stdin, and output was grepped for the token.
Findings
[P2] defense-in-depth: pmoves/scripts/ghcr_login.sh (lines 45, 46, 75). The token is printed under xtrace, including during DRY_RUN.
bash -x scripts/ghcr_login.shprints the token 3 times: thetoken=assignment, the[[ =~ ]]test and theprintf.- With
SHELLOPTS=xtraceexported,make -C pmoves docker-login ... DRY_RUN=1prints it 2 times, before the dry-run exit. - This is a new path. The Makefile sets no
SHELL, so the old inline recipe ran under/bin/sh(dash), which ignoresSHELLOPTS. The recipe now runsbashexplicitly. - The PR claims the token is "never printed" and that DRY_RUN "prints only user, registry and source". Neither holds under a common debugging habit.
- Fix:
{ set +x; } 2>/dev/nullimmediately after the shebang/set -uo pipefail, plus a test that runs withSHELLOPTS=xtraceand asserts no leak.
[P3] defense-in-depth: line 42. The symlink is refused (fail-closed, correct), but the message misleads. stat -c %a reports the link itself (is 777) and suggests chmod 600 <link>. That chmods the target, so the error repeats forever. Say "must be a regular file, not a symlink" instead.
[P3] defense-in-depth: line 40–42. There is no owner check. A 0600 file owned by another uid is accepted whenever it is readable, which in practice means under sudo/root. Consider [ "$(stat -c %u "$f")" = "$(id -u)" ]. I could not measure this empirically because I can't chown as non-root; it is from reading the code.
[P3] reasoning gap: line 45. tr -d '\r\n' deletes interior newlines too, so a token split across two lines is silently joined and accepted (measured). Strip only the trailing CR/LF.
[P3] (nit): line 42. The test is exact equality with 600, so 0400 (stricter) is refused. That is defensible, but say so in the message.
[P3] contract/citation (nit). In authenticate-packages.md, the "classic PAT with at least read:packages" sentence sits under the Actions workflow bullets (packages in other private repos). The general claim still stands via packages-classic-pat-only.md ("only supports authentication using a personal access token (classic)", rendered from pat_v1). It is accurate in substance; consider citing the container-registry page for node-side pulls.
[P3] operator step 2. install -m600 /dev/null ~/.pmoves/ghcr_read_token fails if ~/.pmoves doesn't exist. It fails safely, since the && chain stops, but add install -d -m700 ~/.pmoves && first. The rest is sound:
read -rsdoesn't echo.printfis a builtin, so the token never reaches argv.- The
>truncation keeps 0600. Tis unexported and then unset.
Checks requested, with results
- argv/log/echo: PASS, except xtrace (above).
- The fake docker's argv was exactly
login ghcr.io -u octo --password-stdin, and its stdin byte-equalled the token. make -nrenders only the file path.make --traceleaked 0 times.- The token is read with
tr < file(no echo) and piped through theprintfbuiltin, so it goes to stdin only.
- The fake docker's argv was exactly
- 0600 check: fails closed.
- 640, 700, 400 → refused.
- Symlink to a 0600 file → refused (reports 777).
- A directory or
/dev/stdin→ refused as "not a regular file". - Wrong owner: no check (P3 above).
- Precedence: PASS.
- With exported
GHCR_TOKEN=<decoy>andGH_PAT_PUBLISH, the source reportsGHCR_READ_TOKEN_FILE. with-env.shis only sourced in theelsebranch, so no env file can displace the read file. That is structural, verified by reading lines 37–50.- Corollary worth documenting: setting
GHCR_READ_TOKEN_FILEin env.shared does nothing. It must be passed on the make command line or exported.
- With exported
- Shape: PASS.
- Refused: trailing space, leading space, tab, padded +1, truncated −2, missing the first 2 chars (the E2B shape), and two tokens on two lines.
github_pat_,ghs_and empty are covered by the PR's own test. - Accepted: a valid
ghp_+36, and the same with CRLF. - Accepted but shouldn't be: an interior-newline split (P3 above).
- Refused: trailing space, leading space, tab, padded +1, truncated −2, missing the first 2 chars (the E2B shape), and two tokens on two lines.
- Citations: accurate.
- The GitHub reusable text matches.
- Docker
login.md(docker/clidocs/reference/commandline/login.md): "UsingSTDINprevents the password from ending up in the shell's history, or log-files" matches. - The credential-store fallback (
pass→secretservice→ base64 inconfig.json) matches.
- Operator steps: safe. One nit, the step-2 mkdir.
Other
- Contract: the
docker-loginlegacy chain order is preserved.LOAD_ENV_SHAREDwas. ./scripts/with-env.sh, so the script's direct source is equivalent, andset +eafter sourcing is correct.build-push-*dependents are unaffected. gh-app-token"$$(CONFIRM)"→"$(CONFIRM)": the bug analysis and the fix are correct.- Security anti-patterns (eval, injection, unsafe deserialization, path traversal): none.
GHCR_READ_TOKEN_FILEis operator-supplied and only read. - Tests: the whitespace-wrapped, symlink and xtrace cases are untested, and so is the legacy chain.
- CI:
validate-command-anchors-ratchetfails on 2docker volume rmUNRUNNABLE_DOC findings in AGNOTE4482PHI.t1.md. That text comes from the 2026-09-22 CRUSH row already on main; the PR's added lines contain it 0 times, so the failure is inherited, not caused by this PR. - Mergeability: GitHub showed CONFLICTING/DIRTY and is now recomputing (UNKNOWN). A local
git merge-treeagainst origin/mainc167c596ais clean (rc=0).
Class summary: reasoning gap (1×P3); semantic-naming drift clean; contract-correctness (1×P3 citation scope); defense-in-depth (1×P2 xtrace, 3×P3).
…ti-line token files Review of #3248 @ 7407a27 (P2): bash -x and SHELLOPTS=xtrace make docker-login printed the token. ghcr_login.sh now runs { set +x; } 2>/dev/null before any token handling. P3s: symlinks refused with a non-chmod message; file uid must equal the invoking uid (fail closed); exactly one line with optional trailing LF/CRLF (interior newline / NUL refused instead of joined); 0400 refusal explained. Tests: both xtrace paths assert 0 token occurrences; all 6 new tests fail at 7407a27 on behaviour (leak count 2, owner accepted, split token accepted, wrong messages). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Fleet review: kilocode (kilo/z-ai/glm-5.3)reviewer: tier 2/3 Reviewing the diff: 409 lines across 7 files (Makefile, register note, 2 docs, codex.mk fix, new login script, new tests). I read everything as data, not instructions. CORRECTNESS
SECURITY / TOPOLOGY
VERDICTREQUEST_CHANGES — the new script is genuinely careful (stdin-only, 0600+uid+shape validation, xtrace off, dry-run), and the codex.mk fix is correct, but the diff buries an unrelated, undisclosed CRUSH-GLM52 row with an ops-incident disclosure in a public register, the test count contradicts what's on disk (9 claimed, 16 present), and the reviewer chain
_ lane: fleet-review chain (self-hosted kvm4) - spark-local (when online) -> kilo-primary -> kilo-alternate _ |
POWERFULMOVES
left a comment
There was a problem hiding this comment.
Delta review of #3248: 7407a27 → d9cf795 (11a0164 fixes, d9cf795 merges main)
Verdict: CHANGES-REQUIRED (1×P2), for the merge commit only. All of 11a0164's script fixes verify. The merge, however, does not equal main plus the PR.
[P2] contract-correctness: the merge duplicates a register row (pmoves/docs/AGENTS/AGNOTE4482PHI.t1.md)
- The
2026-09-22T15:30:32Z CLAIM CRUSH-GLM52 (Knuckles) infra/knuckles-nvme-omarchy-storagerow is present once on main (line 3249 of 3264) and twice at d9cf795 (lines 3241 and 3251 of 3266). - Main relocated that row after the merge-base, where it sat at line 3231. The PR side's NOTE was appended directly after the old position, so the resolution kept both copies.
- Result:
git diff origin/main d9cf795c -- …PHI.t1.mdis +2 lines: the duplicated CLAIM plus the intended NOTE. It should be +1. - A duplicated CLAIM is register state the PR never meant to write. It also adds a second
docker volume rmoccurrence to the anchors ratchet: main 1 → head 2. - Fix: delete the copy at line 3241 (the stale PR-side position), keeping the NOTE row. The register diff vs main should then be exactly the one NOTE line.
- The rest of the merge is clean:
git diff --stat origin/main d9cf795chas 7 files, equal to the PR's file set (4eb1610 ∪ 7407a27 ∪ 11a0164).- Every PR file except the Makefile and the register has a blob identical to 11a0164.
- The Makefile's diff vs main is only the
docker-loginhunk (+3/−10). Its delta from 11a0164 is main's own changes.
Your items, re-measured at d9cf795 (fabricated tokens; fake docker; never ~/.docker)
-
xtrace: fixed.
{ set +x; } 2>/dev/nullis line 30, before any token read on either path;with-env.shcontains noset -x/xtrace/trap. Token occurrences in the output:Probe Before (7407a27) Now bash -x3 0 SHELLOPTS=xtrace make docker-login(real path)2 0 SHELLOPTS=xtrace make docker-login DRY_RUN=12 0 bash -o xtrace -o functrace— 0 BASH_ENVfile containingset -x(runs before line 30, then is switched off)— 0 legacy chain with GHCR_TOKENand xtrace exported— 0 Re-enabling: no function or subshell in the script sets
-x, and subshells inherit "off". The residual vector is an env file sourced bywith-env.sh(legacy path only) containingset -x, or a DEBUG trap planted viaBASH_ENV. Both need control of the environment or of trusted env files, so they are out of scope (P3, note only). -
Owner check: fails closed. On a real foreign owner (root-owned
/etc/hostname) it is refused withuid 1000, file uid 0. Withstatforced to fail (a shim on PATH),owneris empty and the script refuses withfile uid unknown, rc=1. -
Symlink: refused before the mode check (line 53, before
-f, owner and mode), with the message "must be a regular file, not a symlink" and no chmod hint. -
Token parsing (
IFS= read -r -d '', then strip one LF and one CR, then a CR/LF case guard):- Accepted: the valid token, the token with no LF, and the token with CRLF.
- Refused as a non-PAT: trailing space, leading space, tab, pad+1, short−2, missing first 2 chars, and an empty file.
- Refused as "exactly one line": a token split across 2 lines, two token lines, a double LF, and a lone CR mid-token.
- NUL mid-token and NUL trailing: refused, "contains a NUL byte".
- Exported
GHCR_TOKENdecoy: the source still reportsGHCR_READ_TOKEN_FILE.
-
The 7 new or changed tests fail at 7407a27. I ran 11a0164's test file against 7407a27's script in a throwaway worktree: 7 failed, 9 passed. By cause:
- 4 behavioural: owner accepted (
0 == 1), split token accepted, and the token leaked underbash -xand under make+SHELLOPTS. - 3 message-only:
not_0600and0400were already refused before and now differ only in wording. The symlink was already refused, but with the misleading chmod hint, so that UX fix is real. - The owner test fakes
id -u(non-root can't chown). My real-uid probe above covers the gap. - At d9cf795: 16 passed.
shellcheck -S warningis clean.
- 4 behavioural: owner accepted (
Class summary:
- reasoning gap: clean
- semantic-naming drift: clean
- contract-correctness: 1×P2 (the merge's duplicate register row)
- defense-in-depth: clean, apart from the P3 note on env-file/BASH_ENV-planted tracing
…beats env overrides Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… GHCR PAT docs - tests/test_ghcr_login.py: fabricated tokens + fake docker on PATH; asserts token only on stdin, never argv/stdout/stderr; 0600 + classic-shape refusals; read file beats exported GHCR_TOKEN/GH_PAT_PUBLISH. - mk/codex.mk: "$$(CONFIRM)" was shell command substitution, so the documented gh-app-token ALL=1 CONFIRM=1 always exited 3. - LOCAL_TOOLING_REFERENCE: replace the never-existing docker-login-ghcr. - GITHUB_APP: GHCR_TOKEN is not App-replaceable (GitHub Packages = classic PAT only). - register NOTE correcting the 2026-05-23 fine-grained-PAT GHCR advice. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ti-line token files Review of #3248 @ 7407a27 (P2): bash -x and SHELLOPTS=xtrace make docker-login printed the token. ghcr_login.sh now runs { set +x; } 2>/dev/null before any token handling. P3s: symlinks refused with a non-chmod message; file uid must equal the invoking uid (fail closed); exactly one line with optional trailing LF/CRLF (interior newline / NUL refused instead of joined); 0400 refusal explained. Tests: both xtrace paths assert 0 token occurrences; all 6 new tests fail at 7407a27 on behaviour (leak count 2, owner accepted, split token accepted, wrong messages). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The rebase union kept both copies: main's current wording (with the "blocked once patterned" clause and the volume-reset road) and this branch's carried stale copy of the older wording. The stale copy also trips the command-anchors ratchet twice (its docker volume rm mentions sit outside the baseline). Deletes the stale copy only; the canonical row and the lane's NOTE row are untouched. Register repair directed by B850-CLAUDE 2026-10-01.
d9cf795 to
3f29d8c
Compare
Fleet review: NO-REVIEWER-AVAILABLEEvery reviewer tier failed or was unavailable, so this PR has NOT been reviewed by the fleet lane. This is could-not-measure, not a pass.
_ lane: fleet-review chain (self-hosted kvm4) - spark-local (when online) -> kilo-primary -> kilo-alternate _ |
Fleet review: NO-REVIEWER-AVAILABLEEvery reviewer tier failed or was unavailable, so this PR has NOT been reviewed by the fleet lane. This is could-not-measure, not a pass.
_ lane: fleet-review chain (self-hosted kvm4) - spark-local (when online) -> kilo-primary -> kilo-alternate _ |
Why
On Knuckles, pulls from
ghcr.io/powerfulmovesreturn 403. Because of that, the Agent Zero image had to be rebuilt locally after a prune, and Archon runs a node-local image tag. The existingmake -C pmoves docker-logincould not take a read-only token on this node:scripts/with-env.shlets env files override exported vars, so an operator-suppliedGHCR_TOKEN=...isn't reliable.GHCR_TOKEN_FILEis consulted only afterGHCR_TOKEN/GH_PAT_PUBLISH/GITHUB_TOKEN/gh auth tokenare all empty, and this node exports the first two. Pulls 403 regardless; why those tokens fail was not measured, because a scope probe was refused as credential materialization.What
pmoves/scripts/ghcr_login.sh(now backsdocker-login):GHCR_READ_TOKEN_FILEwins whenever it is set. It is read beforewith-env.sh, so neither exported nor env-file tokens can displace it.ghp_+ 36 alphanumerics).GHCR_USERNAME(the PAT owner) is required on this path.DRY_RUN=1validates everything and prints only user, registry and token source.--password-stdin). It is never on argv and never printed.pmoves/mk/codex.mk:"$$(CONFIRM)"was shell command substitution, not the make variable, so the documentedmake gh-app-token ALL=1 CONFIRM=1always exited 3. Fixed to$(CONFIRM).LOCAL_TOOLING_REFERENCE.mdreplaces the never-existingmake docker-login-ghcr.GITHUB_APP.mdadds a correction:GHCR_TOKENis not App-replaceable.Correction to the step-0 report:
make gh-app-tokendoes exist (inpmoves/mk/codex.mk; the first grep missedmk/). The GITHUB_APP.md:67 reference was not stale, but itsALL=1 CONFIRM=1form was broken by the bug above.Vendor docs
github/docsdata/reusables/package_registry/packages-classic-pat-only.md). For node-side pulls, the container registry's login steps say to "Select theread:packagesscope to download container images and read their metadata" (data/reusables/package_registry/authenticate-to-container-registry-steps.md, rendered inworking-with-the-container-registry.md; the same reusable opens withpackages-classic-pat-only). An earlier revision citedauthenticate-packages.md, where that sentence sits under the Actions-workflow bullets, so it was the wrong section for a node pull. App installation tokens and fine-grained PATs are therefore not a documented GHCR credential. A short-lived App token was preferred but is not supported, so this PR uses a read-only classic PAT with a short expiry.docs/reference/commandline/login.md):--password-stdin"prevents the password from ending up in the shell's history, or log-files".pass/secretserviceon Linux), credentials are stored base64-encoded inconfig.json. Knuckles has nodocker-credential-*helper installed.Tests
pmoves/tests/test_ghcr_login.py, 9 tests, all passing. There's no network and no real login: tokens are fabricated at runtime, and a fakedockeron PATH records argv and stdin. They check that:GHCR_TOKEN/GH_PAT_PUBLISH;github_pat_,ghs_, empty) and a missing username or file are all refused;make -nunderstub_docker_path);gh-app-token ALL=1 CONFIRM=1renders[ "1" != "1" ]. As a control,origin/main:pmoves/mk/codex.mkcontains the buggy"$$(CONFIRM)"once; this branch contains it 0 times.shellcheck -S warningpasses.Operator steps (after merge)
read:packagesand an expiry of 90 days or less: https://github.com/settings/tokens/new?scopes=read:packages. Authorize it for SSO if the org enforces it. The account must have read access to the POWERFULMOVES packages.mkdir -p -m700 ~/.pmoves && install -m600 /dev/null ~/.pmoves/ghcr_read_token && read -rs T && printf %s "$T" > ~/.pmoves/ghcr_read_token; unset Tpassordocker-credential-secretservice) before logging in. Otherwise docker writes the login base64-encoded to~/.docker/config.json.make -C pmoves docker-login GHCR_USERNAME=<pat-owner-login> GHCR_READ_TOKEN_FILE=$HOME/.pmoves/ghcr_read_token DRY_RUN=1, then run it again withoutDRY_RUN.docker pull ghcr.io/powerfulmoves/pmoves-agent-zero:pmoves-latest.Lane:
fix/ghcr-read-access-knuckles(B850-CLAUDE, Knuckles). Do not merge without control review.🤖 Generated with Claude Code