Skip to content

Bearer token check uses non-constant-time comparison #5

Description

@DonPrus

src/api.zig:576 (in isAuthorized):

return std.mem.eql(u8, required_token.?, request_token.?);

std.mem.eql short-circuits on the first mismatching byte, so the comparison time leaks how many leading bytes of the guess match the real token — the classic timing side channel for bearer-token auth.

Suggested fix: use a constant-time comparison, e.g. std.crypto.timing_safe.eql (or std.crypto.utils.timingSafeEql on older Zig), after an early length check that returns false without revealing position information.

Activity

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions