Skip to content

Commit 3bfce6f

Browse files
committed
chore: update outdated comment
Update outdated comment regarding PHC format attack.
1 parent fc74353 commit 3bfce6f

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

authorization/storage.go

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -81,18 +81,14 @@ into BoltDB. Raw tokens are not stored.
8181
To verify tokens when hashed tokens are enabled, the presented token's hash is calculated and used
8282
for token index lookup. The rest of the authorization flow is unchanged.
8383
84-
To verify tokens when hashed tokens are disabled, the an attempt is made to parse the presented token as
85-
PHC. If the parse succeeds, the access is denied. This prevents an attack described below. After this check,
86-
the presented raw token is used to lookup the token in the raw token index. If found, authorization proceeds
87-
as normal. Otherwise, the token hash is calculated and used to lookup the token in the hashed token index.
88-
A second check is then done on the authorization record token or token hash matches the presented token.
89-
If found, authorization proceeds as normal.
90-
9184
The hashed token index is separate from the raw token index. Newer versions also verify that the token
9285
is not a valid PHC string before starting authorization. This prevents the following attack:
9386
1. Hashed token is extracted from BoltDB.
9487
2. Token hashing is disabled.
9588
3. The hashed token is presented to the API, which will misinterpret it as a raw token and allow access.
89+
This attack is not possible due to the independent indices for raw and hashed tokens. When the hashed token
90+
is presented, it will not match any tokens in the raw index. The hashed token will then be hashed again
91+
before lookup in the hashed index, and will not match any tokens.
9692
9793
The token hashing algorithm is SHA-512. This provides a good level of security and is allowed by FIPS 140-2.
9894
Because the token hashes must be useable as index lookups, salted password hashes (e.g. bcrypt, PBKDF2, Argon)

0 commit comments

Comments
 (0)