fix(peer): verify inbound delegation chain once - #120
Open
devdiv07 wants to merge 1 commit into
Open
Conversation
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Signed-off-by: devdiv07 <sarvenclothing@gmail.com>
imran-siddique
self-requested a review
August 18, 2026 18:57
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Avoid verifying the same delegation chain twice in
handle_peer_request().The inbound path now verifies the chain once, including
trusted_root_issuers,performs holder binding, and then intersects the already-verified leaf scope
with local policy directly.
effective_scope()remains unchanged and continues to verify defensively forcallers that have not already verified their chain.
Closes #105.
Why
handle_peer_request()previously calledverify_chain()directly beforeholder proof and then called
effective_scope(), which performs anotherverify_chain()internally.That meant every successful inbound request repeated the Ed25519 signature
verification, chain continuity checks, scope attenuation walk, depth checks,
and trusted-root validation.
The first verification cannot simply be removed: holder binding must only
challenge control of
chain[-1].subjectafter the chain establishes that thesubject was genuinely delegated.
The second verification is redundant because the exact same chain, depth limit,
and trusted-root set have already been validated before holder proof.
This implements option 1 from #105: keep
effective_scope()defensive for itsindependent/public callers while avoiding it on the already-verified inbound
pipeline.
The ordering remains:
Security impact
No authorization or delegation checks are removed from the inbound request
boundary.
handle_peer_request()still performsverify_chain()before holder proof,including the configured
trusted_root_issuerscheck. Scope intersection onlyoccurs after that verification succeeds.
A dedicated regression also confirms that a valid holder-proved request rooted
outside
trusted_root_issuersis still rejected.effective_scope()itself is unchanged, so other callers such asenforce_peer_call()continue to receive defensive chain verification.The change removes only the second verification of an already-verified chain.
Test plan
pytest tests/unit -qruff check src/ tests/ruff format --check src/ tests/mypy src/ca2a_runtime/ src/ca2a_verify/bandit -r src/ -c pyproject.tomlRegression coverage added for:
verify_chain()invocation during a successfulhandle_peer_request(), while wrapping and executing the real verifier;trusted_root_issuers.The exact-once regression was also run against the pre-change implementation
and failed with:
assert 2 == 1confirming that it detects the redundant verification removed by this change.
DCO sign-off
Developer Certificate of Origin (https://developercertificate.org).