cai/tests/tools
Mike German bb79146c68 fix(fetch_url): block cloud-metadata via IPv4-mapped IPv6 in SSRF guard
The fetch_url SSRF guard guarantees cloud-metadata endpoints (e.g.
169.254.169.254) are ALWAYS blocked, even when CAI_FETCH_ALLOW_INTERNAL
is set for an authorised internal pentest. That guarantee could be
bypassed with the IPv4-mapped IPv6 form of the IMDS address, e.g.
http://[::ffff:169.254.169.254]/ (or its hex form ::ffff:a9fe:a9fe),
because the metadata block is a plain string comparison against the bare
IPv4 literal. With allow_internal=True the private/reserved check is
skipped, so nothing caught the mapped form and the request reached IMDS.

Unwrap IPv4-mapped IPv6 addresses to their embedded IPv4 before the
metadata and private-range checks in both the literal-IP and DNS-resolved
paths. This also hardens the private-range check on Python versions that
do not classify mapped addresses as private/link-local.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: Mike German <mike@stepsventures.com>
2026-07-06 21:31:06 -04:00
..
web fix(fetch_url): block cloud-metadata via IPv4-mapped IPv6 in SSRF guard 2026-07-06 21:31:06 -04:00
test_approach_contest.py CAI 1.1.5 release (#455) 2026-06-05 13:43:19 +02:00
test_approach_contest_resolve.py CAI 1.1.5 release (#455) 2026-06-05 13:43:19 +02:00
test_avoid_sudo.py CAI 1.1.5 release (#455) 2026-06-05 13:43:19 +02:00
test_capture_notice.py CAI 1.1.5 release (#455) 2026-06-05 13:43:19 +02:00
test_evidence_inventory_check.py CAI 1.1.5 release (#455) 2026-06-05 13:43:19 +02:00
test_function_tool.py add new test and fix previous 2025-04-10 08:54:21 +02:00
test_function_tool_decorator.py add test 2025-04-10 07:58:40 +02:00
test_generic_linux_command_guardrails.py Added additional prompt injections PoCs 15 and 16 (#276) 2025-10-08 16:23:59 +02:00
test_handoff_tool.py add test 2025-04-10 07:58:40 +02:00
test_malformed_tool_call.py CAI 1.1.5 release (#455) 2026-06-05 13:43:19 +02:00
test_output_tool.py add more test 2025-04-10 09:27:56 +02:00
test_sensitive_guard_false_positives.py CAI 1.1.5 release (#455) 2026-06-05 13:43:19 +02:00
test_sudo_continuous_ops_no_sudo.py CAI 1.1.5 release (#455) 2026-06-05 13:43:19 +02:00
test_tool_choice_reset.py CAI 1.1.5 release (#455) 2026-06-05 13:43:19 +02:00
test_tool_converter.py add test 2025-04-10 07:58:40 +02:00
test_tool_generic_linux_command.py CAI 1.1.5 release (#455) 2026-06-05 13:43:19 +02:00
test_tool_generic_linux_sessions.py async sessions + friendly IDs + tolerant session commands (#253) 2025-08-29 15:34:48 +02:00
test_tool_use_behavior.py fix some test 2025-04-11 08:04:19 +02:00