Skip to content

fix: refuse translated and platform metadata addresses in the SSRF guard - #240

Merged
ferdingler merged 7 commits into
strands-agents:mainfrom
priyasingh2111:feature/ssrf-nat64-platform-metadata
Nov 11, 2026
Merged

ferdingler merged 7 commits into
strands-agents:mainfrom
priyasingh2111:feature/ssrf-nat64-platform-metadata

Conversation

@priyasingh2111

@priyasingh2111 priyasingh2111 commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Human readable section

Problem: curl refuses requests to addresses an agent must never reach, such as cloud metadata services, so the agent cannot read the host's credentials. The check missed some ways to write those addresses. For example, http://[64:ff9b::a9fe:a9fe]/ is the metadata address 169.254.169.254 written in an IPv6 form, and curl sent it. Two platform metadata addresses outside 169.254.0.0/16 also went through.

Solution: The check now reads the IPv4 address inside these IPv6 forms and refuses it when it is blocked. It also refuses the two metadata addresses and 0.0.0.0/8. Public addresses, including public addresses written in these IPv6 forms, still work. README and SECURITY.md now list exactly what the check covers.

Trade-off: The check still lists the addresses it refuses, so a new metadata endpoint or IPv6 form needs another change. A NAT64 network that uses its own prefix is still not covered. A rule that allows only globally reachable addresses would end this, but it changes behaviour and is left for a separate change.

Description

The SSRF guard misses some IPv6 encodings of IPv4 addresses and some platform metadata addresses. is_ip_blocked already checks the IPv4 address inside IPv4-mapped, IPv4-compatible, 6to4 and Teredo addresses, but not inside two other encodings:

  • NAT64, well-known prefix 64:ff9b::/96
  • IPv4-translated, ::ffff:0:0:0/96

It also has no entry for 0.0.0.0/8, Azure WireServer 168.63.129.16, or the Alibaba Cloud metadata address 100.100.100.200. So check_url_safe (URL literals) and SafeResolver (DNS answers) both accept, for example, 64:ff9b::a9fe:a9fe, which carries 169.254.169.254.

This change:

  • applies the existing IPv4 checks to the address inside the NAT64 /96 and IPv4-translated prefixes
  • refuses all of the RFC 8215 local-use prefix 64:ff9b:1::/48, because it is never globally routed and its embedding offset is chosen by the operator
  • refuses 0.0.0.0/8, 168.63.129.16 and 100.100.100.200

What stays allowed:

  • A NAT64 address that carries a public IPv4 address, for example 64:ff9b::808:808.
  • The rest of 100.64.0.0/10. Shared address space is not a metadata range, so only the Alibaba address is refused.
  • allowed_urls, which behaves as before.

README and SECURITY.md now list what the guard covers.

Background: what the SSRF guard does

The Shell's curl runs this check before any request leaves the host. The agent controls the URL, but the host sends the request. So without the check, a misled agent could make the host:

  • read a cloud metadata service and take the instance's credentials
  • reach internal services that are not exposed to the internet
  • reach local services on the machine

The check refuses loopback, private, link-local and metadata addresses. It checks both the URL literal and the address a hostname resolves to.

Follow-up: the list keeps growing

The guard lists the addresses it refuses. So each new IPv6 encoding of an IPv4 address, and each cloud metadata endpoint outside 169.254.0.0/16, is a new gap. This PR closes the known gaps, not that pattern.

A lasting fix would invert the rule: allow only globally reachable addresses (IANA special-purpose registries) and refuse the rest unless allowed_urls grants them. All IPv4-in-IPv6 encodings would be unwrapped in one helper. Only the metadata endpoints that sit on public addresses, such as 168.63.129.16, would still need to be named. That is a behaviour change: internal services in special ranges would need an allowed_urls entry. So it needs maintainer agreement and is left for a separate change.

Related Issues

None.

Documentation PR

None. README.md and SECURITY.md are updated in this PR.

Type of Change

Bug fix

Testing

  • check_url_safe_blocks_translated_and_platform_metadata_addresses covers NAT64 (/96, also in dotted form), RFC 8215, IPv4-translated, WireServer, Alibaba and 0.0.0.0/8. It fails on main and passes with this change.

  • check_url_safe_allows_public_destinations_behind_nat64_and_shared_space pins the addresses that stay allowed.

  • cargo xtask check --rust-only passes. cargo test: 2081 passed, 0 failed.

  • cargo fmt --all -- --check is clean. cargo clippy --workspace --all-targets reports the same warnings as main.

  • Not run: the Python and Node binding suites (this PR does not touch them), a live NAT64 translator, and requests to real metadata services.

  • I ran the relevant test suites for the bindings I touched (cargo test --workspace --all-targets, pytest tests/python, npm test)

  • If I touched Rust, I ran cargo fmt and cargo clippy

