Skip to content

fix(unsafe-xml): report what each XML parser family risks - #248

Merged
SizzleUnrlsd merged 2 commits into
mainfrom
fix/unsafe-xml-risk
Oct 13, 2026
Merged

SizzleUnrlsd merged 2 commits into
mainfrom
fix/unsafe-xml-risk

Conversation

@SizzleUnrlsd

Copy link
Copy Markdown
Contributor

Summary

unsafe-xml now states the actual risk of each parser family:

  • Standard library: Expat reads no local file. It expands declared entities, which can exhaust memory with Expat older than 2.7.2.
  • lxml: resolves external entities by default before 5.0.
  • iterparse and ETCompatXMLParser: before 6.1 (CVE-2026-41066). ETCompatXMLParser is now covered.
  • resolve_entities=True: reported as such, whatever the version.

Other changes:

  • A parser given resolve_entities=False or 'internal' is no longer reported.
  • A document the project wrote itself, a string constant or a module-level string bound once, is reported at low confidence.
  • SymbolCallDetector gains an additive hook, describe(ctx, call, symbol, defs) -> CallReport, with message and confidence. Its default is the rule's message_template and confidence. It is documented in docs/plugins.md.
  • The severity stays medium.
  • Judging lxml by its declared version, and constant arguments of dangerous-eval, are left out, as the issue allows.

Verification

  • tests/test_unsafe_xml_risk.py, new: 16 tests, 15 of which fail on main. No existing test changed.
  • Full suite green, apart from the local test_packaging metadata issue (fails on main too). ruff check and mypy clean.
  • Regression snapshots of luigi, pygoat and yt-fts, the corpus repositories with unsafe-xml findings, are unchanged.

@SizzleUnrlsd SizzleUnrlsd added the bug Something isn't working label Oct 13, 2026
@SizzleUnrlsd SizzleUnrlsd self-assigned this Oct 13, 2026
… paths at full confidence

lxml before 5.0 reads 'internal' as true and resolves external entities; only resolve_entities=False is safe on every version. Low confidence now applies only to functions that parse their argument as the XML itself.
@SizzleUnrlsd
SizzleUnrlsd merged commit 6e5fb05 into main Oct 13, 2026
10 checks passed
@SizzleUnrlsd
SizzleUnrlsd deleted the fix/unsafe-xml-risk branch October 13, 2026 05:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant