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
F19939019: D20875.id49765.diff
Tue, Apr 14, 9:02 AM
F19900698: D20875.id.diff
Mon, Mar 30, 5:47 AM
F19810442: D20875.diff
Mar 3 2026, 7:42 PM
F19784487: D20875.id49764.diff
Feb 24 2026, 8:06 PM
F19507550: D20875.diff
Jan 9 2026, 9:36 PM
F18990771: D20875.diff
Nov 18 2025, 7:45 PM
F18855504: D20875.id.diff
Nov 1 2025, 5:27 AM
F18854240: D20875.id49764.diff
Oct 31 2025, 10:41 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