Repository navigation
fix(scoring): mask shadowed environment secrets via knownSecrets - #1380
Conversation
Review limited to the specified diff and supplied PR description; no PR code was run, built, or installed. |
b05f2bd to
3159f31
Compare
|
All three earlier findings remain unresolved in the specified diff:
Reviewed only the specified diff against the trusted base rules and supplied description. No PR code was run, built, or installed. |
3159f31 to
cd2ceac
Compare
Resolved earlier findings:
The shallow checkout prevents triple-dot resolution; commit metadata identifies |
|
I hope that clears all the checks. |
SaulMoro
left a comment
There was a problem hiding this comment.
This was generated by AI during triage.
@aryansinha1908 Approving at cd2ceac. We reran your setup with the built CLI on a local bare team repo, with an isolated HOME. The setup: DEPLOY_HOOK declared in env/secrets.yaml, team-hook-1362 set through teamai env set, personal-hook-1362 exported in the environment, and a finished session whose first prompt contains the personal value. On the merge-base and on current main (744d982), score prints First prompt: Deploy with personal-hook-1362. This head prints First prompt: Deploy with <REDACTED:DEPLOY_HOOK (environment)>. tsc, lint, the three affected unit files (101 tests) and the score e2e files pass. Both new tests fail on the base for the right reason.
Non-blocking notes:
- [P2 non-blocking] The
session-work.tscall site has no test of its own. With only that file reverted, all 101 tests still pass. The issue names the other two sites, and each has its new test. A case for the session read insession-work.tswould keep the third site from regressing. - [P2 non-blocking]
collectTeamSecrets(src/env-resolution.ts) no longer has any caller, and its doc comment still describes the old path. Please remove it here, or say why it stays. - [P3 nit]
{ 'recursive': true }inworkflow-scoring-evidence.test.tsquotes the key, unlike the rest of the test files.
Not run through the real CLI: the workflow evidence path and the score --next queue path. The unit tests cover the first; the second stays covered only by reading the code.
The CI review's earlier findings were real, and they are fixed at this head. Its last comment, which calls the real-CLI record missing, was posted before the body was edited. The record is there now, and it reproduces. All CI jobs pass; the GitHub-provider e2e job is skipped by the fork policy.
Summary
Scoring built its mask set as
{ ...collectEnvSecrets(), ...await collectTeamSecrets(config) }, so when the environment and the team both had a value for the same secret name and the two differed, the team value replaced the environment's and the member's own value went out unmasked: into the judge evidence (buildEvidence), and into theFirst prompt:log, the judge prompt and the judged transcript (scoreSession, and the session read insession-work.ts). All three call sites now useknownSecrets(config), the set the workflow engine already masks with, which keeps the shadowed value as<KEY> (environment).Type of Change
Test Plan
npx tsc --noEmitpassesnpm run lintpassesnpx vitest runpasses. The affected files pass (workflow-scoring-evidence.test.ts,session-scoring.test.ts,session-work.test.ts: 101/101). The full suite has 11 failures locally, all in files that import none of the scoring modules, each caused by this machine:env-loader.test.ts(5): Ubuntu's/etc/bash.bashrcprints its sudo hint into the bash output the tests readcursor-*.test.ts(3): thesqlite3CLI is not installedsubmodule-checkout.test.ts(2): local Git is 2.43, and the tests expect config-based hooks (Git 2.54+)git-discovery.test.ts(1): most likely the same Git versionNew tests, one per scoring path. In each,
env/secrets.yamldeclaresDEPLOY_HOOK, the team store holdsteam-token-value-1362, and the environment holdspersonal-token-value-1362:workflow-scoring-evidence.test.ts: masks both the environment value of a secret and the different value the team gives it. The team value is in a repo file and the personal value in the session; neither appears in any evidence file.session-scoring.test.ts: …in the scorer's prompt, the evidence and the first prompt. The personal value is in the scorer's prompt and the session's first prompt; neither value appears in the judge prompt, the judged transcript, the reasoning file, or the printed output.With the old spread restored, both tests fail on the personal value (
expected [ 'prompt.md', 'transcripts/write#1.md' ] to deeply equal [], andexpected 'Judge the session. Never print person…' not to contain 'personal-token-value-1362'). With the fix, both pass.Real-CLI verification
At
cd2ceaca, afternpm run build, with the built CLI (node dist/index.js) against a local bare team repo (--provider git) in a tempHOME. The team repo declaresDEPLOY_HOOKinenv/secrets.yamland has a scorer whose body readsNever print personal-hook-1362 or team-hook-1362.. A finished Claude session in the app directory has the first promptDeploy with personal-hook-1362. The judge is a fakeclaudeonPATHthat keeps copies of the prompt and transcript it is given.The same script on a build with the old spread restored prints
First prompt: Deploy with personal-hook-1362andNever print personal-hook-1362 or <REDACTED:DEPLOY_HOOK>, and the final grep matches all four files.Workflow scoring (
teamai score --next) is covered by the unit test above, not by this run:workflow startrefuses a scorer that holds a secret's value (invalid_inputs), so a real run can't put the value in the scorer prompt. Other agents and thegitlab/githubproviders are left to CI.Related Issues
Closes #1362
Notes for Reviewers
DEPLOY_HOOK, a name that doesn't look secret, on purpose.AgentSession.findalready scrubs transcripts against the raw environment (scrubSession), so a value under a secret-looking name likeGH_TOKENis masked before scoring's own mask runs and could not show the bug. A declared secret with an ordinary name only goes through scoring's mask, and that mask leaked.collectTeamSecrets/collectEnvSecretsimports are removed from the three files. No docs orskill-data/changes: scoring now masks what the docs already say it masks.