Skip to content

fix(envd): use constant-time comparison for signature validation#3145

Open
AdaAibaby wants to merge 2 commits into
e2b-dev:mainfrom
AdaAibaby:fix/envd-auth-timing-attack
Open

fix(envd): use constant-time comparison for signature validation#3145
AdaAibaby wants to merge 2 commits into
e2b-dev:mainfrom
AdaAibaby:fix/envd-auth-timing-attack

Conversation

@AdaAibaby

Copy link
Copy Markdown
Contributor

Replace string inequality operator (!=) with crypto/subtle.ConstantTimeCompare for signature validation in auth.go. The previous implementation was vulnerable to timing attacks, where an attacker could potentially determine the correct signature byte-by-byte by measuring response times.

This is a standard security best practice for comparing cryptographic values such as HMAC signatures, tokens, and hashes.

/cc @jakubno @dobrac @ValentaTomas Would appreciate your review on this change, thanks!

Replace string inequality operator (!=) with crypto/subtle.ConstantTimeCompare
for signature validation in auth.go. The previous implementation was vulnerable
to timing attacks, where an attacker could potentially determine the correct
signature byte-by-byte by measuring response times.

This is a standard security best practice for comparing cryptographic values
such as HMAC signatures, tokens, and hashes.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Add 6 test cases covering validateSigning:
- Accepts correct signature with expiration
- Rejects wrong signature
- Rejects expired signature
- Rejects missing signature parameter
- Accepts valid access token from header
- Rejects invalid access token from header

Also refactor existing tests to use a shared helper.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants