Skip to content

Fix: Secure site gate authentication with HMAC-SHA tokens to prevent secret leakage - #75

Open
Sahveli01 wants to merge 1 commit into
base:mainfrom
Sahveli01:aaz
Open

Fix: Secure site gate authentication with HMAC-SHA tokens to prevent secret leakage#75
Sahveli01 wants to merge 1 commit into
base:mainfrom
Sahveli01:aaz

Conversation

@Sahveli01

Copy link
Copy Markdown

This PR hardens the UI site gate authentication by preventing the plaintext SITE_PASSWORD from being exposed in client-readable cookies, addressing the authentication secret exposure vulnerability highlighted in the workspace security audit.

Authentication & Secret Management:

  • ui/site-gate.ts: Introduced a Web Crypto helper to create and validate a versioned, expiring HMAC-SHA-256 token. Malformed or unverifiable tokens are safely caught and treated as unauthenticated requests without throwing edge failures.
  • ui/app/api/gate/route.ts: Updated the temporary site password verification to issue the signed HMAC token instead of the raw password. The site_gate cookie is now strictly enforced with httpOnly, secure, and sameSite='strict' flags to prevent client-side exposure.
  • ui/middleware.ts: Refactored the middleware to validate the signed token through the shared helper, ensuring secure request interception without putting the password into client-readable material.
  • ui/site-gate.test.ts: Added comprehensive test coverage for the new token behavior, including acceptance cases, wrong-secret rejection, expiry validation, and malformed-token handling.

…secret leakage

This PR hardens the UI site gate authentication by preventing the plaintext `SITE_PASSWORD` from being exposed in client-readable cookies, addressing the authentication secret exposure vulnerability highlighted in the workspace security audit.

**Authentication & Secret Management:**
* **`ui/site-gate.ts`**: Introduced a Web Crypto helper to create and validate a versioned, expiring HMAC-SHA-256 token. Malformed or unverifiable tokens are safely caught and treated as unauthenticated requests without throwing edge failures.
* **`ui/app/api/gate/route.ts`**: Updated the temporary site password verification to issue the signed HMAC token instead of the raw password. The `site_gate` cookie is now strictly enforced with `httpOnly`, `secure`, and `sameSite='strict'` flags to prevent client-side exposure.
* **`ui/middleware.ts`**: Refactored the middleware to validate the signed token through the shared helper, ensuring secure request interception without putting the password into client-readable material.
* **`ui/site-gate.test.ts`**: Added comprehensive test coverage for the new token behavior, including acceptance cases, wrong-secret rejection, expiry validation, and malformed-token handling.
@vercel

vercel Bot commented Aug 18, 2026

Copy link
Copy Markdown

@Sahveli01 is attempting to deploy a commit to the Coinbase Team on Vercel.

A member of the Team first needs to authorize it.

@cb-heimdall

Copy link
Copy Markdown
Collaborator

🟡 Heimdall Review Status

Requirement Status More Info
Reviews 🟡 0/1
Denominator calculation
Show calculation
1 if user is bot 0
1 if user is external 0
2 if repo is sensitive 0
From .codeflow.yml 1
Additional review requirements
Show calculation
Max 0
0
From CODEOWNERS 0
Global minimum 0
Max 1
1
1 if commit is unverified 0
Sum 1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants