Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

fix(browser): block the full non-global IP list, not a reduced copy

Avi-Bendetskyde910879731e
diff --git a/crates/openhuman-core/src/modules/browser.rs b/crates/openhuman-core/src/modules/browser.rs
index 0965ab028e..3e34f59a3e 100644
--- a/crates/openhuman-core/src/modules/browser.rs
+++ b/crates/openhuman-core/src/modules/browser.rs
@@ -344,26 +344,11 @@ fn private_or_local(host: &str) -> bool {
if host == "localhost" || host.ends_with(".localhost") || host.ends_with(".local") {
return true;
}
+ // The network tools' full non-global list, so the browser blocks the same
+ // reserved, benchmarking and documentation ranges they do.
match host.parse::<std::net::IpAddr>() {
- Ok(std::net::IpAddr::V4(ip)) => {
- ip.is_private()
- || ip.is_loopback()
- || ip.is_link_local()
- || ip.is_unspecified()
- || ip.is_multicast()
- || ip.octets()[0] == 0
- || ip.octets()[0] == 100 && (64..=127).contains(&ip.octets()[1])
- }
- Ok(std::net::IpAddr::V6(ip)) => {
- ip.is_loopback()
- || ip.is_unique_local()
- || ip.is_unicast_link_local()
- || ip.is_unspecified()
- || ip.is_multicast()
- || ip
- .to_ipv4_mapped()
- .is_some_and(|mapped| private_or_local(&mapped.to_string()))
- }
+ Ok(std::net::IpAddr::V4(ip)) => crate::tools::implementations::is_non_global_v4(ip),
+ Ok(std::net::IpAddr::V6(ip)) => crate::tools::implementations::is_non_global_v6(ip),
Err(_) => false,
}
}
diff --git a/crates/openhuman-core/src/modules/browser_tests.rs b/crates/openhuman-core/src/modules/browser_tests.rs
index 039e05f99e..9e4d6ae026 100644
--- a/crates/openhuman-core/src/modules/browser_tests.rs
+++ b/crates/openhuman-core/src/modules/browser_tests.rs
@@ -14,6 +14,14 @@ fn navigation_uses_shared_allowlist_and_blocks_private_hosts() {
assert!(client.check_url("http://selenium.dev/").is_err());
}
+#[test]
+fn non_global_ip_literals_stay_blocked() {
+ for host in ["198.18.0.1", "240.0.0.1", "255.255.255.255", "192.0.2.1", "[2001:db8::1]"] {
+ assert!(private_or_local(host.trim_matches(['[', ']'])), "{host} must be blocked");
+ }
+ assert!(!private_or_local("93.184.216.34"));
+}
+
#[test]
fn module_origin_list_requires_https_for_allowed_host_tree() {
if browser_allow_all() {