oliver-zehentleitner / maity

clean-up: hub-wide: the token-digest copies outside auth (forge_links._hash, register_page) use codes.digest

Sign in to report

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 :56 and :70 for the OAuth state_hash).
  • routes/register_page.py:142, inline: it hashes the nonce from the link and compares it with the nonce_hash written at registration_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 delete forge_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:81 and routes/register_page.py:142 change together.

Covered elsewhere

  • auth/device_codes.py:52 digest, auth/email_links.py:26 digest, auth/second_factor_reset.py:43 _nonce_id, auth/caller.py:147 session_id_hash, auth/sessions.py:410, :429, registration_mail.py:81 and account_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).