security(connectors): reject tunneled metadata addresses
This commit is contained in:
@@ -86,6 +86,9 @@ class HttpFetchTests(unittest.TestCase):
|
||||
"255.255.255.255",
|
||||
"::",
|
||||
"::ffff:255.255.255.255",
|
||||
"64:ff9b::169.254.169.254",
|
||||
"64:ff9b::255.255.255.255",
|
||||
"fd00:ec2::254",
|
||||
"fe80::1",
|
||||
"ff02::1",
|
||||
):
|
||||
@@ -95,6 +98,21 @@ class HttpFetchTests(unittest.TestCase):
|
||||
), self.assertRaisesRegex(OutboundHttpBlocked, "forbidden special-purpose network"):
|
||||
validate_outbound_http_url("https://connector.example.test/path", policy=policy)
|
||||
|
||||
def test_public_policy_rejects_reserved_and_ipv4_embedded_ipv6_addresses(self) -> None:
|
||||
policy = outbound_http_policy({"APP_ENV": "production"})
|
||||
for address in (
|
||||
"fec0::1",
|
||||
"::127.0.0.1",
|
||||
"64:ff9b::8.8.8.8",
|
||||
"64:ff9b::127.0.0.1",
|
||||
"2002:7f00:1::",
|
||||
):
|
||||
with self.subTest(address=address), patch(
|
||||
"govoplan_core.security.outbound_http.socket.getaddrinfo",
|
||||
return_value=[(10, 1, 6, "", (address, 443, 0, 0))],
|
||||
), self.assertRaises(OutboundHttpBlocked):
|
||||
validate_outbound_http_url("https://connector.example.test/path", policy=policy)
|
||||
|
||||
def test_outbound_policy_rejects_mixed_public_and_private_dns_answers(self) -> None:
|
||||
policy = outbound_http_policy({"APP_ENV": "production"})
|
||||
with patch(
|
||||
|
||||
Reference in New Issue
Block a user