Repository navigation
feat(audit): detect sensitive destinations and unsafe deserialization - #753
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: b57464e31a
ℹ️ 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".
| severityOverridden bool `yaml:"-"` | ||
| confidenceOverridden bool `yaml:"-"` | ||
| excludePhrase bool `yaml:"-"` | ||
| Files fileGlobs `yaml:"files,omitempty"` |
There was a problem hiding this comment.
Preserve file filters when rules are re-enabled
An applicability-only override saved through the dashboard YAML editor, such as id: unsafe-deserialization-python with files: [], is silently deleted when the rule is disabled and re-enabled. In rules_mutate.go, removeEntryByID, removePatternEntry, and clearDisableForPattern all decide whether an entry has remaining overrides without checking Files. Re-enabling therefore restores the built-in file scope; in this example, previously configured Markdown/text coverage disappears. All three preservation checks need to retain non-nil Files, including explicit empty lists.
AGENTS.md reference: AGENTS.md:L36-L36
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 144a2f2: all three re-enable paths retain non-nil Files overrides, including files: []. Regression tests cover rule toggles, pattern toggles, and clearing a rule-level disable.
| if r.Regex.MatchString(target) { | ||
| return r.Severity |
There was a problem hiding this comment.
Check the URL hostname before escalating metadata mentions
For an inline requests.get("https://ipinfo.io/169.254.169.254/json") in SKILL.md outside a code fence, the request targets the public host ipinfo.io, but this check searches the entire captured URL and finds the metadata address in its path. That promotes the finding from HIGH to CRITICAL, causing the default install audit to reject a harmless skill. Parse the captured URL and check its hostname before promoting severity; metadata references in a public URL's path or query should remain HIGH.
AGENTS.md reference: AGENTS.md:L36-L36
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 144a2f2: severity promotion now checks the parsed request hostname, so a metadata IP only in a public URL path or query remains HIGH. Regression tests cover Markdown, source files, and code fences; actual metadata-host requests remain CRITICAL.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 144a2f25c6
ℹ️ 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".
| u, err := url.Parse(target) | ||
| if err != nil || u.Hostname() == "" { | ||
| continue |
There was a problem hiding this comment.
Strip Markdown delimiters before parsing request URLs
For an ordinary SKILL.md instruction such as Run `curl http://169.254.169.254` , the curl/wget regex captures the closing backtick as part of target. url.Parse rejects that backtick in the hostname, so the finding falls through to HIGH rather than the previous CRITICAL result. The default install audit therefore allows a skill that explicitly requests a metadata host. Exclude Markdown delimiters from the URL capture before parsing and add a bare-host inline-code regression; the existing /latest case puts the backtick in the path and does not exercise this failure.
AGENTS.md reference: AGENTS.md:L36-L36
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 6416eab: the scanner trims trailing inline Markdown backticks before parsing recognized request URLs, so the bare-host curl example stays CRITICAL. I also keep metadata addresses found only in non-metadata URL paths or queries at HIGH in source files and executable fences; TestMetadataContextSeverity covers the inline case, public path/query assignments, and a metadata-host control.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6416eabfb5
ℹ️ 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".
|
|
||
| var safeYAMLArgument = regexp.MustCompile(`^Loader\s*=\s*(?:yaml\.)?C?SafeLoader$`) | ||
| var safeTorchArgument = regexp.MustCompile(`^weights_only\s*=\s*True$`) | ||
| var metadataURLRegex = regexp.MustCompile("(?i)https?://[^\\s\"'<>]+") |
There was a problem hiding this comment.
Keep URL masking within a single source literal
For an admitted .js skill file containing fetch(`https://example.com/`);fetch(`http://169.254.169.254/latest`);, this new regex consumes both template literals as one URL because it accepts backticks and statement delimiters. maskNonMetadataURLPathMentions then parses example.com as the hostname and blanks the actual metadata request as though it were part of the public URL's path. Since requestRegex does not recognize backtick-quoted fetch arguments, the finding falls from CRITICAL to HIGH, so the default install audit no longer blocks it. Bound the masking span to one URL literal/token and add adjacent-template-literal regression coverage.
AGENTS.md reference: AGENTS.md:L36-L36
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 65358f7: the metadata URL scanner now stops at template and Markdown backticks, so a public URL cannot absorb an adjacent JavaScript template literal metadata request. TestMetadataContextSeverity covers a public metadata-IP path staying HIGH and the adjacent metadata request staying CRITICAL; the full internal/audit tests and go vet pass.
|
@codex review |
|
Codex Review: Didn't find any major issues. Delightful! 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 writing down how the metadata severity differs from the proposal. I read through the diff and have a few points. Correctness
Docs
Scope
If anything here looks wrong to you, please say so. Happy to discuss. |
65358f7 to
8b0c5e4
Compare
|
Updated in 094a432:
The reported cases fail on the previous head and pass now. The full audit package, website typecheck and all-locale build pass on isolated local Linux. Docker/devcontainer was unavailable locally; CI covers the other platforms. |
8b0c5e4 to
094a432
Compare
runkids
left a comment
There was a problem hiding this comment.
Thanks. The rule overrides, files validation and safe-loader negatives look right.
1. curl option values are read as request targets (internal/audit/sensitive.go:130). The skip list covers -H, -d, -o, -u and -X, but not -x/--proxy, -e/--referer, -T or --resolve. curl -x http://localhost:8080 https://example.com therefore reports the proxy as an internal target, a MEDIUM ssrf-internal-0 on a public request.
2. The new patterns get no category (internal/audit/audit.go:43). categoryForPattern doesn't map ssrf-* or unsafe-deserialization, so --json, SARIF and the dashboard report them as risk. Exfiltration for ssrf-* and injection or privilege for deserialization would fit better. A test would keep the mapping from regressing.
3. The docs miss the new files field. The custom-rule field table in website/docs/reference/commands/audit-rules.md:114 has no files row, and the template comment at :171 still reads "Optional: exclude…, enabled" while DefaultRulesTemplate now mentions files. The four website/i18n copies have the same gap.
4. Severity versus the proposal. The proposal says "Propose CRITICAL findings for recognized cloud metadata destinations"; prose and config mentions come out HIGH here. If that is intentional, please note it in the PR body.
Possible noise to consider (not blocking):
unsafe-deserialization-yamlmatches ruamel'syaml = YAML(); yaml.load(f), which is safe by default.torch.load()withoutweights_only=Trueis flagged HIGH, although torch ≥ 2.6 already defaults toweights_only=True.
Existing URL and code-execution signatures miss cloud metadata access and language-specific deserializers. Add scoped static evidence and inspect safe YAML and torch options within each call so safe siblings cannot hide risks. Validate and preserve file applicability across overrides, scans and rule listings. Collect PHP scripts and propagate rule-load errors so malformed filters cannot silently disable global scanning. Document the policy and limits with paired regressions, fuzzing and an isolated CLI runbook. Co-Authored-By: GPT-6.1 Sol <[email protected]>
094a432 to
b144cad
Compare
|
Updated in b144cad:
The focused regressions and full audit package pass on isolated Linux. Docker/devcontainer was unavailable; I did not rerun the website build for these docs-only edits. |
runkids
left a comment
There was a problem hiding this comment.
Thanks for the update. All four points are resolved in b144cad:
- The curl skip list now covers proxy, referer, upload and resolve values, with tests on both sides.
ssrf-*maps to Exfiltration andunsafe-deserializationto Injection.- The
filesfield is documented in the English page and all four translations. - The PR body explains why prose and configuration mentions stay HIGH. That works for me.
internal/audit passes in the devcontainer, and CI is green. Nothing more from me on this round.
|
Thanks for checking. Glad the changes address all four points. |
# Conflicts: # internal/audit/audit_scan_content.go # internal/audit/patterns.go # internal/audit/rules.yaml
|
Heads-up: #755 just landed and conflicted with this branch in |
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.
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 10 of PR #746. Earlier discussion: issue #706, closed during consolidation.
What changed
.example.com.sh,bash,zsh,fish,py,js,ts,rb,php,php3,php4,php5,phtml,go,rs,swift,python,javascript,typescript,ruby,shell,console,golang,rust,makefile, ordockerfile. Other labels, includinghttp,powershell,pwsh,node,jsx,tsxandjava, remain HIGH unless an independently recognized literal request targets metadata. Explicit severity overrides take precedence; full regex replacements use configured severity without built-in context inspection..localhost/.internal/.localhosts. Dynamic evidence is MEDIUM with confidence 0.6 for direct request-input targets or interpolation at the start of a host; ordinary URL variables are negative. These rules recognize a limited call list and curl/wget forms including common options and shell delimiters; header values are not treated as destinations.filesglob applicability across loading, global/project ID/pattern overrides, rule rewrites, listings, raw/Markdown/file/skill scans and Markdown link rules. Basename globs match at any depth; slash globs use skill-relative paths (single-file scans use the basename, raw scans the supplied name). Partial overrides inherit omitted filters;[]clears them; full regex replacements replace the whole rule. Malformed globs fail even on disabled or unmatched overrides. This filters already admitted files rather than admitting new types. Re-enabling a rule or pattern preserves non-nil file filters, including an explicit empty list. Show effective scope in CLI/TUI/dashboard details and JSON; add dashboard field help and localized labels.function unserialize(...)declarations from deserialization findings..php,.php3,.php4,.php5and.phtmlunder the existing size/depth/binary scan bounds. Existing rules also scan these newly admitted files.Why
Generic URL and execution signatures miss sensitive destinations and language-specific deserialization evidence. Narrow applicability and call-local safe forms reduce ordinary-skill false positives. Metadata prose stays visible without blocking default installs; extensionless shebang scripts retain the same metadata severity as their
.shequivalents. Unlike the proposal’s blanket CRITICAL suggestion, prose and configuration mentions remain HIGH because a mention alone does not establish an executable request.These are static signatures, with no runtime SSRF or trust guarantee. They do not resolve aliases, data provenance, DNS, redirects or arbitrary multiline syntax. Unrecognized request forms can remain HIGH in prose or extensionless files without a shebang; source/fence context is a syntax heuristic, not proof of execution. PHP allowed_classes=false is not a recognized negative.
Checks
This update: focused regression and full
internal/audittests passed on isolated Linux; the documentation router check passed. Docker/devcontainer and a new website build were not available in this run.Previous head
094a432f: isolated local Linux audit package tests and website typecheck/all-locale build passed.At prior head b57464e, isolated Linux
GOMAXPROCS=2 GOFLAGS=-p=2 make checkpassed (router, formatting,go vet ./..., 38 unit packages and integration; integration 198.995s). The first run found one built-in-reference self-audit regression from a literal metadata hostname; descriptive wording fixed it, the focused test passed, and the full gate then passed. Existing platform/permission/native-runtime/opt-in guards produced 36 top-level skips; no audit regression was skipped or weakened.Prior head b57464e: native macOS
go test ./internal/audit -count=1passed with isolated HOME/XDG_CONFIG_HOME (1.368s), exercising native temporary paths. The new regressions failed before the fix on both macOS and Linux.At b57464e, the rebuilt binary: all 7 mdproof runbook steps passed (2526ms, zero failures/skips), including extensionless-script rejection, public-host twin install success and punctuated prose behavior. Initial runner XDG inheritance and a null-findings assertion were corrected; fixture requests/deserializers were never executed.
Website
npm ciandRAYON_NUM_THREADS=2 npm run buildpassed for en, ja, ko, zh-Hans and zh-Hant. Dependency/Browserslist/Rspack warnings were nonfatal.Five-pass project review and final consumer followup completed; full branch diff read; router and diff checks passed.
At 144a2f2, isolated Linux devcontainer audit tests and vet passed; the Docusaurus build passed for all five locales; python3 scripts/ai-context.py check and git diff --check passed. The Windows failures at b57464e were path-separator assertions in two audit tests and are normalized with filepath.ToSlash. GitHub Actions run 41561184675 for 144a2f2 passed unit, Ubuntu/macOS integration, Windows, Docker offline and redteam; Docker online and redteam-signal were skipped.
At 6416eab, isolated Linux devcontainer
go test ./internal/audit -count=1andgo vet ./internal/audit/...passed; the router check andgit diff --checkpassed. The new source/code-fence URL path and query regressions failed before the code change, then passed with the full audit package suite. The inline bare-host regression covers backtick trimming. Runbook additions were not executed; native macOS tests were not run locally because repository instructions require Go tests in the devcontainer. Prior-head CI run 41578469387 completed with unit-test failing only at TestPluginHostStateProducerLegacyProjection/local (internal/plugins/state_legacy_test.go:114), outside this diff; the other five required jobs passed and the two optional jobs were skipped.Dashboard tests/build/screenshots were not rerun this round (no dashboard code changed). Windows VM, opt-in online/Docker and extended fuzz runs were not performed.
At 65358f7, added failing-first coverage for adjacent JavaScript template literal URL masking. The focused TestMetadataContextSeverity run, full internal/audit package tests, go vet ./internal/audit/..., gofmt, and git diff --check passed in an isolated devcontainer. Prior-head CI run 41580110209 passed all six required jobs (unit-test, Ubuntu/macOS integration, Windows, Docker offline, redteam); docker-sandbox-online and redteam-signal were skipped.
Checklist
make check)