Skip to content

Add nc testcases for an empty permittedSubtrees - #658

Merged
alex merged 2 commits into
C2SP:mainfrom
avalyset:nc/empty-permitted-subtrees
Sep 1, 2026
Merged

Add nc testcases for an empty permittedSubtrees#658
alex merged 2 commits into
C2SP:mainfrom
avalyset:nc/empty-permitted-subtrees

Conversation

@avalyset

@avalyset avalyset commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Adds two rfc5280::nc testcases for a permittedSubtrees that is present but empty. webpki::nc::intermediate-permitted-excluded-subtrees-both-empty-sequences already covers both subtree fields being empty, which an implementation can reject by treating the whole extension as degenerate. Pairing an empty permittedSubtrees with a non-empty excludedSubtrees closes that shortcut, since the extension still carries a constraint to enforce. permitted-empty-sequence-excluded-nonempty is that chain and must be rejected, because an empty permitted set admits no names. permitted-nonempty-excluded-nonempty is the same chain with a non-empty permittedSubtrees and must validate, which separates accepting the empty case from failing both for an unrelated reason. Split out from pyca/cryptography#15560, where @alex preferred this be covered as an x509-limbo testcase rather than against the Rust APIs; pyca/cryptography 50.0.1 accepts the invalid case today.

RFC 5280 4.2.1.10 gives GeneralSubtrees as SEQUENCE SIZE (1..MAX), so a
present-but-empty permittedSubtrees is malformed. Independently, 6.1.4 (g)(1)
intersects the permitted state with the extension's permittedSubtrees, and
6.1.3 (b) requires each name to fall inside the result, so an empty
permittedSubtrees admits no names at all.

webpki::nc::intermediate-permitted-excluded-subtrees-both-empty-sequences
already covers the case where both subtree fields are empty. This adds the
case where only permittedSubtrees is empty, alongside a control chain that
differs only in that field being non-empty.

@cpu cpu left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The premise and test case seem OK to me and produce the results i'd expect downstream in rustls-webpki. I think ideally the PR description and comments could use some human editing.

Comment thread limbo/testcases/rfc5280/nc.py
Match the length and structure of the pre-existing testcases in the
file: chain block, then what the certificate carries. Drops the
cross-reference between the paired cases and the RFC 6.1.x walkthrough.

No functional change; limbo.json is updated only in the two
description fields.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@avalyset

avalyset commented Sep 1, 2026

Copy link
Copy Markdown
Contributor Author

Edited both docstrings down. I measured the existing ones in the file first — median 9 lines, max 12 without an RFC block quote — and the new ones now sit at 14 and 10, with the same structure: chain block, then what the certificate carries. The cross-reference to the paired testcase is gone; the names carry that. The PR description is rewritten too. Code is unchanged, and the harness gives identical results before and after.

@alex
alex merged commit 21cc053 into C2SP:main Sep 1, 2026
11 checks passed
avalyset added a commit to avalyset/cryptography that referenced this pull request Sep 2, 2026
C2SP/x509-limbo#658 landed, so
rfc5280::nc::permitted-empty-sequence-excluded-nonempty and
rfc5280::nc::permitted-nonempty-excluded-nonempty cover these two cases.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
avalyset added a commit to avalyset/cryptography that referenced this pull request Sep 2, 2026
CI pins x509-limbo to 972626160c26b45426bbd8c935a605219bd93207
(2026-08-27), which predates C2SP/x509-limbo#658, so the new cases are
not in the vectors CI runs against yet. Without this test
extension.rs:754-756 is uncovered and the coverage gate fails.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
avalyset pushed a commit to avalyset/cryptography that referenced this pull request Sep 2, 2026
Cherry-picked from pyca#15580 at Alex's suggestion on pyca#15560: the
new pin 21cc053 is the merge commit for C2SP/x509-limbo#658, so the two new
name-constraint testcases are in the vectors CI runs.

(cherry picked from commit 319a8a4)

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@woodruffw

Copy link
Copy Markdown
Collaborator

Sorry, only catching up to this today: I suspect like #660 these need a pedantic-rfc5280 or similar flag, since no validator appears to conform with it ATM:

https://x509-limbo.com/testcases/rfc5280/#rfc5280ncpermitted-nonempty-excluded-nonempty

and

https://x509-limbo.com/testcases/rfc5280/#rfc5280ncpermitted-nonempty-excluded-nonempty

avalyset added a commit to avalyset/x509-limbo that referenced this pull request Sep 2, 2026
Mirrors permitted-empty-sequence-excluded-nonempty from C2SP#658: a non-empty
permittedSubtrees alongside an excludedSubtrees that is present but empty.
Both shapes are rejected by RFC 5280 4.2.1.10, but only the first had a
vector behind it.

limbo.json carries only the new entry; the existing testcases are untouched.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@avalyset

avalyset commented Sep 2, 2026

Copy link
Copy Markdown
Contributor Author

Noting one downstream consequence of #661: with pedantic-rfc5280 on permitted-nonempty-excluded-nonempty, that case is now skipped in pyca/cryptography — https://github.com/pyca/cryptography/blob/5936b461718024e377713d875b6c59fe5a5df3f5/tests/x509/verification/test_limbo.py#L117-L123

It's the positive control of the pair: it verifies that a valid chain is accepted. With it skipped, nothing in limbo runs there to catch the FAILURE case passing for the wrong reason.

It's also the first of the 19 pedantic-flagged cases to expect SUCCESS; the other 18 are FAILURE.

@woodruffw

Copy link
Copy Markdown
Collaborator

I guess there's no harm to removing the pedantic flag in the positive case. But it seems very marginal to me.

@avalyset Going forwards, please engage with us directly. It's not clear the LLM you're using has a full grasp of the problem or solution space here.

@avalyset

avalyset commented Sep 2, 2026

Copy link
Copy Markdown
Contributor Author

Fair — I'll leave it as is then. And understood.

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.

4 participants