Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Introduce UriCompliance.Violation.FRAGMENT to reject HTTP Request Line that includes fragment section. #11579

Closed
joakime opened this issue Mar 27, 2024 · 4 comments · Fixed by #12504
Assignees
Labels
Bug For general bugs on Jetty side Specification For all industry Specifications (IETF / Servlet / etc)

Comments

@joakime
Copy link
Contributor

joakime commented Mar 27, 2024

Jetty version(s)
12.0.7

Jetty Environment
All

Java version/vendor (use: java -version)
All

OS type/version
All

Description
While working PR #11496 the idea of not allowing FRAGMENT section in a Request Line was introduced.

It is good idea that seems to follow the HTTP spec.

If we do this, we should be careful how we do it, and allow a configurable UriCompliance mode to configure the behavior.

See original commit (reverted in PR #11496):
fed10f7

@joakime joakime added Bug For general bugs on Jetty side Specification For all industry Specifications (IETF / Servlet / etc) labels Mar 27, 2024
joakime added a commit that referenced this issue Mar 27, 2024
@joakime joakime self-assigned this Mar 27, 2024
@joakime joakime moved this to 🏗 In progress in Jetty 12.0.9 - FROZEN Mar 27, 2024
@joakime joakime linked a pull request Mar 27, 2024 that will close this issue
@joakime
Copy link
Contributor Author

joakime commented Mar 27, 2024

Opened PR #11580 to start this issue.
Currently just a cherry-pick of commit fed10f7 along with some testcase updates

@sbordet
Copy link
Contributor

sbordet commented Mar 27, 2024

@joakime can you please reword everywhere you wrote "query" meaning "fragment"?

@joakime joakime changed the title Introduce UriCompliance.Violation.FRAGMENT to reject HTTP Request Line that includes Query section. Introduce UriCompliance.Violation.FRAGMENT to reject HTTP Request Line that includes fragment section. Mar 27, 2024
@joakime
Copy link
Contributor Author

joakime commented Mar 27, 2024

Yeah, sorry, my mind was stuck on the exception message from the old PR ...

if (last != null && state.ordinal() > last.ordinal())
throw new IllegalArgumentException("uri cannot go beyond " + last);

The exception messages from that commit showed up as ...

HTTP/1.1 400 Bad Request
Server: Jetty(12.0.8-SNAPSHOT)
Date: Wed, 27 Mar 2024 08:30:11 GMT
Cache-Control: must-revalidate,no-cache,no-store
Content-Type: text/html;charset=iso-8859-1
Content-Length: 621
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1"/>
<title>Error 400 Bad Request</title>
</head>
<body>
<h2>HTTP ERROR 400 Bad Request</h2>
<table>
<tr><th>URI:</th><td>/badMessage</td></tr>
<tr><th>STATUS:</th><td>400</td></tr>
<tr><th>MESSAGE:</th><td>Bad Request</td></tr>
<tr><th>CAUSED BY:</th><td>org.eclipse.jetty.http.BadMessageException: 400: Bad Request</td></tr>
<tr><th>CAUSED BY:</th><td>java.lang.IllegalArgumentException: uri cannot go beyond QUERY</td></tr>
</table>
<hr/><a href="https://eclipse.org/jetty">Powered by Jetty:// 12.0.8-SNAPSHOT</a><hr/>
</body>
</html>

@gregw
Copy link
Contributor

gregw commented Nov 8, 2024

https://www.rfc-editor.org/rfc/rfc9110.html#section-7.1 says ignore/drop rather than reject?!? So perhaps we do not include this violation by default?

@gregw gregw linked a pull request Nov 8, 2024 that will close this issue
gregw added a commit that referenced this issue Nov 11, 2024
* Fix #11579 Added FRAGMENT UriCompliance Violation

* Fix #11579 Added FRAGMENT UriCompliance Violation
@joakime joakime closed this as completed Jan 15, 2025
@github-project-automation github-project-automation bot moved this from 🏗 In progress to ✅ Done in Jetty 12.1.0 Jan 15, 2025
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Bug For general bugs on Jetty side Specification For all industry Specifications (IETF / Servlet / etc)
Projects
Status: ✅ Done
3 participants