Repository navigation
Fix: Keep the config token out of the audited env - #254
ModeSevenIndustrialSolutions merged 3 commits into
Conversation
The config step runs the setup-python interpreter with inputs.token in its environment after the install step has put the audited project into that interpreter's site-packages. A .pth file shipped by any installed wheel runs at interpreter start-up and can read the token. Add tests that pin the fix: every step referencing inputs.token runs before the install step, and the config step's python3 does not run a hostile .pth already present in site-packages. A control test proves the marker wheel does fire under plain python3, so the second test cannot pass vacuously. Both fix-dependent tests are marked strict xfail until the fix lands. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: lf-releng-code-monkey-bot[bot] <332050256+lf-releng-code-monkey-bot[bot]@users.noreply.github.com>
The config step ran the setup-python interpreter with inputs.token in its environment after the install step had put the audited project and its dependencies into that interpreter. A .pth file from any of those wheels runs at interpreter start-up, so the project could read a token that typically grants contents:read on a private repository. Move the config step ahead of the install step, so the token is gone before any audited code reaches the interpreter, and run the resolver with python3 -I -S. The resolver uses only the standard library, and -S skips site-packages, which still matters where a self-hosted runner's tool cache keeps packages from an earlier job. Remove the expected-fail markers from the tests this makes pass, and correct the README note that said the resolver used the runner's preinstalled python3. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: lf-releng-code-monkey-bot[bot] <332050256+lf-releng-code-monkey-bot[bot]@users.noreply.github.com>
Add a job to the testing workflow that runs tests/test_config_token_isolation.py, matching the existing jobs for the install step guard and cache scope tests. Without it the new tests would never run in CI and a regression could merge unnoticed. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: lf-releng-code-monkey-bot[bot] <332050256+lf-releng-code-monkey-bot[bot]@users.noreply.github.com>
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain for the change isolating config resolution from the audited Python environment.
No open issues 🎉
What changed in this PR
This PR addresses #253 by isolating config resolution from the audited Python environment, preventing installed packages’ startup hooks from accessing the config token.
Changes:
- Moves config resolution before package installation and runs the resolver with
python3 -I -S. - Adds regression tests for token-step ordering and isolation from a marker-writing
.pthfile, plus a dedicated CI job. - Updates the README to describe the interpreter and isolation behavior.
| File | Description |
|---|---|
tests/test_config_token_isolation.py |
Tests step ordering and .pth isolation, with a control confirming the hook executes without isolation. |
README.md |
Documents config resolution’s interpreter and token isolation. |
action.yaml |
Runs config resolution before installation with isolated Python startup. |
.github/workflows/testing.yaml |
Adds a dedicated config-token-isolation test job. |
Review effort: Balanced
|
Scope check for the reviewer: this PR covers the one step that holds
So no change is needed in this PR. A possible follow-up, separate from it, is a README sentence telling callers to give the auditing job no OIDC permission or secrets of its own. |
ModeSevenIndustrialSolutions
left a comment
There was a problem hiding this comment.
🤖 Dependamerge
Approved this pull request ✅
9fea5f6
into
lfreleng-actions:main
Closes #253
Authored by an AI agent; human review required
claude-opus-5.5via GitHub Copilot CLI502980f19c042ded518c1da74d079d89cb257895uv run --locked python -m pytest tests -quv run --locked python -m pytest tests/test_config_token_isolation.py -q --runxfail (test commit, expected failures)prek run --files tests/test_config_token_isolation.pyprek run --files action.yaml README.md tests/test_config_token_isolation.py .github/workflows/testing.yamlaislop scan --staged --json (each commit; empty diagnostics)zizmor --persona auditor .github/workflows/testing.yaml action.yamlThe
github-code-monkey-botworkflow opened this pull request.Nobody has merged it; a maintainer must review it first.
Review findings on this pull request are answered by a later revision round of this workflow, up to ten rounds; a maintainer must act on any finding that remains after that, and reviews every round before merge.
What changed
The
Resolve allow-list via configstep ran the setup-python interpreter withinputs.tokenin its environment. It ran afterInstall build products/dependencieshad installed the audited project's wheels andrequirements.txtinto that same interpreter. A.pthfile from any of those packages runs when the interpreter starts, so the audited project could read the token. That token is typically a PAT or App token withcontents:readon a private repository.This PR makes three changes, one per commit:
tests/test_config_token_isolation.py, first with strictxfailmarkers:inputs.tokencomes before the install step;.pthgoes into a venv, the config step's own script (read fromaction.yaml) runs with that venv first onPATH, and the test asserts the marker file is absent. A stubgitthat always fails keeps the test offline, and the test asserts that the helper reached its first git call;.pthfires and sees the token under plainpython3, so the main test cannot pass vacuously.python3 -I -S. The resolver imports only the standard library.-Sstill matters on self-hosted runners, where a persistent tool cache can hold packages that an earlier job installed. This commit removes thexfailmarkers. It also corrects the README note, which said the resolver used the runner's preinstalledpython3(it uses the setup-python one onPATH).tests-config-token-isolationjob totesting.yaml, following the pattern of the existing install-guard and cache-scope jobs.No other step references
inputs.token.Validation
uv run --locked python -m pytest tests -q: 89 passed, 2 xfailed after the test commit; 91 passed after the fix. Each commit leaves the suite green.--runxfailon the test commit: the ordering test and the.pthtest both fail for the expected reasons (the marker gets written).prek run --files <changed files>on each commit: all hooks pass (gitlint, ruff, mypy, basedpyright, yamllint, actionlint, markdownlint, reuse, aislop and the rest).aislop scan --staged --jsonfor each commit, with ruff onPATHso the lint engine ran: emptydiagnostics.zizmor --persona auditor .github/workflows/testing.yaml action.yaml: no findings.Points a reviewer may question
steps.config_resolve.outputs.*) are used only by later steps, so behaviour is otherwise unchanged.-I -Sas well as the move: the move alone covers GitHub-hosted runners.-Scovers a reused self-hosted tool cache. It is safe because the resolver is stdlib-only, and that file is mirrored withharden-runner-block-action; this PR does not touch it.gitorpython3binary that an earlier job planted on a persistent self-hosted runner. That is outside what this action can control.--no-index), which takes a few seconds.