Widen bypass closures: destructuring, alias imports, PR head clone_url and merge ref#21
Closed
Conalh wants to merge 3 commits into
Closed
Widen bypass closures: destructuring, alias imports, PR head clone_url and merge ref#21Conalh wants to merge 3 commits into
Conalh wants to merge 3 commits into
Conversation
…l PR head)
- JS: addSecretVariable and referencesEnvSecret now match bracket
notation (process.env['KEY'] / ["KEY"]) alongside dot notation. An
inline `Authorization: Bearer ${process.env['API_TOKEN']}` or a stored
`const x = process.env["API_TOKEN"]` referenced later now flag the
exfil pattern.
- Python: addSecretVariable and referencesPyEnvSecret make the `os.`
prefix optional, so `from os import getenv; k = getenv("API_TOKEN")`
and `from os import environ; k = environ.get("API_KEY")` are tracked
as secret variables and trigger exfil on later external requests.
- Workflows: detectPullRequestHeadCheckoutOnTarget no longer requires a
structured `ref:`/`repository:` key — any reference to
github.event.pull_request.head.{sha,ref,repo.full_name} under a
pull_request_target workflow is flagged. Closes a bypass where a
custom `run:` step with `git checkout ${{ ... head.sha }}` skipped
detection. Subject/message/recommendation updated from "checkout" to
"reference" to reflect the broadened semantic; kind preserved for
back-compat.
Adds 6 tests (70 total, all passing on this branch's baseline).
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
v0.7.0 adds report envelope, mergeFindings, OTel gen_ai.conversation.id interop, matchSecret, applyExceptions. Lockfile only on this branch — leaving the action-bundle rebuild for when the widen-bypass-closures feature work lands.
…l and merge ref Extends #20's bypass closures with the next wave of evasions surfaced by external inspection. - JS destructuring (`const { API_TOKEN } = process.env`) and renamed destructuring (`const { API_TOKEN: t } = process.env`) now track the secret variable. addSecretVariable handles both direct and destructured forms. - Python aliased env imports: `from os import getenv as g` / `environ as e` (and the unaliased `from os import getenv` form already supported in #20) build a per-file alias map, then the secret-variable regex is generated dynamically from the alias union. Closes `token = g("API_TOKEN")` bypass. - Workflow referencesPullRequestHead now covers github.event.pull_request.head.repo.clone_url and standalone refs/pull/<n>/merge references — the two custom-shell patterns agents use when actions/checkout would attract review attention. - README: new "Detection limits" section documenting same-line URL requirement, no cross-file taint, no Python dep manifests yet, with a pointer to test/fixtures/bypasses/. - test/fixtures/bypasses/ established as the bypass-corpus pattern, with one fixture per closure and a CLI integration test per fixture. Adds 10 tests (80 total on this branch). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
afa1262 to
da04278
Compare
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Extends #20 with the next wave of evasions surfaced by external inspection. Same shape as #20 — broaden regexes to catch syntactic variants agents use to slip past line-based detectors. Also picks up the agent-gov-core 0.7.0 bundle rebuild that was pre-positioned on this branch (21ab387).
const { API_TOKEN } = process.envand the renamed formconst { API_TOKEN: t } = process.envnow track the secret variable (or alias). Single-line scope.from os import getenv as g/environ as ealiases from each file's content, then generates the secret-variable regex dynamically from the alias union. Closestoken = g(\"API_TOKEN\")bypass. Pairs naturally with Close detector bypasses: bracket env, unqualified getenv, custom-shell PR head #20's unaliased-import support.referencesPullRequestHeadnow also matchesgithub.event.pull_request.head.repo.clone_urland anyrefs/pull/<n>/mergereference (the merged-PR ref under elevated context is the same risk pattern as a head SHA checkout).test/fixtures/bypasses/corpus — Bypass fixtures are now a first-class pattern, with one fixture per closure and a CLI integration test per fixture. README inside the dir documents the ritual.Why stacked on #20
This PR's base is
close-detector-bypassesbecause the changes layer on top of #20's regex broadenings (same files, neighboring functions). GitHub will retarget tomainautomatically when #20 merges.Bundle update
agent-gov-core 0.5.0 → 0.7.0 was pre-positioned on this branch by 21ab387. My build picked it up and rebuilt
dist/action-bundle/index.jsaccordingly (65kB → 73kB; reflects 0.7.0's added envelope/exceptions/OTel surface).Deferred (carryover from the inspection)
TOKEN|SECRET|KEY|...heuristic needs design + real-world fixture corpus before tuning, to avoid regressing on FPs.requirements.txt,pyproject.toml) — belongs partly inagent-gov-core.Test plan
npm test— 80 passing (70 from Close detector bypasses: bracket env, unqualified getenv, custom-shell PR head #20's baseline + 10 new):npm run build— clean tsc + ncc bundle (73kB on agent-gov-core 0.7.0)referencesPullRequestHeaddoesn't fire on benignpull_request.head.repo.owner.loginreferences (the regex still only matchessha|ref|repo.full_name|repo.clone_url)test/fixtures/bypasses/README.md— comfortable with the convention?🤖 Generated with Claude Code