Skip to content

ID header check vulnerable to timing attack #48

@windoze95

Description

@windoze95

Summary

In internal/middleware/headers.go:13, CheckIDHeader compares the shared secret using != which is not constant-time:

if idHeaderValue != id {

This allows timing side-channel attacks to brute-force the secret value one character at a time by measuring response latency.

Suggested Fix

Use crypto/subtle.ConstantTimeCompare:

import "crypto/subtle"

if subtle.ConstantTimeCompare([]byte(idHeaderValue), []byte(id)) != 1 {

Comparison time will then be constant regardless of how many characters match.

Metadata

Metadata

Assignees

No one assigned

    Labels

    securitySecurity vulnerability or hardening

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions