Not clearing hex-decoded variable after usage in Authentication
The authentication code zeroes the hex-encoded validator string from memory after decoding it, but leaves the decoded binary value in memory. An attacker with the ability to read process memory could recover the sensitive validator value that the code intended to erase.
- Disclosed after 50 days
All the sensitive information variables are zeroed from memory, expect the hex2bin value of "validator".
$stored = \Sodium\hex2bin($record[$f['validator']]);
\Sodium\memzero($record[$f['validator']]);
if (!\hash_equals($stored, $val)) {
throw new LongTermAuthAlert(
\trk('errors.security.invalid_persistent_token')
);
}
$userID = (int) $record[$f['userid']];
$_SESSION['session_canary'] = $this->db->cell(
'SELECT session_canary FROM airship_users WHERE userid = ?',
$userID
);
return $userID;
The encoded value of "validator" is zeroed from memory, but the decoded version is not. The value of $stored is not returned anywhere, so it should be zeroed from memory.
Note. As the exception throw stops the flow, it should also be cleared when the hash doesn't equal 👍
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the code calls the memory-zeroing function on the encoded input but not on the decoded output variable, and the exception path also skips clearing it.
Impact
The decoded validator value remains in memory although the code intended it to be erased.
What the attacker needed
None stated in the report
The fix
The decoded value should also be zeroed from memory after use, including on the path where the hash comparison fails and an exception is thrown.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
Some programs try to wipe secret values from memory once they are done with them, so that other software or an attacker cannot read them later. Here, the code wiped the scrambled (hex-encoded) form of a secret but forgot to wipe the unscrambled form it had just created. That leftover copy stays in memory and could be read by someone who can inspect the program's memory.
What is Info disclosure?
Data the application should keep private (personal data, internal details, other users' records) reaches someone it should not.