feat: Security hardening across signing flow, API, wallet bridge, and dependencies - #370
Open
Barbie-Dev wants to merge 4 commits into
Conversation
- Validate NEXT_PUBLIC_API_URL is well-formed using URL constructor - Require https:// in production builds - Allow http://localhost for development - Fail loudly on misconfiguration - Add tests for validation logic
- Add isValidStellarPublicKey validation on addresses from freighterApi - Validate addresses in both connect() and hydrate() methods - Treat invalid addresses as connection failures with clear error message - Defense-in-depth against postMessage bridge spoofing attacks - Add comprehensive tests for invalid and valid address scenarios
- Create xdrReview.ts helper for decoding and verifying XDR transactions - Validate signed XDR matches unsigned XDR for operations, amounts, and destinations - Add XDR verification to useSwapSubmission and useSolverRegistration hooks - Block submission if signed XDR fails verification - Defense-in-depth against compromised extensions or man-in-the-middle attacks - Add comprehensive tests for XDR verification and hook behavior
- Create check-dependencies.mjs script for CI pipeline - Require PR description justification for security-sensitive packages - Exempt Dependabot/Renovate automated PRs from strict checks - Update pull request template with dependency change section - Document process in PR template for human-authored changes
|
@Barbie-Dev 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.
Summary
This PR implements four security hardening features to strengthen the Vortex Frontend against potential compromises in the wallet signing flow, API communication, dependency supply chain, and postMessage bridge communications.
Closes #308
Closes #309
Closes #310
Closes #311
Issue #308: Verify Signed XDR Structural Integrity Before Submission
Problem: The application accepts any signed XDR from Freighter without verifying that the signed transaction still represents the same transaction the user reviewed before signing. A compromised extension, man-in-the-middle attack, or browser-based XDR manipulation could alter operations, amounts, or destinations between review and submission.
Solution:
src/lib/xdrReview.tsutility module for decoding and verifying XDR transactionsuseSwapSubmission.tsanduseSolverRegistration.tshooksFiles Changed:
src/lib/xdrReview.ts(new)src/lib/xdrReview.test.ts(new)src/hooks/useSwapSubmission.tssrc/hooks/useSwapSubmission.test.tssrc/hooks/useSolverRegistration.tssrc/hooks/useSolverRegistration.test.tsIssue #309: Add API URL Validation at Module Load
Problem:
NEXT_PUBLIC_API_URLis read from environment without validation. A misconfigured or compromised build-time environment variable could silently redirect all API traffic to an attacker-controlled server, including transaction signing requests.Solution:
NEXT_PUBLIC_API_URLinsrc/lib/api.tsURLconstructorhttps://in production buildshttp://localhostfor developmentFiles Changed:
src/lib/api.tssrc/lib/api.test.tsIssue #310: Harden Freighter PostMessage Bridge Against Spoofed Responses
Problem: The
@stellar/freighter-apicommunicates viapostMessage, a same-window channel that any script running on the page (e.g., from XSS or malicious dependency) can send messages on. The app could be tricked into trusting spoofed extension responses with invalid or attacker-controlled addresses.Solution:
isValidStellarPublicKeyvalidation on every address returned fromfreighterApicallsconnect()(viarequestAccess()) andhydrate()(viagetPublicKey()) methodsisValidStellarPublicKeyfromsrc/lib/stellarAddress.tsFiles Changed:
src/store/wallet.tssrc/store/wallet.test.tsIssue #311: Add Dependency-Provenance Check for Supply-Chain Security
Problem: No process exists to detect typosquatted packages, unexpected dependency updates, or supply-chain compromises. The application's high-value dependencies (
@stellar/freighter-api,@stellar/stellar-sdk) make it an attractive target for dependency injection attacks.Solution:
scripts/check-dependencies.mjsCI script for validating dependency changes.github/workflows/ci.yml) to run beforenpm ci.github/PULL_REQUEST_TEMPLATE.md) with dependency documentation sectionFiles Changed:
scripts/check-dependencies.mjs(new).github/workflows/ci.yml.github/PULL_REQUEST_TEMPLATE.mdTest Coverage
All implementations include comprehensive test coverage:
Total: 40 new/updated tests across 5 test files, all passing ✅
Security Implications
These changes implement layered defense-in-depth across the critical signing flow:
Together, these protections significantly raise the bar for attack success, requiring a sophisticated multi-stage compromise rather than a single point of failure.
Testing & Validation
npm test)npm run lint)npm run typecheck)npm run build)docs/security-audit.md(documented in issue scope)Breaking Changes
None. All changes are backwards-compatible and transparent to existing code paths.
Migration Guide
No user action required. All security validations are enforced at module load time or during standard transaction signing flows.
References
Generated by Claude Code Security Implementation 🔐