Skip to content

sasl-otp: use constant-time hash comparison#259

Closed
rootvector2 wants to merge 1 commit intodovecot:mainfrom
rootvector2:security/otp-constant-time-compare
Closed

sasl-otp: use constant-time hash comparison#259
rootvector2 wants to merge 1 commit intodovecot:mainfrom
rootvector2:security/otp-constant-time-compare

Conversation

@rootvector2
Copy link
Contributor

This PR fixes a timing side-channel vulnerability in the OTP SASL
authentication mechanism.

The OTP verification logic used memcmp() to compare cryptographic
hash values. Because memcmp() exits on the first mismatch, execution
time varied depending on the number of matching prefix bytes, leaking
information through observable timing differences.

The Dovecot codebase already provides mem_equals_timing_safe() and
uses it for other authentication mechanisms (e.g., APOP, CRAM-MD5,
SCRAM, password verification). This patch replaces memcmp() with
mem_equals_timing_safe() in the OTP mechanism to ensure constant-time
comparison.

@cmouse
Copy link
Contributor

cmouse commented Jan 10, 2026

Thank you for the pull request. We'll take a look.

@rootvector2
Copy link
Contributor Author

Hi Team

@sirainen
Copy link
Contributor

Merged as 9124705

@sirainen sirainen closed this Feb 12, 2026
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