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
F17472498: D20875.diff
Wed, Jul 2, 12:50 AM
Unknown Object (File)
Thu, Jun 5, 4:43 PM
Unknown Object (File)
May 27 2025, 6:11 AM
Unknown Object (File)
May 26 2025, 7:35 AM
Unknown Object (File)
May 9 2025, 4:46 PM
Unknown Object (File)
Apr 30 2025, 5:31 AM
Unknown Object (File)
Apr 29 2025, 4:45 PM
Unknown Object (File)
Apr 26 2025, 6:21 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
Branch
ssh-auth-3
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 23593
Build 32429: Run Core Tests
Build 32428: arc lint + arc unit