Skip to content

Fix UB in Windows verifier EKU handling #127

Merged
ctz merged 2 commits into
mainfrom
fix-windows-eku-ub
Aug 23, 2024
Merged

Fix UB in Windows verifier EKU handling #127
ctz merged 2 commits into
mainfrom
fix-windows-eku-ub

Conversation

@complexspaces

@complexspaces complexspaces commented Aug 23, 2024

Copy link
Copy Markdown
Collaborator

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

complexspaces commented Aug 23, 2024

Copy link
Copy Markdown
Collaborator Author

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

Comment thread rustls-platform-verifier/src/verification/mod.rs
Comment thread rustls-platform-verifier/src/verification/mod.rs
/// - 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
Copy Markdown
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
Copy Markdown
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