Skip to content
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

Url::as_str can produce invalid and non-equivalent URLs #775

Closed
Mrmaxmeier opened this issue Jun 16, 2022 · 1 comment
Closed

Url::as_str can produce invalid and non-equivalent URLs #775

Mrmaxmeier opened this issue Jun 16, 2022 · 1 comment

Comments

@Mrmaxmeier
Copy link

The URL crate includes a fuzzer which tests for equivalence of re-serialized URLs. The fuzzer is included in OSS-Fuzz, but running it locally hits assertions instantly. I'm not sure what's going on there -- an inactive email contact or a buggy fuzzing environment maybe?

Here's an example input:

Invalid serialized URL

[fuzz_targets/parse.rs:11] &utf8 = "b:\t/\t../\t/\t.%2\\"
[fuzz_targets/parse.rs:11] &parsed = Url {
    scheme: "b",
    cannot_be_a_base: false,
    username: "",
    password: None,
    host: None,
    port: None,
    path: "//.%2\\",
    query: None,
    fragment: None,
}
[fuzz_targets/parse.rs:11] &as_str = "b://.%2\\"
thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: InvalidDomainCharacter', fuzz_targets/parse.rs:12:56

Non-equivalent serialized URL

[fuzz_targets/parse.rs:11] &utf8 = "K:/.//./\0\0777777\0:/.//./\0\07777"
[fuzz_targets/parse.rs:11] &parsed = Url {
    scheme: "k",
    cannot_be_a_base: false,
    username: "",
    password: None,
    host: None,
    port: None,
    path: "//%00%00777777%00://%00%007777",
    query: None,
    fragment: None,
}
[fuzz_targets/parse.rs:11] &as_str = "k://%00%00777777%00://%00%007777"
thread '<unnamed>' panicked at 'assertion failed: `(left == right)`
  left: `Url { scheme: "k", cannot_be_a_base: false, username: "", password: None, host: None, port: None, path: "//%00%00777777%00://%00%007777", query: None, fragment: None }`,
 right: `Url { scheme: "k", cannot_be_a_base: false, username: "", password: None, host: Some(Domain("%00%00777777%00")), port: None, path: "//%00%007777", query: None, fragment: None }`', fuzz_targets/parse.rs:12:13

@Mrmaxmeier
Copy link
Author

Whoops, looks like this is already tracked #729

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant