feat(security): harden CSP, auth-flow concurrency, WC2 adapter, and HttpOnly auth persistence - #345
Open
adeniran19-maker wants to merge 1 commit into
Conversation
…ttpOnly auth persistence - Harden Content-Security-Policy (CSP) by removing wildcard img-src and enforcing strict origins, analytics, and IPFS gateways (Closes cocor-tech#336) - Harden auth-flow-store.signAndSubmit against concurrent submits using atomic state checks and an in-flight submission guard (Closes cocor-tech#338) - Harden WalletConnect adapter against concurrent connect attempts with isolated PairingContext and safe abort mechanisms (Closes cocor-tech#339) - Transition auth-flow persistence to HttpOnly cookie session lifecycle with in-memory tokens and legacy token cleanup (Closes cocor-tech#340)
|
Someone is attempting to deploy a commit to the Nzubechukwu 's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
@adeniran19-maker Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
Contributor
|
This PR has merge conflicts against latest |
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.
Summary of Changes
This pull request implements comprehensive security hardening, race condition mitigations, and architecture refactors addressing issues #336, #338, #339, and #340.
1. CSP Hardening and Strict Asset Allowlists (Closes #336)
img-srcwildcards (https:) and potential unsafe eval exposure allow external exfiltration and weaken CSP protection.src/lib/security/csp.tsby replacinghttps:wildcard inimg-srcwith strict origins (...configuredOrigins(),...ANALYTICS_HOSTS,...IPFS_HOSTS).unsafe-evalandunsafe-inline.src/lib/security/__tests__/csp.test.ts.2. Auth Flow Concurrency & Atomic State Validation (Closes #338)
auth-flow-store.signAndSubmitcould initiate concurrent signing attempts or submit signatures against stale authentication states.isSigningInFlightconcurrency guard preventing duplicate active sign/submit operations.mode,address, andwalletIdcannot change mid-flight.src/stores/__tests__/auth-flow-store-concurrent.test.tsandsrc/stores/__tests__/auth-flow-store-sign.test.ts.3. WalletConnect Adapter Concurrency & Resource Lifecycle (Closes #339)
PairingContextinstances with abort controllers.resetWcState()anddisconnectWc()to avoid destructive global IndexedDB wipes, scoping resets strictly to active session contexts.WalletErrorunion (not_installedfor disconnected states).src/lib/wallet/adapters/__tests__/wc2-context.test.tsandsrc/lib/wallet/adapters/__tests__/walletconnect.test.ts.4. HttpOnly Cookie Authentication Token Lifecycle (Closes #340)
localStorageexposed credentials to XSS extraction.useAuthFlowStorepartialize configuration to strictly excludeauth(nonces and signatures) fromlocalStorage./api/auth/sessionendpoint, with in-memory token retention for tab session state.moistello_token,moistello_refresh,moistello_access_token,moistello_refresh_token) on store initialization.src/stores/__tests__/auth-security.test.ts.Issue References
Closes #336
Closes #338
Closes #339
Closes #340
Verification
src/lib/security/__tests__/csp.test.tssrc/lib/security/__tests__/api-csp.test.tssrc/lib/security/__tests__/middleware-csp.test.tssrc/lib/security/__tests__/middleware-dev-guard.test.tssrc/lib/security/__tests__/dev-only-route.test.tssrc/stores/__tests__/auth-flow-store-concurrent.test.tssrc/stores/__tests__/auth-flow-store-sign.test.tssrc/stores/__tests__/auth-security.test.tssrc/lib/wallet/adapters/__tests__/walletconnect.test.tssrc/lib/wallet/adapters/__tests__/wc2-context.test.tssrc/lib/wallet/adapters/__tests__/wc2-aggressive.test.ts