Repository navigation
feat(audit): detect whitespace padding that hides instructions - #755
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3a66ad636d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| } | ||
| findings = append(findings, Finding{Severity: severity, Pattern: ruleWhitespacePadding, | ||
| Message: fmt.Sprintf("%s: %s", configured.Message, detail), File: filename, | ||
| Line: lines[index].sourceLine, Snippet: strings.TrimSpace(lines[index].text), |
There was a problem hiding this comment.
Preserve payload identity in padding acceptance keys
After a user accepts a benign 40-blank-line finding with --force at a HIGH threshold, a later update can introduce a different padded instruction elsewhere in the same SKILL.md without blocking again. Blank-run findings—and density findings anchored on blank lines—always receive an empty snippet here, while AcceptKey (internal/audit/accept.go:13–18) ignores both the line and message. Consequently, ApplyAcceptedFindings acknowledges these new findings and the update gate skips them (internal/install/install_audit.go:363–365), rather than remembering only the “exact findings” described in website/docs/reference/commands/update.md:324–330. Include the padding form and relevant padded content in the acceptance identity so changed payloads require fresh approval.
AGENTS.md reference: AGENTS.md:L36-L36
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 10ca389. Whitespace-padding acceptance keys now include the finding form and a digest of relevant evidence; density findings bind to all eligible file content. Added a regression for a newly added padded run in the same SKILL.md and changed-payload coverage across detector forms. Focused audit, install, and update integration tests plus vet passed.
|
@codex review |
|
Codex Review: Didn't find any major issues. 🚀 Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
Thanks for this, and for the care around acceptance keys and CRLF line locations. I read through the diff and have a few points. Correctness
Docs
Cleanup (judgement call)
If anything here looks wrong to you, please say so. Happy to discuss. |
10ca389 to
731c73a
Compare
|
Updated in 731c73a:
The reported regressions failed before the fixes. The audit and CLI package suites, website typecheck, and all-locale build pass on isolated Linux. Docker/devcontainer was unavailable locally; CI covers other platforms. CI passed unit, Linux integration, Windows, security, and offline sandbox checks. The macOS build and integration jobs were cancelled before any steps started while waiting for runners. |
runkids
left a comment
There was a problem hiding this comment.
Thanks. Detection, line numbering and acceptance keys look right. Existing fingerprints don't change, because acceptanceContext is only appended when it is set. Two small points:
1. The reparse guard is much looser than the comment suggests (internal/audit/whitespace_padding.go:141). whitespace*100 <= paddingDensityBytes*paddingDensityPercent compares the file's total whitespace against a fixed ~3.9 KB, so almost every .md file over about 15–20 KB parses Markdown again. A CRLF file also clears blocks and pays for one more parse. "Most files have too little whitespace" doesn't hold for ordinary docs. A guard based on the whitespace share, or reusing the blocks already parsed, would keep large skills cheap.
2. A custom regex on this ID is silently ignored (patterns.go:135). A full overlay with id: whitespace-padding and a regex replaces the rule, but matchesLine always returns false for this ID. The built-in detector keeps running and the user gets no warning. Rejecting regex/exclude for this ID at load time, or warning about them, would make the documented "leave these unset" enforceable. This is low priority, since only a hand-edited rules file can reach it.
Long blank spans and repeated filler can move meaningful instructions out of view during skill review. Add four padding signals under the static analyzer with Markdown exemptions and original-source line mapping. Reuse rule overlays so global and project toggles and severity/confidence overrides also govern this file-level detector. Cover threshold boundaries, benign examples, optimized scans, reports and CLI rule controls. Implements item 17 of runkids#746. Co-Authored-By: GPT-6.1 Sol <[email protected]>
731c73a to
c402ae1
Compare
|
Updated in c402ae1:
The guard and rule-loading regressions failed before the fix. The full audit package and documentation router check pass on isolated Linux. Docker/devcontainer was unavailable; I didn't rerun the website build for these text changes. |
runkids
left a comment
There was a problem hiding this comment.
Thanks for the update. Both points are resolved in c402ae1:
paddingMayHaveExemptionscovers every casepaddingExemptionscan exempt, so ordinary prose skips the second parse without losing an exemption.regexandexcludeonwhitespace-paddingare now rejected inparseRulesYAML, which covers both the rules file and the dashboard, and the docs say so in all five locales.
internal/audit passes in the devcontainer, and CI is green. Nothing more from me on this round.
|
Thanks for checking. Glad both points are resolved. |
runkids
left a comment
There was a problem hiding this comment.
Approving; all review points are resolved and CI is green on the updated branch.
Type
proposals/only — see CONTRIBUTING.md)approvedlabel)Feature implementing one item from the #746 list. It has no
approvedlabel yet; happy to close it if you'd rather not take it.Linked Issue
Implements item 17 of proposal PR #746.
What changed
Add
whitespace-paddingto the static audit analyzer with four forms:In Markdown
.mdfiles, exempt parsed fenced/indented code and table rows from padding accounting. Whitespace inside those blocks stays exempt; nonblank code/table text still triggers a preceding external blank run. An unclosed CommonMark fence exempts its contents through EOF. Fences found only by the HTML-stripped security reparse do not grant exemptions. Density/repetition can flag generated data, including JSON and lookup tables.Keep one finding per qualifying blank, repeated, or adjacent leading-horizontal run. Preserve original LF-based source locations across CRLF, CR, Unicode separators, vertical tab and form feed. Count CRLF once; density uses original eligible UTF-8 byte counts.
Run the detector through supported content, file and skill scans, including the optimized walker. Honor static-analyzer selection and global/project disable, severity and confidence overlays by ID or pattern. Explicit severity overrides every form; leave
regexandexcludeunset for this file-level detector.Include the rule in existing JSON/Markdown/SARIF reporting and obfuscation risk scoring. The new HIGH-capable finding can change blocking and exit behavior at a HIGH threshold, including strict-profile gates. Update English guidance, all four translated catalogs/guides and the built-in skill reference; include a CLI E2E runbook. No behavior outside item 17 is retained.
Accepted padding findings now include the finding form and detector evidence in their acceptance key. A changed padded payload or a new padded run in the same file requires fresh approval; unchanged blank-run findings remain accepted across line shifts. Identical occurrences have separate acceptance keys, so previously accepted padding findings require fresh approval. Density keys use all eligible file content.
Why
Padding can move instructions out of view during human review. Structural checks identify these runs without executing content. Leading-only horizontal accounting and parsed Markdown exemptions keep the reproduced alignment and code-example cases clean. Exempt text must still reveal padding before the block, or a Markdown wrapper can suppress the warning. Findings indicate hidden-content risk, not proof of malicious intent.
Checks
The audit and CLI package suites passed on isolated Linux, including regressions for grouped horizontal padding, colliding same-line findings, and duplicate acceptance. Website typecheck and the all-locale build passed. CI verifies other platforms.
Checklist