Aug 24, 2026·6 min read·30 visits
Unvalidated ALPN parsing in netfoil permits terminal log injection and memory exhaustion.
netfoil, an allowlist-based DNS proxy, failed to sanitize ALPN fields parsed from untrusted DNS-over-HTTPS (DoH) HTTPS Resource Records. This allowed attackers to inject ANSI escape sequences into log files or trigger Denial of Service (DoS) via uncontrolled memory allocations.
netfoil is a client-side, minimal DNS proxy built in Go that relies on DNS-over-HTTPS (DoH) to secure upstream queries and apply allowlists.
During standard resolution operations, the proxy parses incoming DNS resource records, including HTTPS Resource Records (RR) defined by RFC 9460. These records contain Application-Layer Protocol Negotiation (ALPN) parameters used to negotiate client-server protocol capabilities.
Prior to version v0.5.0, netfoil did not validate or sanitize the parsed ALPN parameters. Any raw byte sequence returned in the ALPN field by an upstream server was converted directly into Go strings and subsequently logged or stored.
This lack of validation exposed the proxy to log poisoning via ANSI escape sequence injection and denial of service via memory exhaustion. In addition, the system lacked structured logging for single-byte DNS response codes (RCODE), logging raw numbers directly to standard output.
The vulnerability is situated within the parsing function readALPN in internal/dns/dns_https.go. This function processes raw byte slices containing ALPN identifiers.
RFC 9460 defines the ALPN parameter in HTTPS records as a list of length-prefixed protocol identifiers. The unpatched readALPN implementation sequentially read each identifier via a helper function readPart and converted the raw bytes directly to a Go string.
No checks were performed to verify if the converted strings matched legitimate ALPN values, nor were there limitations on the number of unique or repetitive strings parsed.
An attacker capable of manipulating the upstream DNS response could inject non-printable characters, terminal escape sequences, or millions of duplicate keys. The proxy would attempt to process and store all incoming values, causing excessive memory allocations and terminal-side command execution through output manipulation.
Below is the comparison of the vulnerable implementation versus the patched implementation in internal/dns/dns_https.go.
// VULNERABLE: internal/dns/dns_https.go
func readALPN(data []byte) ([]string, error) {
p := bytes.NewBuffer(data)
parts := make([]string, 0)
for {
if p.Len() == 0 {
break
}
part, err := readPart(p)
if err != nil {
return nil, err
}
parts = append(parts, string(part)) // Direct unvalidated conversion
}
return parts, nil
}The patch introduced strict allowlist matching and a uniqueness check using a map-based set to control memory footprint.
// PATCHED: internal/dns/dns_https.go
func readALPN(data []byte) ([]string, error) {
p := bytes.NewBuffer(data)
alpnSet := make(map[string]struct{})
result := make([]string, 0)
for {
if p.Len() == 0 {
break
}
part, err := readPart(p)
if err != nil {
return nil, err
}
alpn := string(part)
switch alpn {
case "h2":
_, found := alpnSet[alpn]
if !found {
result = append(result, alpn)
alpnSet[alpn] = struct{}{}
}
case "h3":
_, found := alpnSet[alpn]
if !found {
result = append(result, alpn)
alpnSet[alpn] = struct{}{}
}
default:
// Safe fallback: silently drop unapproved values
}
}
return result, nil
}The fix successfully mitigates both log injection and resource consumption. By explicitly restricting valid ALPN tokens to a static switch case ("h2" and "h3"), all arbitrary string conversions are eliminated. The use of alpnSet enforces a maximum slice capacity of two elements, blocking the duplicate exhaustion vector completely.
Exploitation of this vulnerability requires the attacker to control the DNS resolution path of the client using netfoil.
This can be achieved by hijacking an upstream DoH resolver, poisoning the cache of an intermediate resolver, or setting up a malicious authoritative nameserver for a domain queried by the target client.
To perform terminal escape sequence injection, the attacker crafts an HTTPS resource record where the ALPN field contains ANSI escape codes such as \x1b[2J\x1b[H (Clear Screen) or sequences designed to manipulate terminal scrollback and inject arbitrary output lines.
When the proxy resolves the target domain, the raw escape sequences are parsed and written directly to standard output by the logging routine. If the administrator views the logs in an active terminal emulator, the emulator processes the escape sequence, executing the actions locally.
For a Denial of Service attack, the attacker crafts an HTTPS resource record containing a long loop of identical or unique fake ALPN entries. The unpatched proxy continually allocates new memory for the parts slice until the host system encounters an Out of Memory (OOM) condition and kills the process.
The primary impact of this vulnerability is local denial of service and log manipulation.
Because netfoil acts as an allowlist-based DNS proxy, terminating the process disrupts local resolution entirely or bypasses security policies if fallback mechanisms are configured to permit unproxied traffic.
Log poisoning through ANSI injection presents a moderate threat to administrative integrity. It can hide security warnings, falsify system status messages, or spoof user interactions in active terminals.
This vulnerability has been assigned a CVSS score of 6.5 (Medium), reflecting the high requirement of network position or upstream control, coupled with the potential for host-level availability loss and log tampering.
Remediation requires updating the netfoil package to version v0.5.0 or later.
To update the dependency in a Go project, execute the following command:
go get -u github.com/tinfoil-factory/netfoil@v0.5.0If upgrading immediately is not feasible, administrators should enforce the use of trustworthy, verified upstream DoH resolvers (such as Cloudflare or Google DNS) that filter out malformed or suspicious resource records prior to delivery.
Additionally, standard output streams from netfoil can be sanitized through log forwarding utilities to strip control characters before they reach interactive terminal sessions.
For example, administrators can pipe log outputs through a sanitization utility:
./netfoil | tr -cd '\11\12\15\40-\176'CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:L/A:H| Product | Affected Versions | Fixed Version |
|---|---|---|
netfoil tinfoil-factory | < v0.5.0 | v0.5.0 |
| Attribute | Detail |
|---|---|
| CWE ID | CWE-117, CWE-20, CWE-400 |
| Attack Vector | Network (DNS Response Control Required) |
| CVSS v3.1 Score | 6.5 |
| Impact | Denial of Service, Log Manipulation |
| Exploit Status | None |
| KEV Status | Not Listed |
The software does not neutralize or incorrectly neutralizes output written to logs, allowing malicious input to alter log structures or run terminal-side payload sequences.
Hugo versions prior to 0.170.0 contain a path traversal and improper symlink resolution vulnerability in the module resolution and vendoring subsystem. By supplying relative traversal sequences in `_vendor/modules.txt` or crafting symbolic links within vendored directory hierarchies, an untrusted third-party theme or Hugo module can bind its module root to an arbitrary directory on the build host. During site compilation, template functions such as `readFile` can access and render sensitive files from the host filesystem into the generated static output.
A stored Cross-Site Scripting (XSS) vulnerability in the Hugo static site generator (versions 0.140.2 prior to 0.170.0) allows content authors to inject arbitrary HTML and JavaScript into generated pages. The flaw resides in the syntax highlighting component (`markup/highlight/highlight.go`), where the `wrapperClass` option is concatenated directly into an HTML `<div class="...">` attribute without HTML entity escaping. Because shortcodes and code fence attributes bypass Goldmark's raw HTML sanitization rules, untrusted contributors in multi-author workflows can achieve client-side script execution in the browsers of site visitors.
CVE-2026-139994 (GHSA-mjj8-rxh9-q8f5) is a Cross-Site Scripting (XSS) vulnerability in React Router affecting versions 7.11.0 through 7.18.3 and 8.0.0 through 8.3.1. The flaw resides in the server-side streaming handler for the unstable React Server Components (RSC) Data mode and RSC Framework mode. When a server-side redirect is triggered during an HTML stream, the framework injects an inline <meta http-equiv="refresh"> element into the response stream. Because the redirect destination URL is sanitized using an HTML body escaping utility (escapeHtml) rather than an attribute-specific encoding function, double-quote characters (") are left unescaped. An attacker who can influence the redirect URL can break out of the content attribute context, inject arbitrary attributes or HTML elements, and execute arbitrary JavaScript within the victim's browser session.
CVE-2026-139996 is a prototype pollution vulnerability (CWE-1321) in React Router's vendored turbo-stream deserializer, utilized in Framework mode for single-fetch transitions and client-server hydration. When unflattening serialized streams, the decoder assigns object properties using direct bracket notation (object[key] = value) rather than defining own properties via Object.defineProperty. Furthermore, the deserializer lacks integer and bounds validation on stream reference indices. An attacker capable of supplying crafted turbo-stream payloads to the deserializer can pollute Object.prototype or trigger arbitrary index dereferences, compromising application integrity and confidentiality.
CVE-2026-137181 (GHSA-637h-v79h-mvqf) is an incorrect authorization vulnerability (CWE-863) in OpenFGA versions 1.10.3 through 1.22.x. The graph evaluation engine fails to distinguish between normal stream exhaustion and context cancellations or deadline exceedances during concurrent set evaluations. When resolving models using relational set operations (and, or, but not), an aborted worker branch can be evaluated as empty rather than errored, causing the engine to return unauthorized access grants (Allowed: true). When query caching is enabled, these erroneous evaluation states can be persisted to the in-memory cache, poisoning subsequent authorization checks.
An uncaught exception vulnerability (CWE-248) in Engine.IO versions prior to 6.6.12 allows remote unauthenticated attackers to cause a Denial of Service (DoS) against Node.js applications utilizing Engine.IO or Socket.IO. By sending an HTTP upgrade request targeting a non-Engine.IO URL path and forcibly resetting the underlying TCP connection before the internal destruction timeout expires, an attacker triggers an unhandled ECONNRESET error event on the socket object, terminating the entire Node.js runtime process.