Skip to content

fix(audit): reduce false positives in Markdown examples - #475

Merged
runkids merged 6 commits into
mainfrom
runkids/fix-audit-markdown-context
Oct 7, 2026
Merged

runkids merged 6 commits into
mainfrom
runkids/fix-audit-markdown-context

Conversation

@runkids

@runkids runkids commented Oct 7, 2026 •

Copy link
Copy Markdown
Owner

Legitimate SDK system: parameters in Markdown examples currently produce CRITICAL findings and block anthropics/skills installs and updates. Report recognized parameter shapes as HIGH so default policy warns and strict policy blocks, while explicit concealment remains CRITICAL.

Share fenced-code parsing across static, command-tier, and dataflow analysis using the existing Goldmark dependency. Preserve shell analysis across HTML/comment boundaries, blank lines, tab-separated fence metadata, and unclosed blocks, honor explicit global/project severity overrides, keep independent disclosure findings on the same line, and preserve whole-line exclusions for full custom rule replacements. Add regression tests, an isolated CLI runbook, and matching English/Japanese/Korean/Chinese documentation.

Generic disclosure restrictions now use the HIGH rule prompt-injection-5; existing overrides or accepted findings for prompt-injection-4 do not apply to it. Some malicious wording can match only HIGH, so strict policy remains the option for blocking that ambiguity. Findings remain visible.

Type

  • Bug fix
  • Small improvement (docs, typo, minor refactor)
  • Feature proposal (proposals/ only — see CONTRIBUTING.md)

Linked Issue

Closes #468

Validation

  • Linux devcontainer: make check (formatting, vet, unit and integration tests).
  • audit_disclosure_policy_runbook.md: 4/4 E2E steps passed, covering default/strict audit, install/update rollback, remembered acceptance, hidden shell flows, and severity overrides.
  • Website: npm run build passed for all five locales.
  • python3 scripts/ai-context.py check and git diff --check passed.
  • Scanned anthropics/skills pinned to 683bc88e56f3e09ba94f7055977f3d3aa499f202: claude-api has 0 CRITICAL and 44 HIGH findings, and default policy does not block it.
  • Windows was not tested locally; PR CI includes Windows checks. UI tooling was not run because this PR changes no UI code.
  • Regression coverage includes SDK severity overrides, independent disclosure directives, hidden shell flows, blank lines across HTML boundaries, tab-separated fence metadata, and custom disclosure-rule exclusions.

Checklist

  • I've read CONTRIBUTING.md
  • Tests included and passing (make check) — for code changes
  • No unrelated changes in the diff
  • Scope is focused — one concern per PR

Avoid blocking legitimate Markdown SDK parameters and ambiguous disclosure advice by default while retaining visible HIGH findings and strict-policy gating. Preserve explicit concealment, custom severity overrides, and shell dataflow coverage in HTML and comments. Add regression coverage and document rule-ID compatibility.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-07T15:03:43.077060Z 2922026 Manual request
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8dee3108f3

ℹ️ 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".

Comment thread internal/audit/markdown_context.go Outdated
}
blocks = append(blocks, markdownCodeBlock{
start: line, end: line + len(lines),
language: strings.ToLower(string(block.Language(source))), lines: lines, inHTML: inHTML,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Normalize whitespace in fenced-block language identifiers

A fence such as bash<TAB>title=example is no longer recognized as shell: Goldmark 1.7.8's Language stops only at an ASCII space, so this stores bash<TAB>title=example, which fails the shellLangs lookup. The previous strings.Fields implementation accepted tabs, and now a cross-line flow such as X=$API_KEY followed by curl ... $X in this block receives no dataflow-taint-var finding and can pass strict audit. Split the info string on whitespace before storing its first language token.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in e55ec29. Fence languages now use strings.Fields before case normalization, preserving shell recognition for tab-separated metadata. TestMarkdownShellBlocksUseSameContext covers an uppercase BASH fence with tab-separated metadata; the E2E runbook also verifies that it blocks under strict policy. make check and all 4 E2E steps passed.

Parse complete Markdown source without HTML blocks for shell analysis so blank lines inside raw HTML cannot split taint flows. Retain rendered context separately for SDK severity decisions. Normalize tab-separated fence metadata with strings.Fields so shell blocks remain auditable. Cover both regressions in unit tests and the CLI runbook.
@runkids

runkids commented Oct 7, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e55ec290b7

ℹ️ 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".

Comment thread internal/audit/patterns.go Outdated
Comment on lines +133 to +135
if r.ID == "prompt-injection-5" {
// Exclude explicit-concealment phrases, not separate generic directives.
return r.Regex.MatchString(r.Exclude.ReplaceAllString(line, " "))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Honor custom excludes when replacing rule 5

When audit-rules.yaml fully replaces prompt-injection-5 with a custom regex and exclude, this ID-based special case no longer applies the documented line-suppression semantics used by every other rule. For example, a replacement with regex: '(?i)secret' and exclude: '(?i)safe' still reports safe secret, because only safe is removed before the regex is retried; under a strict threshold this can incorrectly block an audit despite the user's explicit exclusion. Restrict this behavior to the built-in rule semantics or otherwise preserve normal excludes for full custom replacements.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 2922026. Phrase exclusion is now metadata attached only to the built-in rule, rather than behavior selected by rule ID. A full custom regex replacement therefore retains the normal whole-line exclude semantics, while severity/enabled overlays preserve the built-in behavior. TestOutputSuppressionCustomRuleExclude covers both raw content and Markdown, and TestOutputSuppressionMixedRuleOverrides retains coverage of independent directives. Validation: make check, 4/4 isolated CLI E2E steps, the website build for all five locales, and the context-router check passed.

Track phrase exclusions as built-in rule metadata so a full custom regex replacement retains normal whole-line exclusion behavior. Keep phrase exclusions when only severity or enabled state is overridden.

Add raw-content and Markdown regression coverage. Verified with make check, four CLI E2E steps, the five-locale website build, and the context-router check.
@runkids

runkids commented Oct 7, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🎉

Reviewed commit: 2922026264

ℹ️ 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".

@runkids
runkids merged commit 87d1924 into main Oct 7, 2026
8 checks passed
@runkids
runkids deleted the runkids/fix-audit-markdown-context branch October 7, 2026 15:36
runkids pushed a commit that referenced this pull request Nov 24, 2026
prompt-injection-1 reports lowercase root: object properties inside
Markdown code fences as CRITICAL prompt overrides. This blocks skills
with ordinary DOM examples such as IntersectionObserver options in
GoogleChrome/modern-web-guidance.

Non-Markdown files already restrict prompt-injection-1 to uppercase
labels (#923), and Markdown fences already downgrade SDK-style
system: / System: parameters from CRITICAL to HIGH (#475). Extend
markdownFindingSeverity with a strict RE2 whitelist grammar
(mdRootPropertyRe) that downgrades lowercase root: lines in parsed
non-HTML fenced code blocks only when the value is a comma-terminated
identifier or member expression, or a single-line call whose arguments
are limited to quoted strings, identifiers or members, or plain
numbers. Quoted-string arguments and trailing // comments are not
inspected by this exception; other audit rules still scan them.

Keep findings visible at HIGH so default policy warns without blocking
while strict policy still blocks. Uppercase ROOT:, prose outside
fences, raw HTML comments, bare words or members without commas,
unquoted commands or prose inside calls, regex or template literals,
unquoted brackets or braces, comments inside parens, unclosed calls,
bare quoted prose, un-commented trailing prose, and explicit rule
overrides stay CRITICAL. Update English and translated docs to match.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[audit] prompt-override rule flags API example code inside Markdown docs — anthropics/skills can never install/update

1 participant