@@ -1393,21 +1393,20 @@ def test_forward_proxy_allows_private_ip_with_allowed_ips(
13931393 )
13941394
13951395
1396- def test_forward_proxy_allows_private_ip_host_without_allowed_ips (
1396+ def test_forward_proxy_denied_without_allowed_ips (
13971397 sandbox : Callable [..., Sandbox ],
13981398) -> None :
1399- """FWD-2: Forward proxy to literal IP host without allowed_ips -> 200 .
1399+ """FWD-2: Forward proxy to private IP without allowed_ips -> 403 .
14001400
1401- When the policy host field is a literal IP address, the user has explicitly
1402- declared intent to allow that destination. The SSRF guard synthesizes an
1403- implicit allowed_ips entry, so explicit allowed_ips is not required.
1401+ Even though the endpoint matches, forward proxy requires explicit
1402+ allowed_ips on the endpoint.
14041403 """
14051404 policy = _base_policy (
14061405 network_policies = {
14071406 "internal_http" : sandbox_pb2 .NetworkPolicyRule (
14081407 name = "internal_http" ,
14091408 endpoints = [
1410- # No allowed_ips — but host is a literal IP, so implicit
1409+ # No allowed_ips — forward proxy should be denied
14111410 sandbox_pb2 .NetworkEndpoint (
14121411 host = _SANDBOX_IP ,
14131412 port = _FORWARD_PROXY_PORT ,
@@ -1420,15 +1419,16 @@ def test_forward_proxy_allows_private_ip_host_without_allowed_ips(
14201419 spec = datamodel_pb2 .SandboxSpec (policy = policy )
14211420 with sandbox (spec = spec , delete_on_exit = True ) as sb :
14221421 result = sb .exec_python (
1423- _forward_proxy_with_server (),
1424- args = (_PROXY_HOST , _PROXY_PORT , _SANDBOX_IP , _FORWARD_PROXY_PORT ),
1422+ _forward_proxy_raw (),
1423+ args = (
1424+ _PROXY_HOST ,
1425+ _PROXY_PORT ,
1426+ f"http://{ _SANDBOX_IP } :{ _FORWARD_PROXY_PORT } /test" ,
1427+ ),
14251428 )
14261429 assert result .exit_code == 0 , result .stderr
1427- assert "200" in result .stdout , (
1428- f"Expected 200 for literal IP host, got: { result .stdout } "
1429- )
1430- assert "forward-proxy-ok" in result .stdout , (
1431- f"Expected response body relayed, got: { result .stdout } "
1430+ assert "403" in result .stdout , (
1431+ f"Expected 403 without allowed_ips, got: { result .stdout } "
14321432 )
14331433
14341434
0 commit comments