| Summary: | NumberFormatException caused by malformed "Host" request header | ||||||||
|---|---|---|---|---|---|---|---|---|---|
| Product: | [RT] Jetty | Reporter: | Nesa Simon David <hellznrg> | ||||||
| Component: | server | Assignee: | Thomas Becker <tbecker> | ||||||
| Status: | RESOLVED FIXED | QA Contact: | |||||||
| Severity: | minor | ||||||||
| Priority: | P3 | CC: | gregw, jetty-inbox | ||||||
| Version: | unspecified | ||||||||
| Target Milestone: | 7.5.x | ||||||||
| Hardware: | All | ||||||||
| OS: | All | ||||||||
| Whiteboard: | |||||||||
| Attachments: |
|
||||||||
|
Description
Nesa Simon David
It could be fixed by changing:
org.eclipse.jetty.server.Request.java:1001
_port=BufferUtil.toInt(hostPort.peek(i+1, hostPort.putIndex()-i-1));
to:
try {
_port=BufferUtil.toInt(hostPort.peek(i+1, hostPort.putIndex()-i-1));
} catch(NumberFormatException e) {
_port=0;
}
I think the server should actually do a 400 bad request response. It is dangerous to be too accepting of things like host - specially with IPv6 addresses containing : characters. Created attachment 209138 [details]
proposed patch
Created attachment 209139 [details]
2nd commit with the actual patch + unit test
Attached you find patches for two commits. The first is a code format and the second is the actual patch + unit test.
NumberFormatException is now being caught and causes jetty to return a 400 Bad Request with a meaningful message text.
Applied, but I modified the error message sent back to remove the XSS vulnerability. The server should never echo back user data, as this can be used to inject evilness in devious ways. Also, to keep the jetty footprint small, I favour short and simple error messages like "Bad Host header" |