Skip to content

security: reconstruct exact TLS configuration boundary on integrated main - #157

Closed
seonghobae wants to merge 5 commits into
mainfrom
security/reconstruct-exact-tls-dd0324
Closed

security: reconstruct exact TLS configuration boundary on integrated main#157
seonghobae wants to merge 5 commits into
mainfrom
security/reconstruct-exact-tls-dd0324

Conversation

@seonghobae

@seonghobae seonghobae commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Purpose

Reconstruct issue #111 / historical PR #148 on exact integrated protected main dd0324c0d7edb6effc74737039d1e754af09f5aa. Historical #148 remains immutable evidence only; none of its checks, reviews, approvals, base identity, or mergeability transfers.

Test-first proof

  • RED test-only head a3e387eb89e4a210bac1b3c8212250ec4cd5c607, CI 31444557116: exact checkout; Ruff passed; Python 3.10 failed exactly test_context_helper_rejects_tls_configuration_subclasses_before_dispatch with Failed: DID NOT RAISE TypeError; 1 failed, 764 passed.
  • Narrow source GREEN 7b04d33c6177f62529e7473b133e9f597fd1c63e: create_egress_ssl_context() now rejects every non-exact TLSConfiguration before subclass-controlled create_ssl_context() can dispatch.
  • Final current-main-compatible head 1db2a43cc367f15fb0eab6b3dfd682ca5ae44919 preserves the operator/research guide, migration contract, documentation regression, and [Unreleased] security history without importing stale base state.

Exact-current-head evidence

On 1db2a43cc367f15fb0eab6b3dfd682ca5ae44919:

  • CI 31445002331: success across package acceptance and Python 3.10–3.13;
  • Python 3.13.14: 767 passed;
  • owned production coverage: exactly 1,633/1,633 statements and 560/560 branches;
  • Ruff, product guard, compileall, wheel/sdist verification, installed-wheel smoke: success;
  • SAST Semgrep 31445002332: success;
  • Security Scan 31445002376: OSV, Trivy, and Scorecard success, but actual pinned Dependency review is skipped, so aggregate workflow success is not supply-chain acceptance.

Scope

No destination authority, DNS policy, proxy behavior, request/response framing, resource limits, credentials, workflow permissions, publisher authority, or public builder signature is widened. Exact instances retain private trust, mTLS, deferred private-key password, and explicit TLS 1.2 compatibility support.

Progresses #111. Historical #148 can be closed as superseded after final ref/review-state revalidation. Merge remains blocked on the read-only central fail-closed dependency-review repair and any current review/ruleset requirements.

Summary by CodeRabbit

  • 보안 개선

    • TLS 설정의 정확한 타입만 허용하여, 검증을 약화할 수 있는 하위 설정 사용을 차단했습니다.
    • 호스트명 및 인증서 검증이 항상 적용되도록 보호 기능을 강화했습니다.
    • 사용자 지정 신뢰 저장소, mTLS, TLS 1.2 호환 설정 및 지연형 키 비밀번호 지원은 유지됩니다.
  • 문서

    • TLS 설정 정책과 마이그레이션 지침을 추가했습니다.
    • 인증서 검증 관련 보안 참고자료를 보강했습니다.

@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

create_egress_ssl_context가 정확한 TLSConfiguration 인스턴스만 허용하도록 변경되었다. 서브클래스 거부 테스트와 TLS 정책 문서 및 문서 계약 테스트를 추가했다.

Changes

TLS 설정 보안 경계

Layer / File(s) Summary
정확한 타입 검증과 보안 테스트
src/egressweave/tls.py, tests/test_tls_configuration_exact_type.py
create_egress_ssl_contextTLSConfiguration 서브클래스를 TypeError로 거부한다. 서브클래스의 create_ssl_context()는 호출되지 않는다.
정책 문서와 문서 계약 테스트
docs/research/tls-configuration.md, CHANGELOG.md, tests/test_tls_configuration_exact_type_documentation.py
정확한 타입 경계, 마이그레이션 지침, 유지되는 TLS 설정, CWE-295 참고문헌을 문서화하고 필수 내용을 검증한다.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related issues

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 제목은 통합된 main에서 TLSConfiguration의 정확한 타입 경계를 적용하는 보안 변경을 명확히 요약합니다.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch security/reconstruct-exact-tls-dd0324

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot 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.

🧹 Nitpick comments (2)
tests/test_tls_configuration_exact_type_documentation.py (1)

17-25: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

문서 계약에서 핵심 보안 문구를 연속된 구문으로 검증하세요.

첫 번째 테스트는 "before""create_ssl_context"를 독립적으로 검사합니다. 두 단어가 서로 다른 문장에 있어도 테스트가 통과할 수 있습니다.

