Sceawere
Vulnerability Detail
CVE-2026-80213UPDATED Verified Sceawere Triage Sources: NVD / CISA KEV
Resolv DNS Label Length Spoofing
Vulnerability Metadata
- Severity
- Medium
- Score / CVSS
- 4
- Creation Date
- 1h ago
- Vendor
- Ruby
- Product
- resolv
- Attack Type
- CWE-197 Numeric Truncation Error
- Vector String
- CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:C/C:N/I:L/A:N
- Attack Complexity
- HIGH
Narrative and Response
Description
An issue was discovered in the resolv gem before 0.7.2 for Ruby. Resolv::DNS::MessageEncoder wrote a DNS label's length into a single octet without checking its range. A label longer than 255 octets had its length stored modulo 256 but the label data was written unchanged, and thus the bytes on the wire described a different name than the one the application asked to encode. RFC 1035 section 2.3.4 limits a label to 63 octets, and the two high bits of the length octet are reserved for compression pointers. put_string packed the length with put_pack("C", d.length) and put_label used it for labels, and thus any value from 0 to 255 could end up as a label length octet, including the reserved 0x40-0xBF range and the 0xC0-0xFF pointer range. Resolv::DNS::Name.create did not check per-label or total name length either, and thus an attacker-controlled hostname reached the encoder unchanged. An application that resolves an attacker-controlled hostname sends a query whose wire bytes name a domain the attacker chose. A hostname suffix that the application validates against an allowlist becomes padding that never appears on the wire, and thus allowlist and egress checks can be bypassed. The recursive resolver caches the response under the attacker's name, and DNS logs record that name rather than the one the application asked for. A label length whose low octet lands in the 0xC0-0xFF range produces a length octet that conforming parsers read as the start of a compression pointer, with the following attacker-controlled byte as the offset.
Executive Summary
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Technical Details
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Mitigations
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
References
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Additional Metadata
{
"score": "4.0",
"pubDate": "2026-08-27T17:20:51.037Z",
"pubdate": "2026-08-27T17:20:51.037Z",
"executiveSummary": "The resolv gem for Ruby contains a vulnerability where DNS label lengths are incorrectly handled, allowing for DNS packet manipulation.\nThis flaw arises because Resolv::DNS::MessageEncoder fails to validate that a DNS label length fits within the allowed 63-octet limit defined by RFC 1035.\nBy exceeding this limit, the encoder performs an incorrect modulo 256 operation on the length byte while keeping the full string data intact, leading to wire-level discrepancies between the requested hostname and the actual query sent.\nThis vulnerability affects versions of the resolv gem prior to 0.7.2.\nAn attacker can exploit this to perform DNS cache poisoning, bypass allowlist-based egress filtering, and conduct hostname spoofing.\nThe primary risk is the ability to redirect traffic to unintended domains while bypassing application-level security checks, as the application effectively queries a different hostname than it believes it is requesting.\nExploitation requires the attacker to control the hostname provided to the vulnerable resolver, making applications that process user-supplied hostnames the most at risk.",
"technicalDetails": "The root cause of this vulnerability lies in the improper implementation of DNS message encoding within the Resolv::DNS::MessageEncoder component. Specifically, the encoder writes DNS label lengths into a single octet without performing range validation. According to RFC 1035 section 2.3.4, DNS labels are strictly limited to 63 octets. The resolv gem fails to enforce this constraint, permitting labels significantly longer than the specification allows.\nWhen a label exceeds 255 octets, the encoder writes the length using put_pack('C', d.length), which effectively stores the length modulo 256. However, the associated string data is written in its entirety. This mismatch creates a desynchronization between the length octet and the actual data bytes on the wire. Consequently, the wire-level representation of the DNS query does not match the semantic intent of the application layer.\nThe attack flow begins when an application resolves an attacker-controlled hostname. Because Resolv::DNS::Name.create lacks validation for both per-label and total name length, the malicious input reaches the encoder unaltered. By crafting a specific hostname length, the attacker can force the length octet into the reserved range (0x40-0xBF) or the compression pointer range (0xC0-0xFF). If the resulting length byte falls into the 0xC0-0xFF range, standard DNS parsers interpret the byte as the beginning of a compression pointer, causing the following byte to be read as an offset.\nThis behavior allows an attacker to bypass security mechanisms such as allowlists and egress firewalls. Since the application validates the hostname before the malformed encoding occurs, the validation logic is applied to the 'benign' requested name, while the wire protocol carries the 'malicious' name. This result is cached by recursive resolvers under the attacker-chosen name, and DNS logs reflect the spoofed hostname rather than the original application request.\nPost-exploitation impact includes the ability to deceive downstream security components, influence DNS cache state to point to attacker-controlled infrastructure, and circumvent network access controls that rely on DNS hostname validation."
}