[core] Share paths and errors: refuse overlong UTF-8, %u, look-alike dots and slashes and trimmed dot segments; never repeat URL credentials in an error
This commit is contained in:
@@ -352,6 +352,9 @@ fn paths_under_the_prefix_are_within() {
|
||||
("/a/b", "/a/b/c"),
|
||||
("/a", "/a/b;v=1"),
|
||||
("/a", "/a/.well"),
|
||||
("/a", "/a/%C3%A9t%C3%A9.jpg"),
|
||||
("/a", "/a/%e2%9c%93"),
|
||||
("/a", "/a/a%20b"),
|
||||
] {
|
||||
assert!(path_within(prefix, path), "{prefix} should cover {path}");
|
||||
}
|
||||
@@ -395,6 +398,28 @@ fn no_path_trick_escapes_the_prefix() {
|
||||
("/", "/../etc/passwd"),
|
||||
("/", "//evil"),
|
||||
("/", "/%2e%2e/x"),
|
||||
// QC fix round 1: overlong UTF-8, IIS %u, fullwidth dots, Windows-trimmed and
|
||||
// encoded-semicolon dot segments.
|
||||
("/a", "/a/%c0%ae%c0%ae/b"),
|
||||
("/a", "/a/%C0%AE%C0%AE/secret"),
|
||||
("/a", "/a/..%c0%afb"),
|
||||
("/a", "/a/%e0%80%ae%e0%80%ae/b"),
|
||||
("/a", "/a/%f0%80%80%ae/b"),
|
||||
("/a", "/a/%u002e%u002e/b"),
|
||||
("/a", "/a/%u002E%u002E/b"),
|
||||
("/a", "/a/..%u2215b"),
|
||||
("/a", "/a/%ef%bc%8e%ef%bc%8e/b"),
|
||||
("/a", "/a/..%ef%bc%8fb"),
|
||||
("/a", "/a/..%e2%88%95b"),
|
||||
("/a", "/a/..%20/b"),
|
||||
("/a", "/a/.%20/b"),
|
||||
("/a", "/a/..%09/b"),
|
||||
("/a", "/a/..%3b/b"),
|
||||
("/a", "/a/..%3B/b"),
|
||||
("/a", "/a/..%3bx/b"),
|
||||
("/a", "/a/.;x/b"),
|
||||
("/a", "/a;/../b"),
|
||||
("/a", "/a/%2E./b"),
|
||||
];
|
||||
for (prefix, path) in cases {
|
||||
assert!(
|
||||
|
||||
Reference in New Issue
Block a user