Page MenuHomePhabricator

Don't use "phutil_hashes_are_identical()" to compare public keys
ClosedPublic

Authored by epriestley on Oct 29 2019, 1:31 AM.
Tags
None
Referenced Files
F18100777: D20875.id.diff
Sat, Aug 9, 12:04 PM
F18096292: D20875.id49765.diff
Fri, Aug 8, 6:03 AM
F17942096: D20875.id.diff
Thu, Jul 31, 6:15 AM
F17923416: D20875.diff
Jul 30 2025, 8:11 AM
F17822339: D20875.id.diff
Jul 26 2025, 3:38 AM
F17770276: D20875.diff
Jul 23 2025, 9:26 AM
Unknown Object (File)
Jul 2 2025, 11:34 PM
Unknown Object (File)
Jul 2 2025, 12:50 AM
Subscribers
Tokens
"Y So Serious" token, awarded by leoluk.

Details

Summary

Ref T13436. There's no real security value to doing this comparison, it just wards off evil "security researchers" who get upset if you ever compare two strings with a non-constant-time algorithm.

In practice, SSH public keys are pretty long, pretty public, and have pretty similar lengths. This leads to a relatively large amount of work to do constant-time comparisons on them (we frequently can't abort early after identifying differing string length).

Test Plan

Ran bin/ssh-auth --sshd-key ... on secure with ~1K keys, saw runtime drop by ~50% (~400ms to ~200ms) with ===.

Diff Detail

Repository
rP Phabricator
Lint
Lint Not Applicable
Unit
Tests Not Applicable