Skip to content

refactor(security): the egress checks take their non-public address rules from a maintained source, not a hand-kept copy of pydantic-ai's private blocks #2184

Closed

Description

@dan-petty

What happened

The egress checks in src/devops_cli/core/validation.py (is_non_public_ip, _enforce_non_private_ssrf, validate_url) decide which addresses are non-public with a block list kept by hand in src/devops_cli/config/constants.py (CONST_PRIVATE_NETWORKS, from line 2547) and with hand-written handling of NAT64, Teredo, ISATAP and IPv4-embedding prefixes (CONST_NAT64_PREFIXES, CONST_TEREDO_PREFIX, CONST_ISATAP_INTERFACE_IDS, CONST_IPV4_EMBEDDING_IPV6_PREFIXES, CONST_LOW32_OFFSETS). The docstring of is_non_public_ip (line 393) says that the list mirrors "pydantic-ai's non-public blocks". In pydantic-ai 2.54.0 those blocks are in the private module pydantic_ai._ssrf, which has no API promise, so the copy can drift from upstream with each upgrade and nobody sees it. The test audit of 2026-10-24 found this.

The owner's rule: fixes use libraries, not home-grown IP code; a new hand-rolled helper is a major finding.

What should happen

The non-public test has one maintained source, and the code keeps no copy of another project's private code:

Evidence

  • src/devops_cli/core/validation.py:393 (the docstring), :599 (_enforce_non_private_ssrf), and the constants listed above, at origin/main on 2026-10-24.
  • python -c "import importlib.util; print(importlib.util.find_spec('pydantic_ai._ssrf'))" finds the private module in pydantic-ai 2.54.0.

Acceptance criteria

  • No constant or docstring in src/ copies or mirrors a private module of another package.
  • A table test runs the classifier over the IPv4 and IPv6 special-purpose registries of IANA and over the NAT64, Teredo and IPv4-mapped forms of private addresses, and each answer agrees with the chosen source or with a rule that the code documents.
  • The existing SSRF tests pass unchanged.

Source: #2152

Proposed design

Problem statement

The egress validation in src/devops_cli/core/validation.py classifies non-public IP addresses using a hand-kept block list in src/devops_cli/config/constants.py. This list mirrors the private module pydantic_ai._ssrf, which has no API guarantee. The copy can drift from upstream with each pydantic-ai upgrade. The owner's rule requires using maintained libraries, not home-grown IP code.

Acceptance criteria

  • Criterion 1: No constant or docstring in src/ references or mirrors a private module of another package.
    Verification: Run grep -rn '_ssrf\|pydantic.ai.*non.public\|pydantic.ai.*private' src/ and confirm zero matches.
  • Criterion 2: A table test covers every IPv4 and IPv6 IANA special-purpose registry plus NAT64, Teredo, and IPv4-mapped forms of private addresses.
    Verification: Run pytest tests/ -k 'ssrf or non_public' -v and confirm the table includes an entry for each IANA registry and each transition mechanism.
  • Criterion 3: The existing SSRF tests pass without modification.
    Verification: Run pytest tests/ -k 'ssrf or egress or non_public' and confirm all tests pass with no test file changes in the diff.

Key questions

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

#2152

Alternatives check of 2026-11-02: not-applicable.
Class: refactor, no search.
Tool: none found.

Activity

  1. added
    source/agent
    type/refactor
    on Oct 24, 2026
  2. dan-petty commented on Oct 24, 2026

    @dan-petty
    OwnerAuthor

    Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones on the board.

    • Type: type/refactor. the candidate proposes to refactor the way SSRF checks are done by using a public API instead of hand-kept copies.
    • Priority: P1-High. this change improves security by removing reliance on private module copies that can drift from upstream.
    • Value: High. the change fixes a security issue where the code relies on outdated and unmaintained copies of another library's private API.
    • Effort: Medium. requires replacing hand-rolled logic with a public API, updating tests, and ensuring compatibility with existing functionality.
    • Related: fix(security): reference_extractor classifies addresses with ipaddress, and the sandbox local whitelist stops mapping host.docker.internal to pod loopback #1174, which asks for a different change. both items improve IP address classification; this one focuses on removing private module copies, while #1174 uses stdlib classes for classification.
  3. dan-petty commented on Oct 27, 2026

    @dan-petty
    OwnerAuthor

    Status set to Ready at 0abf552 (see proposed design in issue body).

  4. added
    priority/p1-high
    status/ready
    effort/medium
    value/high
    scope/security
    on Oct 28, 2026
  5. devops-cli-service commented on Nov 2, 2026

    @devops-cli-service
    Contributor

    Staged: branch refactor/2184-the-egress-checks-take-their-non, draft pull request #3156. The pull request plans the item and closes no issue.

    The task groups, with the tokens of the inputs of each step, for a budget of 40000 tokens:

    1. Add the table test and the standard-library classifier: 7708 tokens
    2. Delete the copied block-list constants: 12384 tokens
  6. devops-cli-service commented on Nov 2, 2026

    @devops-cli-service
    Contributor

    Alternatives check: not-applicable

    Class: refactor. The check makes no search and no model call for an item of this class.

    Tool: none found

    Checked on 2026-11-02. A person decides what this means for the item. The check changes no label and closes no issue.

  7. added 2 commits that reference this issue on Nov 2, 2026
  8. added
    status/planned
    and removed
    status/ready
    on Nov 2, 2026
  9. added
    owner/agent
    status/in-progress
    status/in-review
    and removed
    status/planned
    status/in-progress
    on Nov 4, 2026
  10. removed
    status/in-review
    owner/agent
    on Nov 4, 2026
  11. devops-cli-service commented on Nov 4, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-04 23:38 UTC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/mediumpriority/p1-highscope/securitysource/agenttype/refactorvalue/high

    Type

    No type

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions