Skip to content

docs: correct the reason for refusing 0.0.0.0/8 in is_ip_blocked - #244

Merged
priyasingh2111 merged 1 commit into
strands-agents:mainfrom
priyasingh2111:feature/correct-zero-network-comment
Nov 12, 2026
Merged

priyasingh2111 merged 1 commit into
strands-agents:mainfrom
priyasingh2111:feature/correct-zero-network-comment

Conversation

@priyasingh2111

@priyasingh2111 priyasingh2111 commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Human readable section

Problem: A code comment in is_ip_blocked gave the wrong reason for refusing 0.0.0.0/8. It said Linux routes 0.x.y.z to the local host. Since Linux 5.3, nonzero 0.0.0.0/8 addresses are ordinary unicast destinations (see ip(7)), so that is not true on current Linux.

Solution: The comment now gives the real reason: 0.0.0.0/8 is reserved and not globally reachable, so curl refuses it by default, and allowed_urls can still permit it.

Trade-off: None. This is a comment-only change. The block itself does not change, and 0.0.0.0 itself is still refused by is_unspecified().

Description

Follow-up to #240, from review feedback received after it merged.

Related Issues

#240

Documentation PR

None.

Type of Change

Other (please describe): comment correction only.

Testing

  • cargo test --lib url_safety: 9 passed. cargo fmt --all -- --check is clean.
  • Manual check that the comment matches the behaviour, on this branch, on macOS 26.7 (arm64) and on Ubuntu Linux, kernel 7.3 (arm64). Both gave the same results:
Command Setup Result (macOS and Linux)
curl http://0.1.2.3/ default Shell curl: access denied: 0.1.2.3 (status 1), refused before sending
curl http://0.1.2.3/ Shell::builder().allow_url("http://0.1.2.3") curl: (6) error sending request (status 6). The guard let it through and the request was sent
curl http://0.0.0.0/ default Shell curl: access denied: 0.0.0.0, refused by is_unspecified()

On Linux, ip route get 0.1.2.3 shows via <default gateway> dev eth0: the kernel treats it as an ordinary unicast address and sends it to the default route, as ip(7) describes for Linux 5.3+. The gateway refused the connection, which gives error (6). So the old "routes to the local host" comment was wrong, and the new one holds on both. cargo test --lib url_safety also passes on Linux (9 passed).

Row 2 is why the comment says allowed_urls can still permit it: check_url returns early when a URL matches an allowed_urls prefix, before check_url_safe runs. "Reserved and not globally reachable" is from the IANA IPv4 special-purpose address registry (0.0.0.0/8, "This network", Globally Reachable: False).

  • 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.

@kevin-orellana kevin-orellana left a comment

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 comment now accurately describes the default network policy and addresses the feedback on #240. Verified that the diff remains comment-only after the rebase; no runtime behavior changes.

The comment said Linux routes 0.x.y.z to the local host. Since Linux 5.3,
nonzero 0.0.0.0/8 addresses are ordinary unicast destinations (ip(7)), so that
reason is wrong. The block stays: 0.0.0.0/8 is reserved and not globally
reachable, and allowed_urls can still permit it. 0.0.0.0 itself is refused by
is_unspecified(). Comment-only change; no behaviour changes.
@priyasingh2111
priyasingh2111 force-pushed the feature/correct-zero-network-comment branch from feacc02 to 15c91c1 Compare November 12, 2026 00:44
@priyasingh2111
priyasingh2111 merged commit 379cc36 into strands-agents:main Nov 12, 2026
30 checks passed
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.

2 participants