Skip to content

fix(x509svid): reject leaf SPIFFE IDs with root path#375

Open
maxlambrecht wants to merge 2 commits into
spiffe:mainfrom
maxlambrecht:fix/x509svid-reject-root-path-spiffe-id
Open

fix(x509svid): reject leaf SPIFFE IDs with root path#375
maxlambrecht wants to merge 2 commits into
spiffe:mainfrom
maxlambrecht:fix/x509svid-reject-root-path-spiffe-id

Conversation

@maxlambrecht
Copy link
Copy Markdown
Member

This change updates x509svid.Parse and x509svid.ParseRaw to reject leaf certificates whose SPIFFE ID has a root/empty path (for example, spiffe://example.org). This aligns with the SPIFFE X.509-SVID spec (SPIFFE spec Section 3.1 "Leaf Certificates"), which requires that leaf certificate SPIFFE IDs MUST have a non-root path component.

Copy link
Copy Markdown
Contributor

@strideynet strideynet left a comment

Choose a reason for hiding this comment

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

Implementation looks good and makes sense to me as per the spec.

However, I do worry that this could be a significant breaking change for those consuming a non-spec compliant implementation of SPIFFE. That being said, I don't think I have come across any implementations that are issuing root path SVIDs.

Do we need to at least flag this in the change-log as breaking? Is there any prior art for how we've handled changes in the SDK that could be breaking for non-compliant implementations of SPIFFE.

Copy link
Copy Markdown
Member

@amartinezfayo amartinezfayo left a comment

Choose a reason for hiding this comment

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

Thanks for the PR, @maxlambrecht. I also agree that the spec is clear here: Section 3.1 says leaf certificate SPIFFE IDs MUST have a non-root path component, so this is the right thing to do.

Regarding the breaking change concern that Noah raised, I don't think that we have a precedent for explicitly flagging breaking changes. I think we should document this clearly in the changelog under "Changed" with wording that makes it obvious this is now enforced, something like: "x509svid.Parse and x509svid.ParseRaw now reject leaf certificates with root-path SPIFFE IDs, in alignment with the X.509-SVID specification (Section 3.1)."

In practice, I think the risk is low. SPIRE and any spec-compliant SPIFFE implementation will not mint leaf SVIDs with root-path SPIFFE IDs, so this would only affect consumers using a non-compliant implementation as Noah pointed out.

Comment thread svid/x509svid/svid.go Outdated
return nil, fmt.Errorf("cannot get leaf certificate SPIFFE ID: %v", err)
}

if leafID.Path() == "" || leafID.Path() == "/" {
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.

nit: I think the leafID.Path() == "/" check is unnecessary here since spiffeid.FromURI already rejects URIs with a trailing slash like spiffe://example.org/. So Path() can never return "/" on a successfully parsed ID. Not harmful, but we could simplify this to just check for an empty path.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

done

Signed-off-by: Max Lambrecht <maxlambrecht@gmail.com>
@maxlambrecht maxlambrecht force-pushed the fix/x509svid-reject-root-path-spiffe-id branch from a18d3f9 to 1381fdc Compare April 18, 2026 20:02
Signed-off-by: Max Lambrecht <maxlambrecht@gmail.com>
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.

3 participants