Class DecoyPasswordHash
- Namespace
- MailFathom.Infrastructure.Security.Passwords
- Assembly
- MailFathom.Infrastructure.dll
The stored record a username this deployment holds nothing for is compared against.
public sealed class DecoyPasswordHash
- Inheritance
-
DecoyPasswordHash
- Inherited Members
Remarks
A username that resolves nothing would otherwise be refused in the time of one indexed read, while a username that resolves something costs a deliberately expensive derivation on top of it — and a client timing the difference would be enumerating the accounts this deployment holds. Verifying against this record instead makes both answers cost the same.
It is a type of its own so that it can be derived once for the process rather than once per request. The authenticator that uses it reads the credential store through the request's own context and is therefore scoped; deriving the decoy in that constructor would spend a full derivation on every request before anything had been checked, which is the cost the rate limiter exists to bound and would hand an unauthenticated caller a way around it.
What the record is made of belongs to HashDecoy() rather than to this type, because the work parameters are what the cost is: only the adapter knows the weakest parameters any record it would still accept may carry, and a decoy derived at today's parameters would answer slower than an older stored record the first time they are raised. The password behind it is random and never leaves that call, so nothing can present the credential it would accept.
Constructors
- DecoyPasswordHash(IPasswordHasher)
Derives the record, once.
Properties
- Value
The stored representation, in the same form a provisioned credential holds.