What changed, and why it matters
This patch fixes a way that a malformed file could trick Monero's Boost-based archive reader into trying to allocate a huge amount of memory. Before the fix, the reader would trust the length value encoded in the input and resize a string to that size, which could exhaust memory or crash the program. Now it first checks that the claimed length matches the expected archive signature length before allocating.
Treat this as a hardening fix with possible denial-of-service security relevance. Apply the patch and consider fuzzing archive deserialization paths. No immediate remote code execution evidence is present in the diff.
Security signals we found
Potential denial-of-service via memory exhaustion from untrusted length prefix
Input validation added for length before memory allocation
Fix is in a deserialization/archive parsing code path
Evidence from the diff
The change is in external/boost/archive/portable_binary_iarchive.hpp, in the init() method. Previously the code used operator>> to deserialize a std::string directly, which reads a length prefix and resizes the string accordingly. A malicious or malformed input could supply an extremely large length, causing excessive memory allocation. The patch reads the length separately, verifies it equals std::strlen(boost::archive::BOOST_ARCHIVE_SIGNATURE()), and only then resizes the string and loads the binary bytes. If the length does not match, the signature comparison fails and an archive_exception is thrown without allocating the requested amount of memory.
Changed components
external/boost/archive/portable_binary_iarchive.hppBoost portable binary archive deserializationInspect captured patch +9 / −2
### external/boost/archive/portable_binary_iarchive.hpp
@@ -21,6 +21,7 @@
// See http://www.boost.org for updates, documentation, and revision history.
+#include <cstring>
#include <istream>
#include <boost/version.hpp>
#include <boost/serialization/string.hpp>
@@ -307,9 +308,15 @@ portable_binary_iarchive::load_override(
inline void
portable_binary_iarchive::init(unsigned int flags){
if(0 == (flags & boost::archive::no_header)){
- // read signature in an archive version independent manner
+ // read signature in an archive version independent manner,
+ // checking its length before allocating since non-archive input can encode any length
std::string file_signature;
- * this >> file_signature;
+ std::size_t l;
+ load(l);
+ if(l == std::strlen(boost::archive::BOOST_ARCHIVE_SIGNATURE())){
+ file_signature.resize(l);
+ this->primitive_base_t::load_binary(&file_signature[0], l);
+ }
if(file_signature != boost::archive::BOOST_ARCHIVE_SIGNATURE())
boost::serialization::throw_exception(
boost::archive::archive_exception(
Why this scored 60/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.