fix(security): route allowlisted provider validation through EgressWeave - #1046
fix(security): route allowlisted provider validation through EgressWeave#1046seonghobae wants to merge 9 commits into
Conversation
ModelClient._validate_provider's allowlisted-host branch used a hand-rolled resolve-then-check loop for its SSRF guard. Replace it with EgressWeave's validate_egress_url_details, reusing its already-validated, already-resolved addresses directly instead of re-resolving (re-resolving would reopen the validate-then-connect DNS-rebinding gap EgressWeave closes). The no-allowlist-configured default keeps the prior hand-rolled check, since EgressWeave's allowlist model can't express "no host restriction" (an empty allowlist there rejects every host, not none). Resolves #1041. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Team Run ID: ⛔ Files ignored due to path filters (2)
📒 Files selected for processing (4)
Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review. 📝 WalkthroughWalkthrough허용 목록이 설정된 프로바이더 호스트 검증을 EgressWeave에 위임합니다. EgressWeave가 검증한 IPv4 또는 IPv6 주소를 연결 대상에 사용합니다. DNS 해석 경계를 반영하도록 테스트를 수정하고 사설 주소 거부 테스트를 추가합니다. Changes프로바이더 Egress 검증
Estimated code review effort: 3 (Moderate) | ~20 minutes Merge Risk: ⚪ Minimal · up to Allowlisted provider URLs now receive SSRF and DNS-rebinding validation while preserving existing behavior when no allowlist is configured. The validated address is used for the provider connection, and the available regression coverage includes private-address rejection. Sequence Diagram(s)sequenceDiagram
participant ModelClient
participant EgressWeave
participant DNSResolver
ModelClient->>EgressWeave: EgressPolicy와 프로바이더 URL 전달
EgressWeave->>DNSResolver: 호스트 주소 해석
DNSResolver-->>EgressWeave: 주소 목록 반환
EgressWeave-->>ModelClient: 검증된 주소 또는 거부 오류 반환
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 1 files. (3 skipped: 2 unsupported, 1 too large.)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
CodeRabbit's pre-merge docstring-coverage check flagged this new helper (added in dca1084) as missing documentation, bringing diff-scoped docstring coverage to 33% against an 80% threshold. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
최신 main 병합 및 provider-validation slice 검증PR head
검증 결과:
현재 Ready 상태는 유지합니다. Auto-merge가 안전하려면 이 exact head의 required tests/security scans가 모두 명시적 성공 상태가 되고, 최신 head에 유효한 필수 robot/human review가 충족되며, protected-branch ruleset이 merge를 허용해야 합니다. 대기 중인 체크를 이전 head 결과로 대체하지 않습니다. |
Signed-off-by: Seongho Bae <me@seonghobae.me>
Signed-off-by: Seongho Bae <me@seonghobae.me>
…to codex/pr1046-restack
…to codex/pr1046-restack
|
Status note, since a cross-session triage described this PR as a lock-file change conflicting with #1030 on This is a stacked PR, not a main-based one. The real conflict against
So resolving this is NIM-benchmark work, not dependency-lock work. Whoever owns that surface should take the resolution; the EgressWeave delta itself ( One more thing worth flagging: commit All checks run on a clone verified 0 commits behind |
Summary
ModelClient._validate_provider's allowlisted-host branch replaces its hand-rolled resolve-then-check SSRF loop with EgressWeave'svalidate_egress_url_details(CWE-918/CWE-350).ProviderDestination— re-resolving would reopen the validate-then-connect DNS-rebinding gap EgressWeave closes.Resolves #1041.
Implementation notes (scoped in the issue first)
The PyPI-published
egressweaveis0.1.0— materially simpler than the unreleasedmainbranch I initially read (no port-authority dimension, just a host allowlist, matching this codebase's existing host-onlyallowed_provider_hostssemantics exactly). See the issue comments for the full scoping trail, including the correction after downloading and inspecting the actual installable wheel.egressweave>=0.1.0,<0.2.0topyproject.toml.requirements.lockviauv pip compile --universal --python-version 3.10 --extra=api --extra=db --extra=queue --generate-hashes --output-file=requirements.lock pyproject.toml(universal mode was necessary to preserve the existingpython_full_version >= '3.12'markers onfast-mlsirm/numpy— a plain single-interpreter compile silently dropped them).uv.lockviauv lock.test_provider_allowlist_ignores_request_time_environment_changes: it previously mockedModelClient._resolve_addresses, a seam EgressWeave's allowlisted path no longer calls (EgressWeave resolves DNS itself viasocket.getaddrinfo). Now patches at that shared boundary instead.test_provider_allowlist_rejects_allowlisted_host_resolving_to_private_addresscovering the case an allowlisted host still needs address-safety checking.Verification
PYTHONPATH=. python -m pytest tests/test_security_hardening.py -q— 26 passed.PYTHONPATH=. python -m pytest tests/ -q(full suite, pre-lock-regen venv) — 3391 passed, 2 skipped.uv run --locked --extra api --extra db --extra queue --group dev python -m pytest -q(exact CI command, post-lock-regen) — 3391 passed, 2 skipped in 657s.python -m pip install --disable-pip-version-check --no-input --require-hashes -r requirements.lock(exact security.yml command) — installs cleanly.python -m pip_audit -r requirements.lock— no known vulnerabilities found.Developer experience
No API surface change for existing no-allowlist deployments. Allowlist-configured deployments gain a stricter, more thoroughly-audited SSRF/DNS-rebinding guard at the cost of two new transitive dependencies (
httpx,httpcore) that this codebase doesn't otherwise use — accepted per the issue's scoping discussion since they're EgressWeave's own hard package dependency regardless of which of its symbols are imported.User experience
No behavior change for the default (no-allowlist) configuration. Allowlist-configured deployments get equivalent-or-stricter address-safety rejection (EgressWeave's
is_globalcheck catches more reserved-address classes than the prior hand-rolledis_private/is_loopback/is_link_local/is_multicast/is_reservedcheck).🤖 Generated with Claude Code
Summary by CodeRabbit
Current restack authority
7ebe9128245c3ad212f8f2d6456bd6d968cc5139fa5446294ae7ae69f1c2958aa1ab6c071fa760bc47 passed59 passed3396 passed, 2 skippedgit diff --check: passThe prior Noema and Strix failures were provider-infrastructure failures, not transferable source approvals. Fresh hosted checks and current-head review remain required. #1063 stays open until #1068 reaches protected main and exact-tree equivalence is verified.