Skip to content

Security: Weak constant-time comparison guarantee in auth #102

Description

@mantono

Description

The constant-time comparison in src/auth.rs (lines 57-62) uses std::hint::black_box to prevent compiler optimizations from short-circuiting the byte comparison. However, the documentation for black_box explicitly states it does not offer any guarantees for cryptographic or security purposes.

The code acknowledges this limitation in comments (lines 49-56). While the current approach (SHA384 hashing + XOR fold) is reasonable, the subtle crate provides a well-audited ConstantTimeEq trait specifically designed for this use case.

Severity

Low

Suggested Fix

Replace the custom const_comp function with the subtle crate ConstantTimeEq for a stronger guarantee.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions