Skip to content
Misconfiguration Disclosed report Intermediate

Stacked --proto modifiers leave denied protocol enabled

The curl command-line parser only reads the first modifier character in a stacked --proto option, so a value like '+-ftp' is treated as allowing all protocols and the intended denial of FTP is ignored. A wrapper script that relies on this documented syntax can be bypassed by an attacker who controls the URL or a redirect target, reaching protocols the wrapper meant to block.

giant_anteater Follow

Originally disclosed on HackerOne

  • Disclosed after 2 days

Summary

proto2num() (line 431–447) consumes only one leading modifier character via a switch statement. The documentation says entries may be "prefixed by zero or more modifiers." Before commit 86ac471d, a loop consumed all modifiers. The replacement switch reads only the first character.

--proto '+-ftp' reads + (action=allow), then passes -ftp to proto_token() (line 466). -ftp is not a recognized protocol name → warning emitted, FTP stays in the default set. --silent suppresses the warning entirely.

The same parser handles --proto-redir, so redirect protocol restrictions are equally bypassable.

Reproduction

Shell
python3 poc_proto_bypass.py <sha>
Shell
# Denied correctly:
curl --proto '-file' file:///etc/hostname    # exit 1 (protocol denied)

# Bypass:
curl --proto '+-file' file:///etc/hostname   # exit 0 — reads the file!
curl --silent --proto '+-file' file:///etc/hostname  # no warning shown

Root cause

C
// src/tool_paramhlp.c:431-447
switch(*str++) {        // ← consumes ONE character only
case '=': action = set;   break;
case '-': action = deny;  break;
case '+': action = allow; break;
default:  str--; plen++;  break;
}
// str now points to "-ftp", which proto_token() doesn't recognize

Impact

A trusted wrapper or script that uses the documented stacked-modifier syntax (e.g. --proto '+-ftp' intending to deny FTP after first allowing all) silently leaves the denied protocol enabled. An untrusted party who controls the URL or a redirect target can then reach a protocol the wrapper explicitly tried to block. --proto-redir is equally affected, so a server-controlled 3xx redirect can escalate to file://, gopher://, or ftp:// reads despite the wrapper's restrictions. --silent suppresses the only visible indicator (the "unrecognized protocol" warning). Direct libcurl API callers are not affected — the bug is in the CLI argument parser only.

The original report as published on HackerOne, by giant_anteater. 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

The parser uses a switch that consumes only one leading modifier character instead of looping over all of them, so the remaining text is misread as a protocol name.

Impact

A wrapper or script that uses the documented stacked syntax can be tricked into allowing a protocol it tried to deny, and the same flaw in --proto-redir means a server-controlled redirect could reach file, gopher or ftp reads; --silent hides the only warning.

What the attacker needed

A wrapper or script using stacked --proto syntax; attacker controls the URL or redirect target

The fix

The parser should loop over all leading modifier characters, as it did before the change, rather than consuming only the first one.

How it was found

  1. Run curl with a single denied protocol and observe it is refused.
  2. Run curl with a stacked modifier that starts with allow and then denies the same protocol.
  3. Observe that the file is read and the command exits successfully.
  4. Add the silent flag and observe that the warning about the unrecognised protocol is hidden.

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.

curl is a tool for fetching URLs, and its --proto option lets you say which URL schemes (like http or ftp) are allowed. The documentation says you can stack modifiers, for example a plus then a minus, but the code only looks at the first one. So a rule meant to block a scheme silently does nothing, and a crafted URL can still use it.

What is Misconfiguration?

Settings left unsafe: exposed panels, open storage buckets, debug modes, default credentials.

More by giant_anteater

View all

93 more disclosed reports, best first.

More from curl

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Security misconfiguration

The lesson behind this report.

Settings left unsafe: exposed panels, open storage buckets, debug modes, default credentials.