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
F15419772: D20875.diff
Fri, Mar 21, 8:48 AM
F15419687: D20875.id49765.diff
Fri, Mar 21, 8:03 AM
F15387563: D20875.id49764.diff
Sat, Mar 15, 2:36 AM
F15379262: D20875.diff
Thu, Mar 13, 7:52 PM
F15343595: D20875.id49765.diff
Sun, Mar 9, 11:46 PM
F15335876: D20875.id49765.diff
Sat, Mar 8, 5:39 PM
F15334374: D20875.id49764.diff
Sat, Mar 8, 8:36 AM
Unknown Object (File)
Sun, Mar 2, 1:55 PM
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