Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix UB in Windows verifier EKU handling #127

Merged
merged 2 commits into from
Aug 23, 2024
Merged

Fix UB in Windows verifier EKU handling #127

merged 2 commits into from
Aug 23, 2024

Conversation

complexspaces
Copy link
Collaborator

@complexspaces complexspaces commented Aug 23, 2024

This PR implements two fixes in the Windows verifier to fix UB and future-UB:

  • Properly NULL-terminate the EKU strings we pass in.
  • Only pass in a thin pointer containing the string data to Windows, not the slice's fat pointer.

See the linked issue for a more detailed analysis if you're curious why this was never problematic before.

Closes #126

Additionally, ensure we only pass thin string pointers, not fat ones
@complexspaces complexspaces requested a review from ctz August 23, 2024 04:28
@complexspaces complexspaces self-assigned this Aug 23, 2024
@complexspaces complexspaces added bug Something isn't working O-Windows Work related to the Windows verifier implementation labels Aug 23, 2024
@complexspaces
Copy link
Collaborator Author

complexspaces commented Aug 23, 2024

@ctz I meant to open a PR against the rel-0.1 branch with this backport since its UB/an important bugfix but I mistakenly pushed this commit to the branch instead. I apologize for that. Please make sure it matches this for diligence as part of your review.

@ctz ctz merged commit 626e33c into main Aug 23, 2024
19 checks passed
@@ -82,8 +82,11 @@ fn invalid_certificate(reason: impl Into<String>) -> rustls::Error {
/// - id-kp-serverAuth
// TODO: Chromium also allows for `OID_ANY_EKU` on Android.
#[cfg(target_os = "windows")]
// XXX: Windows requires that we NUL terminate EKU strings and we want to make sure that only the
Copy link
Member

Choose a reason for hiding this comment

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

I think this sentence is missing a word. Otherwise LGTM!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Oops, good catch. I'll fix this when migrating to windows_sys.

@complexspaces complexspaces deleted the fix-windows-eku-ub branch August 23, 2024 22:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working O-Windows Work related to the Windows verifier implementation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TLS Runtime Issues for GitHub Artifacts built on Windows
3 participants