Improper Encoding or Escaping of Output vulnerability in ninenines cowlib allows Link header directive smuggling via unescaped special characters in cow_link:link/1.
cow_link:do_link/1 in cowlib interpolates the target URI, rel value, and attribute keys directly into the serialized Link: header value without escaping or token-grammar validation. A > byte in target prematurely closes the URI slot, allowing an attacker to append additional link entries with attacker-chosen rel directives. A " or \ in rel escapes the quoted string and opens new parameters. Any byte — including whitespace, =, and " — in an attribute key is emitted verbatim. Because browsers act on Link: directives such as rel="preconnect", rel="preload", and rel="prerender", an attacker who can influence these fields in an application that round-trips parsed Link headers through cow_link:link/1 can force victim browsers to make out-of-band connections to attacker-controlled origins.
This issue affects cowlib: from 2.9.0 onward.
Sanitize values before passing them to cow_link:link/1: reject or strip any target value containing >, any rel value containing " or \, and any attribute key containing characters outside the HTTP token grammar. Alternatively, ensure all Link entry fields are derived exclusively from trusted, application-controlled values rather than untrusted input.
The application must pass values that originate from, or can be influenced by, untrusted input into cow_link:link/1 — specifically the target URI, rel value, or attribute keys. Applications that construct Link entries exclusively from trusted, application-controlled values are not affected.
{
"capec_ids": [
"CAPEC-137"
],
"cwe_ids": [
"CWE-116"
],
"cpe_ids": [
"cpe:2.3:a:ninenines:cowlib:*:*:*:*:*:*:*:*"
]
}