두 번째 테스트는 exact TLSConfiguration typesubclass만 검사합니다. before TLS context creation 또는 인증서·호스트명 검증 문구가 삭제되어도 통과할 수 있습니다.

문서 계약을 보존하려면 현재 보안 문장을 연속된 문자열로 검증하세요.

권장 검증 변경
-    assert "exact `TLSConfiguration` type" in guide
-    assert "subclass" in guide
-    assert "before" in guide and "create_ssl_context" in guide
-    assert "hostname verification" in guide
-    assert "certificate verification" in guide
+    assert (
+        "The public context helper accepts only the exact `TLSConfiguration` type "
+        "before it invokes `create_ssl_context()`."
+    ) in guide
+    assert (
+        "a context that disables hostname verification or certificate verification"
+    ) in guide

-    assert "exact `TLSConfiguration` type" in changelog
-    assert "subclass" in changelog
+    assert (
+        "Require the exact `TLSConfiguration` type before TLS context creation."
+    ) in changelog
+    assert "A subclass can no longer override `create_ssl_context()`" in changelog
+    assert "context that disables hostname or certificate verification" in changelog

Also applies to: 28-34

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/test_tls_configuration_exact_type_documentation.py` around lines 17 -
25, Update the assertions in
test_tls_guide_requires_exact_configuration_type_before_dispatch and the related
second test to validate the complete security wording as contiguous normalized
phrases, including exact TLSConfiguration type, subclass dispatch, the
requirement occurring before create_ssl_context/TLS context creation, and both
hostname and certificate verification. Remove separate word-presence checks
where they allow reordered or unrelated sentences to pass.
tests/test_tls_configuration_exact_type.py (1)

12-28: 🔒 Security & Privacy | 🔵 Trivial | ⚡ Quick win

서브클래스 메서드의 호출 자체를 검증하세요.

현재 create_ssl_context()는 안전하지 않은 컨텍스트를 반환합니다. 헬퍼가 이 메서드를 먼저 호출한 후 TypeError를 발생시켜도 현재 테스트는 통과합니다. 그러면 테스트가 TypeError의 발생 시점까지 검증하지 못합니다.

메서드가 호출되면 실패하도록 변경하거나 호출 플래그를 기록하세요. 호출 플래그가 거짓인지도 검증하세요.

검증 강화 예시
 class _VerificationDisablingTLSConfiguration(TLSConfiguration):
-    """Return an insecure context if subclass-controlled dispatch is allowed."""
+    """Fail if subclass-controlled dispatch occurs."""

     def create_ssl_context(self) -> ssl.SSLContext:
-        """Build a context that deliberately violates the EgressWeave TLS contract."""
-        context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
-        context.check_hostname = False
-        context.verify_mode = ssl.CERT_NONE
-        return context
+        raise AssertionError("subclass dispatch must not occur")
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/test_tls_configuration_exact_type.py` around lines 12 - 28, Strengthen
test_context_helper_rejects_tls_configuration_subclasses_before_dispatch by
tracking whether _VerificationDisablingTLSConfiguration.create_ssl_context was
invoked, making the override fail or set a call flag when entered, and asserting
the flag remains false after the expected TypeError. Keep the test focused on
proving rejection occurs before subclass-controlled dispatch.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@tests/test_tls_configuration_exact_type_documentation.py`:
- Around line 17-25: Update the assertions in
test_tls_guide_requires_exact_configuration_type_before_dispatch and the related
second test to validate the complete security wording as contiguous normalized
phrases, including exact TLSConfiguration type, subclass dispatch, the
requirement occurring before create_ssl_context/TLS context creation, and both
hostname and certificate verification. Remove separate word-presence checks
where they allow reordered or unrelated sentences to pass.

In `@tests/test_tls_configuration_exact_type.py`:
- Around line 12-28: Strengthen
test_context_helper_rejects_tls_configuration_subclasses_before_dispatch by
tracking whether _VerificationDisablingTLSConfiguration.create_ssl_context was
invoked, making the override fail or set a call flag when entered, and asserting
the flag remains false after the expected TypeError. Keep the test focused on
proving rejection occurs before subclass-controlled dispatch.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 8c23eaa9-3bcc-4fca-bfdf-d6f6ca3c5bd5

📥 Commits

Reviewing files that changed from the base of the PR and between dd0324c and 1db2a43.

📒 Files selected for processing (5)
  • CHANGELOG.md
  • docs/research/tls-configuration.md
  • src/egressweave/tls.py
  • tests/test_tls_configuration_exact_type.py
  • tests/test_tls_configuration_exact_type_documentation.py

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.

1 participant