gopher: reject CR and LF in the selector#22116
Conversation
|
Unrelated observation: the GOPHER label wasn't automatically applied Lines 240 to 245 in 372401f https://github.com/curl/curl/actions/runs/27867115900/job/82472952947 |
|
It's the matcher. The |
|
That definitely doesn't belong in this PR. The rule is deliberately built this
way to avoid false positives. Many PRs will touch several protocols when
performing a cleanup of some sort, which would add many useless labels to a
fair number of PRs. What we really want is a rule that excludes directories
like docs/ and tests/ and ensures that all the *other* files match a particular
protocol (like gopher), but I haven't found a way to express that with the
tools available.
|
No probs, I was just wondering on how it works, and if this is expected. |
No, not necessary, we expect tests/docs updates together with src changes. |
|
Right, makes sense. I'll leave the labeler as is then and keep this PR to the gopher fix. |
|
No, not necessary, we expect tests/docs updates together with src changes.
The problem is that if someone DOES include docs along with a gopher change, the presence of a doc file means that, according to the rule, EVERYTHING isn't about gopher so it doesn't get the tag.
|
|
Right, that's the For a separate change, I think you can express the "ignore docs/tests, require the rest to be gopher" shape without enumerating doc paths like GOPHER:
- all:
- changed-files:
- any-glob-to-any-file: 'lib/gopher*'
- all-globs-to-all-files: '{lib/gopher*,docs/**,tests/**}'The |
There was a problem hiding this comment.
Pull request overview
This PR hardens curl’s gopher implementation against request-smuggling by rejecting URL-decoded CR/LF characters in the gopher selector, returning CURLE_URL_MALFORMAT before anything is sent to the server.
Changes:
- Reject decoded
\r/\ningopher_do()after URL-decoding the selector and fail withCURLE_URL_MALFORMAT. - Add a new gopher regression test (
test1609) covering%0d%0ainjection in the selector. - Register the new test in
tests/data/Makefile.am.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
lib/gopher.c |
Adds CR/LF rejection in the decoded selector to prevent gopher request line splitting. |
tests/data/test1609 |
Introduces a regression test for URL-encoded CRLF in the gopher selector expecting CURLE_URL_MALFORMAT. |
tests/data/Makefile.am |
Adds test1609 to the autotools test data list. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
adjust <protocol> to verify better Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
|
Thanks! |
Repro:
gopher://host/1/sel%0d%0aINJECTis sent on the wire assel\r\nINJECT\r\n, so theINJECTline is smuggled as a second request line.Cause:
gopher_do()URL-decodes the selector withREJECT_ZERO, which only blocks a decodedNUL, leavingCR/LFto split the single-line gopher request.Fix: reject a decoded
CRorLFingopher_do()after the decode and fail withCURLE_URL_MALFORMAT. ATABstays allowed as the legitimate type-7 selector/search separator, sotest1202keeps passing.test1609covers the rejection.