SSRF-3: Proxy log includes block reason when SSRF check fires. Loopback addresses are always-blocked. Since implicit_allowed_ips_for_ip_host now skips always-blocked hosts, 127.0.0.1 falls through to the default resolve_and_reject_internal path which blocks it as an internal address.
(
sandbox: Callable[..., Sandbox],
)
| 695 | |
| 696 | |
| 697 | def test_ssrf_log_shows_blocked_address( |
| 698 | sandbox: Callable[..., Sandbox], |
| 699 | ) -> None: |
| 700 | """SSRF-3: Proxy log includes block reason when SSRF check fires. |
| 701 | |
| 702 | Loopback addresses are always-blocked. Since implicit_allowed_ips_for_ip_host |
| 703 | now skips always-blocked hosts, 127.0.0.1 falls through to the default |
| 704 | resolve_and_reject_internal path which blocks it as an internal address. |
| 705 | The shorthand log should include 'ssrf' and a '[reason:' tag for denied events. |
| 706 | """ |
| 707 | policy = _base_policy( |
| 708 | network_policies={ |
| 709 | "internal": sandbox_pb2.NetworkPolicyRule( |
| 710 | name="internal", |
| 711 | endpoints=[ |
| 712 | sandbox_pb2.NetworkEndpoint(host="127.0.0.1", port=80), |
| 713 | ], |
| 714 | binaries=[sandbox_pb2.NetworkBinary(path="/**")], |
| 715 | ), |
| 716 | }, |
| 717 | ) |
| 718 | spec = datamodel_pb2.SandboxSpec(policy=policy) |
| 719 | with sandbox(spec=spec, delete_on_exit=True) as sb: |
| 720 | sb.exec_python(_proxy_connect(), args=("127.0.0.1", 80)) |
| 721 | |
| 722 | log_result = sb.exec_python(_read_openshell_log()) |
| 723 | assert log_result.exit_code == 0, log_result.stderr |
| 724 | log = log_result.stdout |
| 725 | # OCSF shorthand uses "engine:ssrf" for SSRF blocks |
| 726 | assert "engine:ssrf" in log.lower() or "ssrf" in log.lower(), ( |
| 727 | f"Expected SSRF block indicator in proxy log, got:\n{log}" |
| 728 | ) |
| 729 | # Shorthand for denied events should include [reason:...] tag |
| 730 | assert "[reason:" in log.lower(), ( |
| 731 | f"Expected [reason:] tag in denied event shorthand, got:\n{log}" |
| 732 | ) |
| 733 | |
| 734 | |
| 735 | # ============================================================================= |
nothing calls this directly
no test coverage detected