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
F14076946: D20875.diff
Thu, Nov 21, 8:36 PM
Unknown Object (File)
Thu, Nov 21, 3:30 AM
Unknown Object (File)
Tue, Nov 19, 1:40 PM
Unknown Object (File)
Sat, Nov 2, 8:46 PM
Unknown Object (File)
Tue, Oct 29, 8:46 AM
Unknown Object (File)
Oct 19 2024, 12:52 PM
Unknown Object (File)
Sep 28 2024, 2:12 AM
Unknown Object (File)
Sep 28 2024, 2:10 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