You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Downgrade FRAGMENT-IN-TARGET from MUST to SHOULD (warn_on_2xx)
Fragment (#) is absent from origin-form grammar but RFC 9112 §3 only
says SHOULD reject invalid request-lines. Servers that strip the
fragment and return 2xx are not violating a mandatory requirement.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
A request with a fragment identifier in the URI: `GET /path#fragment HTTP/1.1`.
17
+
A request with a fragment identifier in the URI: `GET /path#frag HTTP/1.1`.
18
18
19
19
```http
20
20
GET /path#frag HTTP/1.1\r\n
21
21
Host: localhost:8080\r\n
22
22
\r\n
23
23
```
24
24
25
-
26
25
## What the RFC says
27
26
28
-
The origin-form of request-target is `absolute-path [ "?" query ]`. There is no fragment component. A fragment identifier (`#...`) does not appear in any valid request-target form.
27
+
The origin-form of request-target is defined as:
28
+
29
+
```
30
+
origin-form = absolute-path [ "?" query ]
31
+
```
32
+
33
+
There is no fragment component in this grammar. The `#` character and anything after it are not part of any valid request-target form (origin-form, absolute-form, authority-form, or asterisk-form).
34
+
35
+
Since the request-line doesn't match any valid form, it is an invalid request-line:
29
36
30
-
> "Recipients of an invalid request-line **SHOULD** respond with either a 400 (Bad Request) error..." — RFC 9112 Section 3
37
+
> "Recipients of an invalid request-line **SHOULD** respond with either a 400 (Bad Request) error or a 301 (Moved Permanently) redirect..." — RFC 9112 Section 3
38
+
39
+
This is a **SHOULD**, not a MUST — servers that strip the fragment and process the path are not violating a mandatory requirement.
31
40
32
41
## Why it matters
33
42
34
-
Fragments are a client-side concept (they reference a position within a document). They should never appear on the wire. A server that silently strips fragments may process a different resource than what the client intended.
43
+
Fragments are a client-side concept used to reference a position within a document. They should never appear on the wire. A server that silently strips fragments may process a different resource than what the client intended, though the practical security risk is low.
44
+
45
+
**Pass:** Server rejects with `400` (strict parsing).
46
+
**Warn:** Server returns `2xx` (likely strips the fragment and processes `/path`).
0 commit comments