Checklist

  • I have read the CONTRIBUTING document
  • I have reviewed and understand every line of code in this PR, including any generated by AI tools, and I can explain why it works
  • My change is focused and reasonably small; I have split unrelated work into separate PRs
  • I have added any necessary tests that prove my fix is effective or my feature works
  • I have updated the documentation accordingly
  • I have added an appropriate example to the documentation to outline the feature, or no new docs are needed
  • My changes generate no new warnings
  • Any dependent changes have been merged and published

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

is_ip_blocked checked the IPv4 address inside IPv4-mapped, IPv4-compatible,
6to4, and Teredo addresses, but not inside the NAT64 well-known prefix
64:ff9b::/96 or the IPv4-translated prefix ::ffff:0:0:0/96. It also had no
entry for 0.0.0.0/8, Azure WireServer 168.63.129.16, or the Alibaba Cloud
metadata address 100.100.100.200. So check_url_safe and SafeResolver accepted
an address such as 64:ff9b::a9fe:a9fe, which carries 169.254.169.254.

The guard now applies the IPv4 checks to the address inside the NAT64 and
IPv4-translated prefixes, refuses the whole RFC 8215 local-use prefix
64:ff9b:1::/48, and refuses 0.0.0.0/8, 168.63.129.16, and 100.100.100.200.
A NAT64 address that carries a public IPv4 address, and the rest of
100.64.0.0/10, stay allowed. allowed_urls behaves as before.

Tests: check_url_safe_blocks_translated_and_platform_metadata_addresses fails
without the change and passes with it.
check_url_safe_allows_public_destinations_behind_nat64_and_shared_space pins
the addresses that stay allowed. cargo test: 2081 passed, 0 failed.
cargo fmt --check is clean, and clippy warnings are unchanged from main.
priyasingh2111 added a commit to strands-agents/box that referenced this pull request Nov 10, 2026
…transport

## Problem

The Shell `curl` and the Monty `fetch` call the vendored `check_url_safe`
before they send a request to the gateway. Its `is_ip_blocked` did not read
the IPv4 address inside a NAT64 (`64:ff9b::/96`) or IPv4-translated
(`::ffff:0:0:0/96`) address. It also did not refuse `0.0.0.0/8`, Azure
WireServer `168.63.129.16`, or the Alibaba Cloud metadata address
`100.100.100.200`. So a literal such as `http://[64:ff9b::a9fe:a9fe]/`, which
carries `169.254.169.254`, passed this check. Only authored policy could then
refuse it. The example `metadata_addresses` forbids did not name the Azure or
Alibaba addresses, so a box that uses an example policy permitted them.

## Solution

`is_ip_blocked` in `crates/shell` now applies its IPv4 checks to the address
inside the NAT64 and IPv4-translated prefixes. It refuses all of the RFC 8215
local-use prefix `64:ff9b:1::/48`, and it refuses `0.0.0.0/8`,
`168.63.129.16`, and `100.100.100.200`. A NAT64 address that carries a public
IPv4 address, and the rest of `100.64.0.0/10`, stay allowed. This is an
upstream bug. The same change is proposed upstream in
strands-agents/shell#240, and `crates/shell/UPSTREAM.md` records the
divergence.

The four example policies and `docs/user/security.md` add `168.63.129.16` and
`100.100.100.200` to `metadata_addresses`. `docs/design/egress.md` lists them.
The vendored README and SECURITY.md state the new coverage. A comment in the
Monty `fetch` no longer says that the gateway has a compiled floor. No
interface changes.

## Tests

- `vfs_kernel.rs::url_safety_tests::check_url_safe_blocks_translated_and_platform_metadata_addresses`
  refuses nine literals. It fails without the change.
- `check_url_safe_allows_public_destinations_behind_nat64_and_shared_space`
  pins the addresses that stay allowed.
- `run::broker::python::fetch::tests::a_fetch_to_a_translated_or_platform_metadata_literal_is_refused_before_transport`
  shows that four literals are refused and no request reaches the proxy.
  I removed the vendored change and the test failed at
  `[64:ff9b::a9fe:a9fe]`. I restored the change and the test passed.
- `shipped_examples` in `strands-box` and `strands-box-policy` pass, so each
  edited example policy still loads.
- `cargo test --workspace --all-features`: 4884 passed, 0 failed, 17 ignored.
  The `just clippy` flags report no warnings. `cargo fmt --all --check` is
  clean.

These tests did not run: a live NAT64 translator, and requests to real
metadata services. The Shell `curl` path has no new Box-level test. It calls
the same `check_url_safe` that the vendored unit tests cover.
priyasingh2111 added a commit to strands-agents/box that referenced this pull request Nov 11, 2026
…transport

## Problem

The Shell `curl` and the Monty `fetch` call the vendored `check_url_safe`
before they send a request to the gateway. Its `is_ip_blocked` did not read
the IPv4 address inside a NAT64 (`64:ff9b::/96`) or IPv4-translated
(`::ffff:0:0:0/96`) address. It also did not refuse `0.0.0.0/8`, Azure
WireServer `168.63.129.16`, or the Alibaba Cloud metadata address
`100.100.100.200`. So a literal such as `http://[64:ff9b::a9fe:a9fe]/`, which
carries `169.254.169.254`, passed this check. Only authored policy could then
refuse it. The example `metadata_addresses` forbids did not name the Azure or
Alibaba addresses, so a box that uses an example policy permitted them.

## Solution

`is_ip_blocked` in `crates/shell` now applies its IPv4 checks to the address
inside the NAT64 and IPv4-translated prefixes. It refuses all of the RFC 8215
local-use prefix `64:ff9b:1::/48`, and it refuses `0.0.0.0/8`,
`168.63.129.16`, and `100.100.100.200`. A NAT64 address that carries a public
IPv4 address, and the rest of `100.64.0.0/10`, stay allowed. This is an
upstream bug. The same change is proposed upstream in
strands-agents/shell#240, and `crates/shell/UPSTREAM.md` records the
divergence.

The four example policies and `docs/user/security.md` add `168.63.129.16` and
`100.100.100.200` to `metadata_addresses`. `docs/design/egress.md` lists them.
The vendored README and SECURITY.md state the new coverage. A comment in the
Monty `fetch` no longer says that the gateway has a compiled floor. No
interface changes.

## Tests

- `vfs_kernel.rs::url_safety_tests::check_url_safe_blocks_translated_and_platform_metadata_addresses`
  refuses nine literals. It fails without the change.
- `check_url_safe_allows_public_destinations_behind_nat64_and_shared_space`
  pins the addresses that stay allowed.
- `run::broker::python::fetch::tests::a_fetch_to_a_translated_or_platform_metadata_literal_is_refused_before_transport`
  shows that four literals are refused and no request reaches the proxy.
  I removed the vendored change and the test failed at
  `[64:ff9b::a9fe:a9fe]`. I restored the change and the test passed.
- `shipped_examples` in `strands-box` and `strands-box-policy` pass, so each
  edited example policy still loads.
- `cargo test --workspace --all-features`: 4884 passed, 0 failed, 17 ignored.
  The `just clippy` flags report no warnings. `cargo fmt --all --check` is
  clean.

These tests did not run: a live NAT64 translator, and requests to real
metadata services. The Shell `curl` path has no new Box-level test. It calls
the same `check_url_safe` that the vendored unit tests cover.
@ferdingler
ferdingler merged commit def7ab7 into strands-agents:main Nov 11, 2026
38 checks passed
Comment thread src/vfs_kernel.rs
|| v4.is_link_local()
|| v4.is_unspecified()
|| v4.octets()[..2] == [169, 254]
// 0.0.0.0/8 "this network": Linux routes 0.x.y.z to the local host.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The localhost-routing claim is inaccurate for Box’s Amazon Linux 2023 baseline. Since Linux 5.3, nonzero addresses in 0.0.0.0/8 are treated as ordinary network destinations. Could we replace that explanation with “Block 0.0.0.0/8 under the default network policy”? That states the intended restriction without relying on the incorrect routing claim.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, thanks. Since Linux 5.3, nonzero 0.0.0.0/8 addresses are ordinary unicast destinations, so the comment gives the wrong reason. The block still stands: 0/8 is reserved and not globally reachable, and 0.0.0.0 itself was already refused by is_unspecified(). Shell has no policy layer, so I worded the comment as "reserved and not globally reachable, so curl refuses it by default; allowed_urls can still permit it". The fix is in #244, since this PR is merged. Box's copy gets the same comment in strands-agents/box#393.

priyasingh2111 added a commit to strands-agents/box that referenced this pull request Nov 11, 2026
…transport

## Problem

The Shell `curl` and the Monty `fetch` call the vendored `check_url_safe`
before they send a request to the gateway. Its `is_ip_blocked` did not read
the IPv4 address inside a NAT64 (`64:ff9b::/96`) or IPv4-translated
(`::ffff:0:0:0/96`) address. It also did not refuse `0.0.0.0/8`, Azure
WireServer `168.63.129.16`, or the Alibaba Cloud metadata address
`100.100.100.200`. So a literal such as `http://[64:ff9b::a9fe:a9fe]/`, which
carries `169.254.169.254`, passed this check. Only authored policy could then
refuse it. The example `metadata_addresses` forbids did not name the Azure or
Alibaba addresses, so a box that uses an example policy permitted them.

## Solution

`is_ip_blocked` in `crates/shell` now applies its IPv4 checks to the address
inside the NAT64 and IPv4-translated prefixes. It refuses all of the RFC 8215
local-use prefix `64:ff9b:1::/48`, and it refuses `0.0.0.0/8`,
`168.63.129.16`, and `100.100.100.200`. A NAT64 address that carries a public
IPv4 address, and the rest of `100.64.0.0/10`, stay allowed. This is an
upstream bug. The same change is proposed upstream in
strands-agents/shell#240, and `crates/shell/UPSTREAM.md` records the
divergence.

The four example policies and `docs/user/security.md` add `168.63.129.16` and
`100.100.100.200` to `metadata_addresses`. `docs/design/egress.md` lists them.
The vendored README and SECURITY.md state the new coverage. A comment in the
Monty `fetch` no longer says that the gateway has a compiled floor. No
interface changes.

## Tests

- `vfs_kernel.rs::url_safety_tests::check_url_safe_blocks_translated_and_platform_metadata_addresses`
  refuses nine literals. It fails without the change.
- `check_url_safe_allows_public_destinations_behind_nat64_and_shared_space`
  pins the addresses that stay allowed.
- `run::broker::python::fetch::tests::a_fetch_to_a_translated_or_platform_metadata_literal_is_refused_before_transport`
  shows that four literals are refused and no request reaches the proxy.
  I removed the vendored change and the test failed at
  `[64:ff9b::a9fe:a9fe]`. I restored the change and the test passed.
- `shipped_examples` in `strands-box` and `strands-box-policy` pass, so each
  edited example policy still loads.
- `cargo test --workspace --all-features`: 4884 passed, 0 failed, 17 ignored.
  The `just clippy` flags report no warnings. `cargo fmt --all --check` is
  clean.

These tests did not run: a live NAT64 translator, and requests to real
metadata services. The Shell `curl` path has no new Box-level test. It calls
the same `check_url_safe` that the vendored unit tests cover.
priyasingh2111 added a commit to strands-agents/box that referenced this pull request Nov 11, 2026
…transport

## Problem

The Shell `curl` and the Monty `fetch` call the vendored `check_url_safe`
before they send a request to the gateway. Its `is_ip_blocked` did not read
the IPv4 address inside a NAT64 (`64:ff9b::/96`) or IPv4-translated
(`::ffff:0:0:0/96`) address. It also did not refuse `0.0.0.0/8`, Azure
WireServer `168.63.129.16`, or the Alibaba Cloud metadata address
`100.100.100.200`. So a literal such as `http://[64:ff9b::a9fe:a9fe]/`, which
carries `169.254.169.254`, passed this check. Only authored policy could then
refuse it. The example `metadata_addresses` forbids did not name the Azure or
Alibaba addresses, so a box that uses an example policy permitted them.

## Solution

`is_ip_blocked` in `crates/shell` now applies its IPv4 checks to the address
inside the NAT64 and IPv4-translated prefixes. It refuses all of the RFC 8215
local-use prefix `64:ff9b:1::/48`, and it refuses `0.0.0.0/8`,
`168.63.129.16`, and `100.100.100.200`. A NAT64 address that carries a public
IPv4 address, and the rest of `100.64.0.0/10`, stay allowed. This is an
upstream bug. The same change is proposed upstream in
strands-agents/shell#240, and `crates/shell/UPSTREAM.md` records the
divergence.

The four example policies and `docs/user/security.md` add `168.63.129.16` and
`100.100.100.200` to `metadata_addresses`. `docs/design/egress.md` lists them.
The vendored README and SECURITY.md state the new coverage. A comment in the
Monty `fetch` no longer says that the gateway has a compiled floor. No
interface changes.

## Tests

- `vfs_kernel.rs::url_safety_tests::check_url_safe_blocks_translated_and_platform_metadata_addresses`
  refuses nine literals. It fails without the change.
- `check_url_safe_allows_public_destinations_behind_nat64_and_shared_space`
  pins the addresses that stay allowed.
- `run::broker::python::fetch::tests::a_fetch_to_a_translated_or_platform_metadata_literal_is_refused_before_transport`
  shows that four literals are refused and no request reaches the proxy.
  I removed the vendored change and the test failed at
  `[64:ff9b::a9fe:a9fe]`. I restored the change and the test passed.
- `shipped_examples` in `strands-box` and `strands-box-policy` pass, so each
  edited example policy still loads.
- `cargo test --workspace --all-features`: 4884 passed, 0 failed, 17 ignored.
  The `just clippy` flags report no warnings. `cargo fmt --all --check` is
  clean.

These tests did not run: a live NAT64 translator, and requests to real
metadata services. The Shell `curl` path has no new Box-level test. It calls
the same `check_url_safe` that the vendored unit tests cover.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants