Commit Graph

6 Commits

  • fix(network-proxy): normalize network proxy host matching (#19995)
    ## Why
    The proxy matches allow and deny rules against normalized host strings.
    Scoped IPv6 literals can arrive in equivalent forms, such as
    `fd00::1%eth0`, `[fd00::1%eth0]`, or `[fd00::1%25eth0]`. Policy should
    canonicalize those spellings without erasing scope granularity: an
    unscoped rule like `fd00::1` should still cover scoped requests for that
    address, while a scoped rule like `fd00::1%eth0` should remain exact to
    that scope.
    
    ## What changed
    - preserve IPv6 scope IDs during host normalization and canonicalize
    `%25scope` to `%scope`
    - match policy against the exact normalized host plus the unscoped IP
    base for scoped literals
    - keep local-address explicit allow checks aligned with the same
    scoped/unscoped semantics
    - add focused coverage for scoped IPv6 normalization, scoped allow
    rules, and scoped deny rules in `network-proxy`
    
    ## Security impact
    A request cannot bypass a broad deny rule by adding an IPv6 scope
    suffix. At the same time, scoped policy remains precise:
    `deny=fd00::1%eth0` affects that scoped spelling without collapsing
    `fd00::1%eth1` onto the same key, and `allow=fe80::1%eth0` does not
    implicitly allow other scopes.
    
    ## Verification
    - `just fmt`
    - `cargo test -p codex-network-proxy`
    - `just fix -p codex-network-proxy`
    - `git diff --check`
    
    ---------
    
    Co-authored-by: Codex <noreply@openai.com>
    Co-authored-by: evawong-oai <evawong@openai.com>
  • Add wildcard in the middle test coverage (#15813)
    ## Summary
    Add a focused codex network proxy unit test for the denylist pattern
    with wildcard in the middle `region*.some.malicious.tunnel.com`. This
    does not change how existing code works, just ensure that behavior stays
    the same and we got CI guards to guard existin behavior.
    
    ## Why
    The managed Codex denylist update relies on this mid label glob form,
    and the existing tests only covered exact hosts, `*.` subdomains, and
    `**.` apex plus subdomains.
    
    ## Validation
    `cargo test -p codex-network-proxy
    compile_globset_supports_mid_label_wildcards`
    `cargo test -p codex-network-proxy`
    `./tools/argument-comment-lint/run-prebuilt-linter.sh -p
    codex-network-proxy`
  • Allow global network allowlist wildcard (#15549)
    ## Problem
    
    Today `codex-network-proxy` rejects a global `*` in
    `network.allowed_domains`, so there is no static way to configure a
    denylist-only posture for public hosts. Users have to enumerate broad
    allowlist patterns instead.
    
    ## Approach
    
    - Make global wildcard acceptance field-specific: `allowed_domains` can
    use `*`, while `denied_domains` still rejects a global wildcard.
    - Keep the existing evaluation order, so explicit denies still win first
    and local/private protections still apply unless separately enabled.
    - Add coverage for the denylist-only behavior and update the README to
    document it.
    
    ## Validation
    
    - `just fmt`
    - `cargo test -p codex-network-proxy` (full run had one unrelated flaky
    telemetry test:
    `network_policy::tests::emit_block_decision_audit_event_emits_non_domain_event`;
    reran in isolation and it passed)
    - `cargo test -p codex-network-proxy
    network_policy::tests::emit_block_decision_audit_event_emits_non_domain_event
    -- --exact --nocapture`
    - `just fix -p codex-network-proxy`
    - `just argument-comment-lint`
  • Apply argument comment lint across codex-rs (#14652)
    ## Why
    
    Once the repo-local lint exists, `codex-rs` needs to follow the
    checked-in convention and CI needs to keep it from drifting. This commit
    applies the fallback `/*param*/` style consistently across existing
    positional literal call sites without changing those APIs.
    
    The longer-term preference is still to avoid APIs that require comments
    by choosing clearer parameter types and call shapes. This PR is
    intentionally the mechanical follow-through for the places where the
    existing signatures stay in place.
    
    After rebasing onto newer `main`, the rollout also had to cover newly
    introduced `tui_app_server` call sites. That made it clear the first cut
    of the CI job was too expensive for the common path: it was spending
    almost as much time installing `cargo-dylint` and re-testing the lint
    crate as a representative test job spends running product tests. The CI
    update keeps the full workspace enforcement but trims that extra
    overhead from ordinary `codex-rs` PRs.
    
    ## What changed
    
    - keep a dedicated `argument_comment_lint` job in `rust-ci`
    - mechanically annotate remaining opaque positional literals across
    `codex-rs` with exact `/*param*/` comments, including the rebased
    `tui_app_server` call sites that now fall under the lint
    - keep the checked-in style aligned with the lint policy by using
    `/*param*/` and leaving string and char literals uncommented
    - cache `cargo-dylint`, `dylint-link`, and the relevant Cargo
    registry/git metadata in the lint job
    - split changed-path detection so the lint crate's own `cargo test` step
    runs only when `tools/argument-comment-lint/*` or `rust-ci.yml` changes
    - continue to run the repo wrapper over the `codex-rs` workspace, so
    product-code enforcement is unchanged
    
    Most of the code changes in this commit are intentionally mechanical
    comment rewrites or insertions driven by the lint itself.
    
    ## Verification
    
    - `./tools/argument-comment-lint/run.sh --workspace`
    - `cargo test -p codex-tui-app-server -p codex-tui`
    - parsed `.github/workflows/rust-ci.yml` locally with PyYAML
    
    ---
    
    * -> #14652
    * #14651
  • fix: reject global wildcard network proxy domains (#13789)
    ## Summary
    - reject the global `*` domain pattern in proxy allow/deny lists and
    managed constraints introduced for testing earlier
    - keep exact hosts plus scoped wildcards like `*.example.com` and
    `**.example.com`
    - update docs and regression tests for the new invalid-config behavior
  • feat: introducing a network sandbox proxy (#8442)
    This add a new crate, `codex-network-proxy`, a local network proxy
    service used by Codex to enforce fine-grained network policy (domain
    allow/deny) and to surface blocked network events for interactive
    approvals.
    
    - New crate: `codex-rs/network-proxy/` (`codex-network-proxy` binary +
    library)
    - Core capabilities:
      - HTTP proxy support (including CONNECT tunneling)
      - SOCKS5 proxy support (in the later PR)
    - policy evaluation (allowed/denied domain lists; denylist wins;
    wildcard support)
      - small admin API for polling/reload/mode changes
    - optional MITM support for HTTPS CONNECT to enforce “limited mode”
    method restrictions (later PR)
    
    Will follow up integration with codex in subsequent PRs.
    
    ## Testing
    
    - `cd codex-rs && cargo build -p codex-network-proxy`
    - `cd codex-rs && cargo run -p codex-network-proxy -- proxy`