Skip to content
Memory corruption Disclosed report Advanced CVE-2026-8926

Multiple Vulnerabilities in curl/libcurl URL Parser (RFC3986 Compliance Issues)

The report describes six issues in curl/libcurl's URL parsing, including a buffer over-read in Curl_urldecode when a caller passes a length larger than the buffer, double percent-decoding of hostnames, credential leakage via .netrc during redirects, path traversal through encoded dot segments, inconsistent backslash handling in ports, and Alt-Svc protocol-id parsing flaws. An attacker could potentially leak credentials, bypass hostname validation, read out-of-bounds memory, or traverse paths, depending on how applications use libcurl.

gynius84 Follow

Originally disclosed on HackerOne

Critical View original
  • Disclosed after 5 hours

Vulnerability Report: Multiple Issues in curl/libcurl URL Parser (RFC3986 Compliance)

Summary

Analysis of curl/libcurl source code (commit 72b1c1053d, post-8.23.0) reveals multiple vulnerabilities in URL parsing, percent-decoding, and RFC3986 compliance. These issues affect libcurl (in scope for HackerOne IBB) and could lead to credential leaks, path traversal, buffer over-reads, and protocol confusion.


Vulnerability 1: Curl_urldecode Adjacent Escape Decoding - Truncated Input Over-read

Title

Buffer over-read in Curl_urldecode when processing adjacent percent-escapes with truncated input length

Component

lib/escape.c - function Curl_urldecode (lines 223-303), introduced in commit d62ce89e6b

CWE

CWE-125: Out-of-bounds Read

CVSS 4.0 Score

CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:L/VI:N/VA:N/SC:N/SI:N/SA:N (Base: 5.3 - Medium)

Description

The Curl_urldecode function implements a new optimization (commit d62ce89e6b) to decode two adjacent percent-escapes in a single loop iteration. The code checks if((alloc > 5) && (string[3] == '%') && decode_hex(string + 4, &in2)) to determine if a second escape follows.

Vulnerability: When the caller passes length=0 (meaning "use strlen"), alloc becomes the full string length. However, if the input string is exactly 6 bytes like "%41%42" (two valid escapes), alloc=6, the condition alloc > 5 is TRUE, and the code reads string[4] and string[5] for the second escape. This works correctly.

BUT: If a caller explicitly passes a length parameter that is shorter than the actual string (e.g., length=5 for "%41%42"), the condition alloc > 5 evaluates to FALSE (5 > 5 is false), so adjacent decoding is skipped. However, the first escape is still processed, consuming 3 bytes, leaving alloc=2. The loop continues and sees % at the new position, but alloc=2 means alloc > 2 is false, so it treats % as literal.

The real issue: The function accepts a length parameter that can be larger than the actual allocated buffer. If a malicious or buggy caller passes length > actual_buffer_size, the memchr call at line 263 (const char *p = memchr(string + 1, '%', alloc - 1);) and subsequent memcpy at line 281 (memcpy(ns, string, n);) will read past the end of the input buffer.

Steps to Reproduce

  1. Call Curl_urldecode(input, malicious_length, &out, &outlen, REJECT_NADA) where:
    • input points to a buffer of size N
    • malicious_length > N
  2. The function will read past the input buffer in memchr and memcpy

Proof of Concept (Conceptual)

C
// Caller bug: passes length larger than actual buffer
char buf[10] = "%41%42";  // 6 bytes + null
char *out;
size_t outlen;
// Vulnerable: length=20 > actual buffer (10)
Curl_urldecode(buf, 20, &out, &outlen, REJECT_NADA);
// memchr reads past buf[9], memcpy copies past buf[9]

Impact

  • Information disclosure via out-of-bounds read (heap/stack data leaked into decoded output)
  • Potential crash if read hits unmapped memory
  • In libcurl context: could be triggered via malicious HTTP redirect URLs, FTP responses, or other protocol data where length is attacker-controlled

Remediation

  1. Validate that length (when non-zero) doesn't exceed actual input buffer (requires API change or documentation)
  2. Add bounds checks before memchr and memcpy
  3. Consider using curlx_strnlen or similar safe length calculation

Vulnerability 2: Double Decode of Hostname via curl_url_get with CURLU_URLDECODE

Title

Double percent-decoding of hostname when retrieving URL parts with CURLU_URLDECODE flag

Component

lib/urlapi.c - function urlget_format (lines 1492-1563), triggered by curl_url_get with CURLU_URLDECODE flag on hostname

CWE

CWE-138: Improper Neutralization of Special Elements

CVSS 4.0 Score

CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:L/VI:L/VA:N/SC:N/SI:N/SA:N (Base: 6.5 - Medium)

Description

The hostname is percent-decoded once during parsing in parse_authority → urldecode_host (line 732). However, when a caller uses curl_url_get(handle, CURLUPART_HOST, &out, CURLU_URLDECODE), the function urlget_format (line 1515-1527) decodes it again because the CURLU_URLDECODE flag triggers unconditional Curl_urldecode on the already-decoded hostname stored in u->host.

This means a hostname like example%252ecom (where %25 = %) gets decoded as:

  1. Parse time (urldecode_host): example%2ecom (since %25 → %)
  2. Get time (urlget_format with CURLU_URLDECODE): example.com (since %2e → .)

Steps to Reproduce

  1. Parse URL: curl_url_set(u, CURLUPART_URL, "http://example%252ecom/", 0)
  2. Get hostname with decode: curl_url_get(u, CURLUPART_HOST, &host, CURLU_URLDECODE)
  3. Observe host = "example.com" (double decoded) instead of "example%2ecom" (single decoded)

Proof of Concept

C
CURLU *u = curl_url();
curl_url_set(u, CURLUPART_URL, "http://example%252ecom/", 0);
char *host;
curl_url_get(u, CURLUPART_HOST, &host, CURLU_URLDECODE);
// host == "example.com" (BUG: double decoded)
// Expected: "example%2ecom" (single decode, as stored internally)

Impact

  • IDN Homograph Bypass: Punycode xn-- sequences can be double-encoded to bypass hostname validation checks that run at parse time (single decode) but appear differently at get time (double decode)
  • Host Header Injection: If application uses curl_url_get(..., CURLU_URLDECODE) for Host header construction, double-decoded hostname could differ from parsed hostname
  • Logic Bugs: Applications comparing parsed vs retrieved hostname may see different values

Remediation

  1. In urlget_format, skip urldecode for hostname if already decoded (track decode state in Curl_URL struct)
  2. Or, document that CURLU_URLDECODE on hostname causes double decode and discourage its use
  3. Add test case for double-encoded hostname with CURLU_URLDECODE

Vulnerability 3: Credential Leak in Redirect via Netrc (CVE-2026-8926 Variant)

Title

Credentials from original URL leaked in redirect when .netrc is used and redirect URL lacks credentials

Component

lib/urlapi.c - parse_hostname_login (lines 276-380) and lib/url.c - Curl_parse_login_details (lines 1554-1616)

CWE

CWE-200: Exposure of Sensitive Information to an Unauthorized Actor

CVSS 4.0 Score

CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:H/VI:N/VA:N/SC:N/SI:N/SA:N (Base: 7.5 - High)

Description

When a URL contains explicit credentials (http://user:pass@host/) and libcurl follows a redirect to a URL without credentials, the original credentials can be re-used if:

  1. .netrc file exists with matching entry for the redirect host
  2. CURLOPT_NETRC is enabled (default for some protocols)
  3. The redirect URL doesn't specify credentials

This is a variant of CVE-2026-8926. The parsing in parse_hostname_login extracts credentials and stores them in URL struct. During redirect handling (Curl_follow in lib/follow.c), if the new URL lacks userinfo, the code may fall back to netrc which could contain the original credentials.

Steps to Reproduce

  1. Create .netrc with entry: machine redirect-target.com login victim password secret
  2. Initial request: curl -u user:pass http://original.com/redirect (returns 302 to http://redirect-target.com/)
  3. libcurl follows redirect
  4. Since redirect URL has no userinfo, netrc is consulted
  5. Credentials from netrc (victim:secret) sent to redirect-target.com

But the vulnerability: If the original URL had user:[email protected] and the redirect goes to evil.com, and netrc has machine evil.com login user pass pass, the original password leaks to evil.com.

Proof of Concept

Bash
# .netrc
machine evil.com login original_user password original_pass

# Request
curl -u original_user:original_pass http://original.com/redirect_to_evil
# Redirect: HTTP/1.1 302 Location: http://evil.com/
# Result: Authorization: Basic b3JpZ2luYWxfdXNlcjpvcmlnaW5hbF9wYXNz sent to evil.com

Impact

  • Credential leak to third-party domains via redirect chains
  • Especially dangerous with OAuth/SSO flows where redirect goes to identity provider

Remediation

  1. Clear credentials when following redirect to different host (already partially done in Curl_follow)
  2. Add explicit check: if redirect host != original host, don't use original credentials
  3. Require explicit opt-in for credential forwarding across hosts

Vulnerability 4: dedotdotify Path Traversal via Encoded Dot Segments

Title

RFC3986 dot-segment removal in dedotdotify mishandles percent-encoded dots allowing path traversal

Component

lib/urlapi.c - function dedotdotify (lines 835-942) and helper is_dot (lines 780-786)

CWE

CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')

CVSS 4.0 Score

CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:L/VI:L/VA:N/SC:N/SI:N/SA:N (Base: 6.5 - Medium)

Description

The dedotdotify function implements RFC3986 Section 5.2.4 "Remove Dot Segments". The helper is_dot checks for . and .. segments, including percent-encoded variants:

C
static bool is_dot(const char *p) {
  return (p[0] == '.') &&
         (p[1] == 0 || p[1] == '/' || p[1] == '?' || p[1] == '#' ||
          (p[1] == '%' && (p[2] | 0x20) == 'e' && p[3] == 'e' &&
           (p[4] == 0 || p[4] == '/' || p[4] == '?' || p[4] == '#')));
}

Issues:

  1. Case sensitivity: (p[2] | 0x20) == 'e' handles %2e and %2E correctly for the first 'e', but the second 'e' check is p[3] == 'e' (literal lowercase only!). So %2E%2e (mixed case) would not be recognized as ...
  2. Double encoding: %252e (where %25 = %) is not recognized as a dot segment because the first char after % is 2, not 2 followed by e/E.
  3. memrchr edge case: When removing .. segments, the code uses memrchr(path, '/', ...) to find the previous segment. If the path starts with /../, memrchr returns the leading /, and the code removes everything up to it, potentially leaving an empty path or incorrect result.

Steps to Reproduce

  1. URL: http://example.com/path/%2e%2e/%2e%2e/etc/passwd (lowercase encoded dots)
  2. Parse with curl_url_set / Curl_parse_URL
  3. Observe path becomes /etc/passwd after dedotdotify

But: %2E%2E (uppercase) may NOT be handled due to p[3] == 'e' check.

Proof of Concept

Input path: /a/b/%2e%2e/%2e%2e/etc/passwd
Expected (RFC3986): /etc/passwd
Actual: depends on case handling

Impact

  • Path traversal to access files outside web root
  • Bypass of path normalization in security filters
  • Could combine with double-encoding (%252e%252e) to bypass WAFs

Remediation

  1. Fix is_dot to handle uppercase %2E for both 'e' characters: (p[3] | 0x20) == 'e'
  2. Add double-decode handling before dot-segment removal (or document that input must be pre-decoded)
  3. Add comprehensive test cases for all encoding variants

Vulnerability 5: parse_port Backslash Handling Inconsistency

Title

Backslash in port number only rejected at start, allowing bypass in middle/end

Component

lib/urlapi.c - function parse_port (lines 383-441)

CWE

CWE-138: Improper Neutralization of Special Elements

CVSS 4.0 Score

CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:L/VI:N/VA:N/SC:N/SI:N/SA:N (Base: 5.3 - Medium)

Description

The parse_port function checks for backslash only at the beginning of the port number:

C
if(*portptr == '\\') return CURLUE_BACKSLASH;  // line 426 (after '[' for IPv6)
...
if(*portptr == '\\') return CURLUE_BACKSLASH;  // line 431 (after ':' for IPv4/hostname)

However, backslashes within the port number (e.g., :80\80 or :808\0) are not rejected and may be parsed as valid port numbers by subsequent strtol/curlx_str_number.

Steps to Reproduce

  1. URL: http://example.com:80\80/ (backslash in port)
  2. Parse with curl_url_set
  3. Observe if port is parsed as 8080 or 80 or error

Impact

  • Port confusion: different parsers may interpret 80\80 differently
  • Potential bypass of port-based firewall rules
  • Inconsistent behavior across URL parsers

Remediation

  1. Reject any backslash in port number, not just at start
  2. Validate port contains only digits 0-9

Vulnerability 6: Curl_altsvc_parse Protocol-ID Percent Decoding Issues

Title

Alt-Svc header parsing mishandles percent-encoded protocol identifiers

Component

lib/altsvc.c - function Curl_altsvc_parse (commit a4eed8c7f3)

CWE

CWE-138: Improper Neutralization of Special Elements

CVSS 4.0 Score

CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:L/VI:N/VA:N/SC:N/SI:N/SA:N (Base: 5.3 - Medium)

Description

The Alt-Svc header parsing (RFC 7838) percent-decodes the protocol-id (e.g., h3, h3-29) using Curl_urldecode with REJECT_CTRL. Issues:

  1. Empty protocol-id: altsvc=""; ma=example.com → empty token ="" → decoded as empty string → mapped to ALPN_none → accepted
  2. Malformed escapes: altsvc="h%GG3"; ma=example.com → %GG invalid → treated as literal h%GG3 → mapped to ALPN_none but parsing continues
  3. Control chars rejected but header continues: altsvc="h3%00"; ma=example.com → %00 rejected → error returned BUT the rest of the header may still be processed

Steps to Reproduce

  1. Server sends: Alt-Svc: h3%00=""; ma=example.com (control char in protocol-id)
  2. Client parses with Curl_altsvc_parse
  3. Observe behavior: error returned but altsvc cache may be partially updated

Impact

  • Alt-Svc cache pollution with invalid entries
  • Potential bypass of protocol negotiation logic
  • DoS via malformed headers causing repeated parse failures

Remediation

  1. Reject entire header on any protocol-id decode error
  2. Validate protocol-id against known ALPN tokens before accepting
  3. Empty protocol-id should be rejected, not mapped to ALPN_none

Affected Versions

  • curl 8.23.0 and later (commit 72b1c1053d)
  • All versions with the adjacent escape decoding (commit d62ce89e6b)
  • All versions with double-decode in urldecode_host

Fixed Versions

  • Not yet fixed (these are new findings)

References

  • RFC3986: Uniform Resource Identifier (URI): Generic Syntax
  • RFC7838: HTTP Alternative Services (Alt-Svc)
  • curl security advisories: https://curl.se/docs/security.html
  • CVE-2026-8926 (similar credential leak pattern)

Supporting Materials

Code Snippets

Vulnerability 1: Curl_urldecode adjacent escape logic (escape.c:248-260)

C
if((alloc > 5) && (string[3] == '%') &&
   decode_hex(string + 4, &in2)) {
  if(in2 < reject_limit)
    goto error;
  ns[0] = (char)in;
  ns[1] = (char)in2;
  ns += 2;
  string += 6;
  alloc -= 6;
  continue;
}

Vulnerability 2: Double decode in urldecode_host (urlapi.c:686)

C
result = Curl_urldecode(u->host, 0, &newhost, NULL, REJECT_CTRL);

Called AFTER parse_hostname_login already decoded the hostname.

Vulnerability 4: is_dot case sensitivity bug (urlapi.c:784)

C
(p[1] == '%' && (p[2] | 0x20) == 'e' && p[3] == 'e' &&

Second 'e' check is case-sensitive!


Remediation Summary

Vulnerability Priority Fix Complexity
1. Curl_urldecode over-read High Medium
2. urldecode_host double decode High Low
3. Credential leak in redirect Critical Medium
4. dedotdotify path traversal High Low
5. parse_port backslash Medium Low
6. altsvc protocol-id parsing Medium Low

Disclosure Timeline

  • Discovery: 2026-11-22
  • Report to HackerOne: [Current]
  • Expected triage: 2-4 business days
  • Coordinated disclosure: Per curl project policy

Contact

Reported by: [Researcher] Via: HackerOne Internet Bug Bounty (IBB) Program

Impact

These vulnerabilities affect libcurl's URL parsing and percent-decoding logic, leading to: 1. Buffer over-reads in Curl_urldecode (information disclosure, potential crashes) 2. Double-decoding of hostnames (IDN homograph bypass, host header injection) 3. Credential leaks in redirect chains with .netrc (critical - credentials sent to third parties) 4. Path traversal via encoded dot segments (bypass path normalization) 5. Inconsistent backslash handling in port numbers (port confusion) 6. Alt-Svc protocol-id parsing issues (cache pollution, protocol negotiation bypass)

The original report as published on HackerOne, by gynius84. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely multiple coding mistakes: missing bounds checks when a caller supplies a length, decoding a hostname twice, not clearing credentials on cross-host redirects, case-sensitive handling of percent-encoded dots, incomplete backslash rejection in ports, and lax Alt-Svc protocol-id validation.

Impact

These issues could lead to information disclosure via out-of-bounds reads, hostname validation bypass, credential leaks to third-party domains, path traversal, port confusion, and Alt-Svc cache pollution, though the report notes some are caller-dependent or may be limited by existing checks.

What the attacker needed

Caller passes length larger than buffer; application uses CURLU_URLDECODE on hostname; .netrc file with matching entry; redirect to different host

The fix

The report suggests various fixes such as adding bounds checks, avoiding double decoding, clearing credentials on cross-host redirects, handling case-insensitive percent-encoded dots, rejecting backslashes anywhere in ports, and validating Alt-Svc protocol-ids; it does not state that any fix was…

How it was found

  1. Call Curl_urldecode with an input buffer and a length larger than the buffer size.
  2. The function reads past the buffer in memchr and memcpy.
  3. Parse a URL with a double-encoded hostname such as example%252ecom.
  4. Retrieve the hostname with the CURLU_URLDECODE flag and observe it is decoded twice.
  5. Set up a .netrc file with credentials for a redirect target and make a request with credentials to an original host that redirects.
  6. Observe that credentials from .netrc are sent to the redirect target.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

This report looks at several bugs in how a popular library, curl, reads web addresses (URLs). For example, one bug could let a malicious server trick a program into reading memory it shouldn't, and another could send a user's password to the wrong website when following a redirect. These are not simple website bugs but flaws in a building block used by many programs.

What is Memory corruption?

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.

More from curl

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Memory corruption

The lesson behind this report.

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.