Skip to content

Used authenticator codes: three small things left after #58 #59

Open

Description

@Madraka

From the audit of #58 (workers/auth/used-codes.ts). None of them is a way in; each makes the control easier to trust or to operate.

Done when

  • A write that fails for another reason is told to the operator. Every failure of the claim's write is answered as a wrong code, which is the safe side, but nothing is logged: if the database refuses writes, every person sees "Invalid code" and the log is silent. One log line (never the code, never the key) when the failure is not the key being there already.
  • The key says what it is for. The claim's key is an HMAC under the instance secret over the person and the code. The same secret signs other things; put a fixed label of this use into what is signed, so that a value made here can never mean something elsewhere.
  • The module says who removes old claims, and a test holds it. The comment says a claim "is then replaced", which is true only when the same person meets the same six digits again. What removes the rest is the sign-in library's own clean-up of expired rows whenever it looks one up (read in the installed version; the option that turns it off is not set). Say that, and hold it with a test that fails if the clean-up stops, since an option or an update could end it silently.
  • The two minutes follow the library's settings. USED_CODE_SECONDS is right for a period of 30 seconds and a window of one step. A test reads the configured period and window and fails when they no longer fit.

Activity

  1. added
    enhancementNew feature or request
    securityTouches a trust boundary. A vulnerability is never reported in an issue: see SECURITY.md
    area: authSign-in, sessions, roles, memberships, keys
    on Nov 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: authSign-in, sessions, roles, memberships, keysenhancementNew feature or requestsecurityTouches a trust boundary. A vulnerability is never reported in an issue: see SECURITY.md

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions