-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HostPort needs updates for spec compliance #7269
Comments
RFC3986 has been updated for IPv6 with zone literals in And support for IPv4 within IPv6 is documented in the obsolete |
Per
|
How far do we go? Are these considered valid?
|
+ Updates to HttpURI in regards to handling of no-port to conform to java.net.URI behaviors of no-port as well Signed-off-by: Joakim Erdfelt <[email protected]>
+ Updates to HttpURI in regards to handling of no-port to conform to java.net.URI behaviors of no-port as well Signed-off-by: Joakim Erdfelt <[email protected]>
Opened PR #7279 to conform to specs, and perform Host validation that just ensures it follows reg-name (simply by rejecting host names that violate the generous reg-name scope of characters) |
Signed-off-by: Joakim Erdfelt <[email protected]>
Signed-off-by: Joakim Erdfelt <[email protected]>
Signed-off-by: Joakim Erdfelt <[email protected]>
Signed-off-by: Joakim Erdfelt <[email protected]>
Along with the general cleanup, we should standardize our use of "no port". Since we go into and out of the A value of Here's a demo of the behavior of package uri;
import java.net.URI;
import java.net.URISyntaxException;
public class UriBadPortTest
{
public static void main(String[] args)
{
dumpUri("http://host:0/path");
dumpUri("http://host:-1/path");
dumpUri("http://host:-2/path");
dumpUri("http://host:/path");
dumpUri("http://host: 777 /path");
}
private static void dumpUri(String raw)
{
try
{
URI uri = new URI(raw);
System.out.printf("Raw \"%s\" -> host:\"%s\" port:%d%n", raw, uri.getHost(), uri.getPort());
}
catch (URISyntaxException e)
{
System.out.printf("Invalid URI \"%s\": (%s) %s%n",
raw, e.getClass().getName(), e.getMessage()
);
}
}
} Results in the output ...
|
Some other things that (Presented as tests of valid authorities in the
|
I also think that all of the following should be reported as Invalid Authorities. private static Stream<Arguments> invalidAuthorityProvider()
{
return Stream.of(
// Empty / Null / Blank authority
null,
"", // TODO: if addressing edge case with absolute-uri and empty Host header (Issue #7278)
" ", // TODO: if addressing edge case with absolute-uri and empty Host header (Issue #7278)
// Invalid Ports
"-:-",
"host:xxx",
"127.0.0.1:xxx",
"[0::0::0::0::1]:xxx",
"host:-80",
"127.0.0.1:-80", // negative port
"[0::0::0::0::1]:-80", // negative port
"127.0.0.1:65536", // port too big
"jetty.eclipse.org:88007386429567428956488", // port too big
"jetty.eclipse.org:22,333", // port with commas
// Empty / Null / Blank Hosts
":",
":44",
"::",
// Bad quoting
"'eclipse.org:443'",
"eclipse.org:443\"", // bad end quoting that made it through
"':88'",
// Bad Host Names (invalid IP-Literals)
"[jetty.eclipse.org]:80", // invalid/mimic ipv6 with port
"[sheep:cheese:of:rome]:80", // invalid/mimic ipv6 with port
"[pecorino:romano]", // invalid/mimic ipv6 without port
// Bad Host Names (invalid reg-name) - note: an invalid IPv4address looks like a reg-name
"this:that:or:the:other.com:222", // multiple ':' with port
"and:also:th.is", // multiple ':' without port
// reg-name identified invalid printable characters - / \ : @ ^ [ ] { } < > # | " `
"a/slash.com",
"a\\backslash.edu",
"[email protected]",
"a^caret.net",
"some[arbitrary]brackets.org",
"more{curly}braces.io",
"html<elements>here.au",
"hash#octothor.pe",
"ceci-n'est-pas-une|pipe.fr",
"we-sell-\"quotes\".com",
"back`ticks`bbq.au",
// reg-name invalid control characters
"how\ttabulous.net",
"null\u0000.com",
"bell-\u0007-tolls.edu",
"del-\u007F-mar.au"
)
.map(Arguments::of);
}
@ParameterizedTest
@MethodSource("invalidAuthorityProvider")
public void testInvalidAuthority(String authority)
{
assertThrows(IllegalArgumentException.class, () ->
{
new HostPort(authority);
});
} |
This issue has been automatically marked as stale because it has been a |
This issue has been automatically marked as stale because it has been a |
@joakime Ofthe examples listed above, almost all of them result in an IAE from HostPort (both the ones you say are valid and invalid). I'm not sure if there is anything really to do here? Can you review this please, else we can close this |
Jetty version(s)
9.4+
Java version/vendor
(use: java -version)
All
OS type/version
Alll
Description
Currently
HostPort
allows odd authorities that make no sense.I think
HostPort
should validate thehost
portion a bit more, to reject these nonsense hosts with a 400 Bad Request.The spec for HTTP at https://datatracker.ietf.org/doc/html/rfc7230#section-5.4
Says the
uri-host
for http is detailed in https://datatracker.ietf.org/doc/html/rfc7230#section-2.7.1Which points to
host
in https://datatracker.ietf.org/doc/html/rfc3986#section-3.2.2which has the following ABNF ...
Optionally, this validation could exist as a
RejectInvalidAuthorityCustomizer
(like proposed in PR #7251).The text was updated successfully, but these errors were encountered: