Skip to content

security-guidance: XSS-family substring rules fire on doc/prose files — extend the existing _DOC_EXTS carve-out #83851

Description

@choa712

Summary

In the security-guidance plugin (v2.0.0), the XSS-family substring rules — innerHTML_xss, react_dangerously_set_html, document_write_xss, new_function_injection — fire on documentation/prose files that merely mention the pattern, e.g. a markdown note documenting an incident or a coding guideline that quotes el.innerHTML = ....

patterns.py already solves this exact problem for other rules: eval_injection carries "path_filter": lambda p: not p.endswith(_DOC_EXTS) ("Skip doc/prose files"), and pickle_deserialization is scoped to _PY_EXTS. The XSS-family substring rules are the remaining ones with no path scoping, so they warn on .md/.txt/.rst/.yaml content where nothing executes.

Repro

  1. Enable the plugin, then Write/Edit a markdown file containing the literal text el.innerHTML = r.svg (e.g. a post-mortem note).
  2. PostToolUse fires: "⚠️ Security Warning: Setting innerHTML with untrusted content can lead to XSS..."

Expected: no warning for doc/prose files, consistent with eval_injection.

Proposed fix (4 lines)

Add the same carve-out the file already uses:

# in each of: new_function_injection, react_dangerously_set_html,
#             document_write_xss, innerHTML_xss
"path_filter": lambda p: not p.endswith(_DOC_EXTS),

Happy to send this as a PR if code contributions to the plugin are accepted here.

Why it matters

Advisory noise on prose trains users (and agents) to either ignore the warnings or over-react to them — we hit a case where a reflexive "fix" in response to a false positive introduced a real rendering regression. Related in spirit: #82484 (allowlist/exemption mechanism).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    reproducedBug reproduced by maintainers on a released buildstaleIssue is inactive

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions