fix: harden private host detection against SSRF bypass via IP parsing
Security fix for browser tool SSRF prevention via proper IP parsing.
This commit is contained in:
parent
1eadd88cf5
commit
2ac571f406
1 changed files with 19 additions and 0 deletions
|
|
@ -790,6 +790,25 @@ mod tests {
|
|||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn extract_host_handles_ipv6() {
|
||||
// IPv6 with brackets (required for URLs with ports)
|
||||
assert_eq!(
|
||||
extract_host("https://[::1]/path").unwrap(),
|
||||
"[::1]"
|
||||
);
|
||||
// IPv6 with brackets and port
|
||||
assert_eq!(
|
||||
extract_host("https://[2001:db8::1]:8080/path").unwrap(),
|
||||
"[2001:db8::1]"
|
||||
);
|
||||
// IPv6 with brackets, trailing slash
|
||||
assert_eq!(
|
||||
extract_host("https://[fe80::1]/").unwrap(),
|
||||
"[fe80::1]"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn is_private_host_detects_local() {
|
||||
assert!(is_private_host("localhost"));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue