FWD-5: Forward proxy to public IP -> 403. Even with allowed_ips, forward proxy is restricted to private IPs. Plain HTTP should never traverse the public internet.
(
sandbox: Callable[..., Sandbox],
)
| 1526 | |
| 1527 | |
| 1528 | def test_forward_proxy_public_ip_denied( |
| 1529 | sandbox: Callable[..., Sandbox], |
| 1530 | ) -> None: |
| 1531 | """FWD-5: Forward proxy to public IP -> 403. |
| 1532 | |
| 1533 | Even with allowed_ips, forward proxy is restricted to private IPs. |
| 1534 | Plain HTTP should never traverse the public internet. |
| 1535 | """ |
| 1536 | policy = _base_policy( |
| 1537 | network_policies={ |
| 1538 | "public": sandbox_pb2.NetworkPolicyRule( |
| 1539 | name="public", |
| 1540 | endpoints=[ |
| 1541 | sandbox_pb2.NetworkEndpoint( |
| 1542 | host="example.com", |
| 1543 | port=80, |
| 1544 | allowed_ips=["93.184.0.0/16"], |
| 1545 | ), |
| 1546 | ], |
| 1547 | binaries=[sandbox_pb2.NetworkBinary(path="/**")], |
| 1548 | ), |
| 1549 | }, |
| 1550 | ) |
| 1551 | spec = datamodel_pb2.SandboxSpec(policy=policy) |
| 1552 | with sandbox(spec=spec, delete_on_exit=True) as sb: |
| 1553 | result = sb.exec_python( |
| 1554 | _forward_proxy_raw(), |
| 1555 | args=(_PROXY_HOST, _PROXY_PORT, "http://example.com/"), |
| 1556 | ) |
| 1557 | assert result.exit_code == 0, result.stderr |
| 1558 | assert "403" in result.stdout, ( |
| 1559 | f"Expected 403 for public IP forward proxy, got: {result.stdout}" |
| 1560 | ) |
| 1561 | |
| 1562 | |
| 1563 | def test_forward_proxy_log_fields( |
nothing calls this directly
no test coverage detected