Skip to content

wake-lambda: wake token comparison is not constant-time #123

Open

Description

@royosherove

wake-lambda/index.mjs line 236 uses token !== stored.

The risk is low, because the token is a UUID that you can use one time. But a constant-time comparison is the correct method.

Fix: compare with crypto.timingSafeEqual (check that the lengths are equal first).

Found by a static read of the code at commit 1f66a8f. The code was not run.

Activity

  1. royosherove commented on Oct 11, 2026

    @royosherove
    MemberAuthor

    👻 Andromeda is on this · Kiro Crew Issue Radar
    awaiting-merge · PR #125 · updated 11:15 UTC

    The fix adds tokensMatch() to wake-lambda/index.mjs. It compares the UTF-8 byte lengths first and then calls crypto.timingSafeEqual, because timingSafeEqual throws when the lengths are not equal. Byte length is used, not string length, so a token with a multi-byte character cannot cause an exception. Wrong tokens still get 403. The new tests/test-wake-token.sh runs the real handler with stub AWS SDK modules: 4 of 5 checks pass on main (the source check fails), 5 of 5 pass after the fix on Node 22 and Node 26.

    progress
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

    bugSomething isn't workingcrew: in progressIssue Radar work claimed by a Kiro Crew worker

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions