[
https://issues.apache.org/jira/browse/PDFBOX-6314?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Tilman Hausherr updated PDFBOX-6314:
------------------------------------
Affects Version/s: 2.0.37
> SaslPrep rejects valid supplementary characters (e.g. U+20000) in AES-256
> passwords
> -----------------------------------------------------------------------------------
>
> Key: PDFBOX-6314
> URL: https://issues.apache.org/jira/browse/PDFBOX-6314
> Project: PDFBox
> Issue Type: Bug
> Components: PDModel
> Affects Versions: 2.0.37, 3.0.8 PDFBox, 4.0.0
> Reporter: Martin Mirchev
> Priority: Major
>
> {{SaslPrep.prohibited(int codepoint)}} casts the code point to {{char}}
> before two of its checks:
> {code:java}
> return nonAsciiSpace((char)codepoint)
> || asciiControl((char)codepoint)
> || ...
> {code}
> For a code point above U+FFFF the cast keeps only the low 16 bits, so U+20000
> (CJK Unified Ideographs Extension B) becomes U+0000 and is rejected as an
> ASCII control character. Any supplementary character whose low 16 bits fall
> in 0x00-0x1F, 0x7F or one of the non-ASCII space code points is rejected the
> same way, although none of them is prohibited by RFC 4013.
> Through the public API (trunk bd0c9c0):
> {code:java}
> try (PDDocument doc = new PDDocument()) {
> doc.addPage(new PDPage());
> StandardProtectionPolicy pol = new
> StandardProtectionPolicy("own\uD840\uDC00er", "", new AccessPermission());
> pol.setEncryptionKeyLength(256);
> doc.protect(pol);
> doc.save(out);
> }
> // java.lang.IllegalArgumentException: Prohibited character 'CJK UNIFIED
> IDEOGRAPHS EXTENSION B 20000' at position 3
> {code}
> {{pass\u00e9}} is accepted, and a real control character such as U+0001 is
> still rejected. The same code is on the 3.0 and 2.0 branches.
> A possible fix is to apply the two {{char}} checks only to BMP code points:
> {code:java}
> return (codepoint <= Character.MAX_VALUE
> && (nonAsciiSpace((char) codepoint) || asciiControl((char)
> codepoint)))
> || nonAsciiControl(codepoint)
> || ...
> {code}
> This issue was found by an LLM-assisted tool and verified manually.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]