Fix: Secure site gate authentication with HMAC-SHA tokens to prevent secret leakage - #75
Open
Sahveli01 wants to merge 1 commit into
Open
Fix: Secure site gate authentication with HMAC-SHA tokens to prevent secret leakage#75Sahveli01 wants to merge 1 commit into
Sahveli01 wants to merge 1 commit into
Conversation
…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.
|
@Sahveli01 is attempting to deploy a commit to the Coinbase Team on Vercel. A member of the Team first needs to authorize it. |
Collaborator
🟡 Heimdall Review Status
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR hardens the UI site gate authentication by preventing the plaintext
SITE_PASSWORDfrom 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. Thesite_gatecookie is now strictly enforced withhttpOnly,secure, andsameSite='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.