Skip to main content
Menu
Advisories

Non-constant-time credential comparison enables timing attacks

GHSA-JJ2R-4MGJ-F964Published Updated GitHub

Description

Credential.Check in internal/conf/credential.go compared a SHA256-hashed credential and a plaintext credential against the caller-supplied guess using Go's built-in == string comparison operator. This operator short-circuits on the first mismatched byte, so the time taken to reject a guess depends on how many leading bytes it shares with the stored secret. Since an attacker fully controls one operand of the comparison, repeated measurements of response time can in principle be used to recover the secret byte by byte, particularly for the plaintext credential path where the comparison is made directly against the raw secret.

The issue was fixed by replacing both == comparisons with subtle.ConstantTimeCompare, which runs in time independent of where (or whether) the two inputs differ. The fix was merged in PR #5961.

Affected versions

References

GitHub · bluenviron/mediamtx