Skip to content

Commit 4a53fc3

Browse files
author
epriestley
committedOct 29, 2019
Don't use "phutil_hashes_are_identical()" to compare public keys
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 `===`. Maniphest Tasks: T13436 Differential Revision: https://secure.phabricator.com/D20875
1 parent 24f771c commit 4a53fc3

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed
 

‎scripts/ssh/ssh-auth.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@
109109
if ($sshd_key !== null) {
110110
$matches = array();
111111
foreach ($authstruct['keys'] as $key => $key_struct) {
112-
if (phutil_hashes_are_identical($key_struct['key'], $sshd_key)) {
112+
if ($key_struct['key'] === $sshd_key) {
113113
$matches[$key] = $key_struct;
114114
}
115115
}

0 commit comments

Comments
 (0)
Failed to load comments.