fix(security): swagger route path safety, localStorage encryption, and horizon fallback verification - #346
Merged
cypriannwokolo2-creator merged 1 commit intoAug 31, 2026
Conversation
…d horizon fallback verification - Make GET /api/swagger configurable via env vars (SWAGGER_JSON_PATH/SWAGGER_PATH, SWAGGER_BACKEND_URL/BACKEND_URL) with sensible local defaults, returning 404 without leaking server path details on missing files (Closes cocor-tech#333). - Encrypt user profile & wallet sessions at rest in localStorage using WebCrypto AES-GCM, with graceful fallback/clearance on corrupted payloads and re-auth key rotation (Closes cocor-tech#335). - Ensure client balance cache routes solely through first-party /api/wallet/balance proxy without third-party Horizon fallbacks or address leaks (Closes cocor-tech#326). - Add unit tests for swagger API route, WebCrypto AES-GCM storage encryption, auth-store rehydration, and session manager.
|
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. |
|
@wowamaxe-glitch 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! 🚀 |
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.
Closes #333
Closes #335
Closes #326
Summary of Changes
This PR addresses three security issues on
moistello-frontend:Swagger Route Path Hardcoding & Path Disclosure (Fixes fix(security): make swagger route robust instead of reading a hardcoded absolute server path #333)
GET /api/swaggerinsrc/app/api/swagger/route.tsto replace the hardcoded server path (/opt/moistello/backend/...).SWAGGER_JSON_PATH/SWAGGER_PATHandSWAGGER_BACKEND_URL/BACKEND_URLenvironment variables with safe relative defaults (docs/api/swagger.json,public/swagger.json).404status with{ error: "Swagger API specification not found" }without disclosing server filesystem paths.src/app/api/swagger/__tests__/route.test.ts.WebCrypto AES-GCM Encryption for Persisted Data at Rest (Fixes feat(security): encrypt wallet sessions and user profile at rest in localStorage #335)
AES-GCMencryption insrc/lib/security/encryption.tsto encrypt user profile and wallet session payloads stored inlocalStorage.WalletSessionManagerinsrc/lib/wallet/session-manager.tsto use a consistent device-based passphrase seed sorestore()andpersist()match across reloads.useAuthStoreinsrc/stores/auth-store.tswithgetStoredUserAsync()to decrypt the user profile using WebCrypto AES-GCM on rehydration and handle tampered payloads gracefully by clearing stale storage.src/lib/security/__tests__/encryption.test.tscovering round-trip encryption, decryption failure with wrong keys, and tamper detection.Removal of Direct Third-Party Horizon Fallbacks (Fixes fix(security): remove direct Horizon fallback in balance-cache leaking wallet addresses #326)
fetchBalanceWithBackoffinsrc/lib/wallet/balance-cache.tsroutes all wallet balance requests exclusively through the first-party proxy (/api/wallet/balance).Verification
route.test.ts,encryption.test.ts,auth-store.test.ts,session-manager.test.ts, andbalance-cache.test.ts.