oliver-zehentleitner / maity
clean-up: hub-wide: the token-digest copies outside auth (forge_links._hash, register_page) use codes.digest
tsk-cqv228n1q0ns Open
From the clean-up audit tsk-hgnbapyw7hnh (finding A1-2), read at 80647565. Line numbers are at that SHA; check them against current main first. Paths are under hub/src/maity_hub/.
This card is small on purpose: tsk-j967n09yz6ps item 3 already holds most of A1-2. What is left are two sites, plus one found while grepping. It could also be folded into tsk-j967n09yz6ps item 3 if its holder agrees.
What is wrong
codes.digest (codes.py:13-14) is the hub's "store only the hash" helper for single-use tokens. These places still write the same sha256-hex one-liner themselves.
Sites
forge_links.py:41-42_hash(used at:56and:70for the OAuthstate_hash).routes/register_page.py:142, inline: it hashes the nonce from the link and compares it with thenonce_hashwritten atregistration_mail.py:81. The writer is in tsk-j967n09yz6ps item 3; the reader is not, so the pair should switch in the same PR.auth/credentials.py:42: the credential secret hash is the same expression (found while grepping; not in the audit). Include it only if the auth card's holder agrees that it belongs to the same rule.
Proposal
- Use
codes.digest(or whatever name tsk-j967n09yz6ps item 3 settles on) at these sites and deleteforge_links._hash.
Effort and risk
- Effort S. Risk none: the output is byte-identical for the ASCII tokens and nonces hashed here.
Order
- After, or in the same PR as, tsk-j967n09yz6ps item 3, so that both use the helper name it picks and
registration_mail.py:81androutes/register_page.py:142change together.
Covered elsewhere
auth/device_codes.py:52digest,auth/email_links.py:26digest,auth/second_factor_reset.py:43_nonce_id,auth/caller.py:147session_id_hash,auth/sessions.py:410,:429,registration_mail.py:81andaccount_deletion.py:210-211_digest: tsk-j967n09yz6ps item 3.- The forge cache keys built from a token digest (
forge.py:476,:505,:594,forge_access.py:65): tsk-e77g3nhqqnex item 5. They are cache keys, not stored hashes. - Searched: forge_links, register_page.
Effort sum: S (1 point).