Repository navigation
Reject identity and small order peer ephemeral public keys - #503
Open
akasakariko wants to merge 1 commit into
Open
akasakariko wants to merge 1 commit into
akasakariko wants to merge 1 commit into
Conversation
X25519 against the identity point or a small order point yields an all-zero shared secret, which was fed into the key schedule without any check, as reported in issue cloudflare#502 Reject every non contributory Diffie-Hellman result that involves a peer supplied ephemeral public key, as required by section 6 of RFC 7748, and return a new InvalidPublicKey error instead of continuing the handshake The check covers the anonymous handshake parsing, the handshake initiation handling and both Diffie-Hellman computations of the handshake response handling, and the regression tests cover the identity point and the small order points in both handshake directions
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.
Fixes #502
Problem
The peer ephemeral public key received during the handshake is used in a Diffie-Hellman exchange without any check on the result
X25519 against the identity point or a small order point produces an all-zero shared secret, which was mixed into the key schedule instead of aborting the handshake, contrary to section 6 of RFC 7748
Fix
Add a check that rejects non contributory Diffie-Hellman results and return a new WireGuardError::InvalidPublicKey variant
The check is applied to every exchange that involves a peer supplied ephemeral public key
Peer static public keys that come from the local configuration are left unchanged
Tests
New unit tests in the handshake module cover the identity point and the small order point encodings in both handshake directions
The tests assert that the handshake fails with InvalidPublicKey, and they fail on the parent commit because the handshake is accepted there
Verification
The root integration tests were not run locally because they need a tun device and root privileges