Skip to content

Use safe XML parser for rich text in PdfUA2AnnotationChecker#318

Open
netliomax25-code wants to merge 1 commit into
itext:developfrom
netliomax25-code:pdfua-richtext-safe-xml
Open

Use safe XML parser for rich text in PdfUA2AnnotationChecker#318
netliomax25-code wants to merge 1 commit into
itext:developfrom
netliomax25-code:pdfua-richtext-safe-xml

Conversation

@netliomax25-code

Copy link
Copy Markdown
  1. getRichTextStringValue parses the RC (rich text) entry of an annotation, which comes straight from the PDF being validated for PDF/UA-2 conformance.
  2. it used XmlUtil.initXmlDocument, a bare DocumentBuilderFactory.newInstance() with DOCTYPE and external entities left enabled, so a crafted RC stream can pull in an external entity (local file read / SSRF).
  3. switched the parse to XmlProcessorCreator.createSafeDocumentBuilder, the same hardened factory used elsewhere in the library, which rejects DOCTYPE and external entities.

Validation: added a unit test feeding an RC value with a DOCTYPE/external entity; it fails on the old parser and passes once the safe builder rejects the declaration.

@iText-CI

iText-CI commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@vitali-pr

Copy link
Copy Markdown
Contributor

hi @netliomax25-code ,
Thank you for your contribution!

Would you mind signing the Contributor License Agreement?
The details are available at https://itextpdf.com/en/how-buy/legal/itext-contributor-license-agreement
We need it in order to be able to merge your PR.

@netliomax25-code

Copy link
Copy Markdown
Author

Sure, no problem. I'll get the CLA signed on my end so this can move forward.

@netliomax25-code

Copy link
Copy Markdown
Author

hi @netliomax25-code , Thank you for your contribution!

Would you mind signing the Contributor License Agreement? The details are available at https://itextpdf.com/en/how-buy/legal/itext-contributor-license-agreement We need it in order to be able to merge your PR.

Done

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.

3 participants