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 potential side-channel timing attack issue #1375

Merged
merged 4 commits into from
Apr 24, 2024

Conversation

scott-xu
Copy link
Collaborator

The PR fixes a potential side-channel timing attack issue when verify HMAC and verify DigitalSignature.

@Rob-Hague
Copy link
Collaborator

What's the attack? The signature verification does not involve any private data, and in both cases we will drop the connection once the verification fails. What am I missing?

@scott-xu
Copy link
Collaborator Author

AFAK, the timing attack is based on enumerous failures.

@scott-xu
Copy link
Collaborator Author

https://github.com/openssh/openssh-portable/blob/88351eca17dcc55189991ba60e50819b6d4193c1/mac.c#L222
FYI. OpenSSH also prevents timing attack when verify MAC.

@scott-xu scott-xu self-assigned this Apr 17, 2024
@scott-xu
Copy link
Collaborator Author

I come up with this PR when read Chaos.Nacl project.
The readme.md says: (forget the typos 🙄)

public static bool ContantTimeEquals(byte[] x, byte[] y)

Checks if the contents of the two arrays are the same and returns truie if they are equal.
Throws an expection if their lengthes differ.

The runtime of this method does not depend on the contents of the arrays. Using constant time prevents timing attacks that allow an attacker to learn if the arrays have a common prefix. It is important to use such a constant time comparison when verifying MACs.

Copy link
Collaborator

@Rob-Hague Rob-Hague left a comment

Choose a reason for hiding this comment

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

Ok 🤷

@Rob-Hague Rob-Hague merged commit ce45129 into sshnet:develop Apr 24, 2024
1 check passed
@scott-xu scott-xu deleted the timing-attack branch April 24, 2024 23:05
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.

2 participants