Use proquints for recovery codes #41379
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The
github.com/sethvargo/go-diceware
library that we use to generate friendly recovery codes unconditionally causes a ~1.5MB allocation at runtime, since it uses a map in avar
; while this is a relatively small cost for a long runningteleport
process, this cost is incurred even by binaries that are intended to be much leaner (such astsh
ortbot
) and that might end up running in multiple copies (hundreds or thousands) on a given machine. That fixed cost also happens on every new re-execution ofteleport
to handle shell execution, port forwarding and various other bits of functionality that must happen in a separate process - which is pretty silly, considering that most of those are not in the auth service, which is the only component that needs to generate recovery codes.Adding to the aforementioned issue, #5685 is still very much a problem, and trimming one more dependency is worth in and of itself.
This PR thus proposes to change the recovery code generation to use proquints (PRO-nouncable QUINT-uplets of alternating unambiguous consonants and vowels, arXiv:0901.4016 [cs.SE]), which we've been successfully using in Cloud to generate random pronounceable identifiers for a while now. As a bonus, this makes the recovery codes slightly less guessable (from ~103 to 128 bits of entropy each).
Example of the account recovery UI after the change:
Existing recovery codes are stored hashed in the user
recoverycodes
resource, and will continue working as normal after this change.