Skip to content

Fix an out-of-bounds read in the XML archive signature check - #394

Open
gennaroprota wants to merge 1 commit into
developfrom
fix-an-out-of-bounds-read-in-the-xml-archive-signature-check
Open

gennaroprota wants to merge 1 commit into
developfrom
fix-an-out-of-bounds-read-in-the-xml-archive-signature-check

Conversation

@gennaroprota

Copy link
Copy Markdown
Collaborator

basic_xml_grammar<>::init() compared the signature in the header of an XML archive with BOOST_ARCHIVE_SIGNATURE() using the three-iterator std::equal(), which reads as many characters of the expected signature as the archive provides. So a longer signature made it read past the end of the expected one, and any prefix of it, such as "serialization", was accepted. We now compare the lengths first, as "fix address sanitizer exception when loading corrupted XML archive. GitHub issue #257" did for the tag names in load_end().

Note that the test can only catch the accepted prefix: the read past the end goes unnoticed without a sanitizer, and CI runs none.

Closes #392.

@gennaroprota
gennaroprota force-pushed the fix-an-out-of-bounds-read-in-the-xml-archive-signature-check branch 3 times, most recently from 5b8930f to 89731f7 Compare November 25, 2026 15:04
`basic_xml_grammar<>::init()` compared the signature in the header of an
XML archive with `BOOST_ARCHIVE_SIGNATURE()` using the three-iterator
`std::equal()`, which reads as many characters of the expected signature
as the archive provides. So a longer signature made it read past the end
of the expected one, and any prefix of it, such as "serialization", was
accepted. We now compare the lengths first, as "fix address sanitizer
exception when loading corrupted XML archive. GitHub issue #257" did for
the tag names in `load_end()`.

Note that the test can only catch the accepted prefix: the read past the
end goes unnoticed without a sanitizer, and CI runs none.

Fixes #392.
@gennaroprota
gennaroprota force-pushed the fix-an-out-of-bounds-read-in-the-xml-archive-signature-check branch from 89731f7 to ee1e45d Compare November 25, 2026 15:06
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.

Out-of-bounds read in XML archive signature check (basic_xml_grammar::init) — missed twin of #257

1 participant