⚠️

سلب مسئولیت و اخلاق حرفه‌ای

این مطالب صرفاً برای اهداف آموزشی، پژوهشی و افزایش آگاهی امنیتی ارائه شده‌اند. هرگونه استفاده غیرمجاز، غیرقانونی یا سوءاستفاده از اطلاعات، ابزارها و روش‌های مطرح‌شده، کاملاً بر عهده مخاطب است. نویسنده و منتشرکننده هیچ مسئولیتی در قبال خسارات، آسیب‌ها یا پیامدهای ناشی از استفاده نادرست از این مطالب نخواهند داشت.

CVE-2026-140011: Ruby WebSocket Compression Flaw Enables Memory Exhaustion | Alireza Bolbolabadi - Red Team Security
LOADING

CVE-2026-140011: Ruby WebSocket Compression Flaw Enables Memory Exhaustion

Executive summary

CVE-2026-140011 affects the per-message DEFLATE compression path used by Ruby WebSocket servers and libraries. An unauthenticated remote client can submit a highly compressible payload that appears small on the wire but expands substantially during decompression. Because websocket-driver checks its :max_length option only after permessage-deflate has inflated the message, the vulnerable implementation may allocate memory beyond both the transmitted size and the intended message limit.

The flaw can cause memory exhaustion, process termination, and denial of service. The advisory rates the vulnerability HIGH with a CVSS 3.1 base score of 7.5. The supplied intelligence records no known exploitation, no CISA KEV listing, and no public proof-of-concept repository, but the attack is network-reachable and does not require authentication where permessage-deflate is enabled.

The coordinated release includes permessage_deflate 0.2.0, websocket-extensions 0.2.0, and websocket-driver 0.9.0. These components should be upgraded together because the remediation spans the complete decompression and message-length enforcement path.

Detailed analysis

Affected systems

The vulnerability affects the following Ruby components:

  • permessage_deflate earlier than 0.2.0

  • websocket-extensions earlier than 0.2.0

  • websocket-driver from 0.5.0 up to, but not including, 0.9.0

The realistic attack surface is a server-side WebSocket endpoint that negotiates the permessage-deflate extension and accepts messages from untrusted or unauthenticated clients. Deployments that do not negotiate this extension, or that restrict access to trusted peers, are not exposed to the same attack path.

Root cause

The permessage-deflate extension implements the WebSocket per-message DEFLATE compression option. In the vulnerable versions, the websocket-driver :max_length check occurs only after the compressed payload has been fully inflated by permessage-deflate.

That ordering defeats the intended size restriction. The decompressor can first allocate buffers for the expanded output, and only afterward does the driver compare the resulting message length with :max_length. A small frame containing highly repetitive data may therefore produce an allocation dramatically larger than its network representation before the limit is evaluated.

The coordinated fix changes the processing sequence so that :max_length is enforced while zlib output is consumed. It also forwards the option through websocket-extensions and websocket-driver, ensuring that the limit applies during decompression rather than only after the message has already been expanded.

Attack scenario

An attacker needs only network access to a WebSocket endpoint that supports permessage-deflate. No credentials, application-layer handshake, or prior trust relationship is required. Once the extension is negotiated, the attacker can send a compact payload that expands into a much larger message.

The primary consequence is availability loss. A sufficiently large decompression allocation may exhaust the Ruby process memory, cause an allocation failure, or trigger worker termination and restart by the operating system or container runtime. In shared environments, the same event can also create memory pressure for neighboring services.

The weakness is classified as CWE-409: Improper Handling of Highly Compressed Data (Data Amplification). Its practical significance is the difference between the small attacker-controlled input and the much larger allocation required to process it.

Exploitability assessment

The technical conditions for exploitation are straightforward: find a reachable WebSocket endpoint, negotiate permessage-deflate, and transmit a crafted compressible message. Standard compression tooling lowers the barrier to developing a proof of concept.

However, the supplied sources contain no evidence of exploitation in the wild, no CISA KEV listing, and no identified public proof-of-concept implementation for this CVE. The absence of observed weaponization supports a high technical rating but does not justify treating the issue as an active widespread attack campaign.

The risk is highest for internet-facing or otherwise anonymous WebSocket services that enable per-message compression. Internal deployments are less exposed because network access and extension negotiation are additional constraints.

Mitigation

The primary remediation is a coordinated upgrade to:

  • permessage_deflate 0.2.0 or later

  • websocket-extensions 0.2.0 or later

  • websocket-driver 0.9.0 or later

All three components are relevant to the corrected enforcement path. Upgrading only one package may leave the decompression flow without complete protection.

When an immediate upgrade is not possible, organizations can reduce exposure by refusing permessage-deflate during WebSocket negotiation. A reverse proxy or load balancer can also terminate WebSocket traffic, disable compression, and enforce message and frame limits before requests reach the Ruby process. Authentication and an origin allow-list can further narrow who may connect, although these measures do not correct the underlying flaw.

Process and container memory limits provide additional containment against host-wide disruption. They do not replace the package upgrades and should be treated as defense in depth.

Expert insight

This vulnerability illustrates why compressed-data limits must be enforced during expansion rather than after it. A limit checked only against the final decompressed message cannot prevent a decompressor from first allocating the excessive buffer. The relevant control point is inside the streaming decompression path, where the application can stop consumption before memory use exceeds its budget.

The coordinated release also demonstrates that security controls often cross package boundaries. Passing :max_length correctly through permessage-deflate, websocket-extensions, and websocket-driver is as important as enforcing it at the final message-handling layer. Version reviews for WebSocket deployments should therefore consider the complete dependency chain rather than only the package named in the incoming request.

Actionable recommendations

  1. Upgrade permessage_deflate to 0.2.0 or later, websocket-extensions to 0.2.0 or later, and websocket-driver to 0.9.0 or later as one coordinated change.

  1. Confirm that production WebSocket endpoints do not negotiate permessage-deflate unnecessarily, particularly when clients are anonymous or untrusted.

  1. Enforce WebSocket message and frame limits at a reverse proxy or load balancer, and ensure those limits cover decompressed data when compression is enabled.

  1. Monitor Ruby worker resident memory, process restarts, OOM-killer events, and abrupt WebSocket connection drops during bursts of inbound traffic.

  1. Record compressed and decompressed message sizes so that abnormal expansion ratios and unexpectedly large decompressed messages can be identified.

  1. Apply worker or container memory limits to contain accidental or malicious expansion without relying on them as the primary fix.

  1. Review dependency locks and transitive versions to verify that every deployment path uses the corrected releases.

منابع

·
← اخبار