Security fixes: validation, verification, and schema enforcement - #372
Open
OZILSOLAR wants to merge 4 commits into
Open
Security fixes: validation, verification, and schema enforcement#372OZILSOLAR wants to merge 4 commits into
OZILSOLAR wants to merge 4 commits into
Conversation
…tion - Create src/lib/schemas.ts with type guards for all API response types - Add validation error handling to apiFetch function - Integrate validators into API endpoints (createIntent, submitIntent, acceptIntent, registerSolver, submitSolverRegistration) - Add comprehensive unit tests for all schema validators Validates: Quote, FeedItem[], IntentDetail, Solver[], CreateIntentResponse, SubmitIntentResponse, RegisterSolverResponse, SubmitRegistrationResponse
…re protocols - Extend scripts/check-env-vars.mjs to validate NEXT_PUBLIC_API_URL and NEXT_PUBLIC_WS_URL in production - Ensure production builds use https:// and wss:// schemes (localhost exempt for testing) - Add comprehensive test suite for security validation logic - Integrate check into npm build script - Document NEXT_PUBLIC_SITE_URL in .env.example Security check ensures: - Production API URLs use https:// (not http://) - Production WebSocket URLs use wss:// (not ws://) - Localhost testing URLs remain unaffected - Clear error messages guide developers to fix misconfiguration
…ion before signing - Create src/lib/transactionVerification.ts with XDR decoding and contract address verification - Implement verifyContractAddresses() to validate contract addresses in transactions - Integrate verification into useSwapSubmission.ts (settlement contract) - Integrate verification into useSolverRegistration.ts (solver registry contract) - Add comprehensive test suite for verification logic Security features: - Decodes unsigned XDR to extract invoked contract addresses - Fails if no environment variables are configured (fail-closed principle) - Validates that transaction targets configured contract addresses only - Clear error messages guide debugging of contract mismatches - Prevents signing transactions targeting wrong/malicious contracts
…t state from localStorage - Create isValidPersistedState() type guard for wallet state shape validation - Validate address fields using isValidStellarPublicKey() from stellarAddress.ts - Integrate validation into persist middleware via reviver function - Fail-safe to default disconnected state on validation failure - Add comprehensive test suite for adversarial wallet state scenarios Security features: - Validates object structure (address, lastKnownAddress, network, isConnected) - Rejects corrupted or manually-edited localStorage entries - Prevents maliciously-injected wallet state from being used - Validates Stellar public key format before trusting persisted addresses - Logs warnings when invalid state is detected Testing includes: - Valid persisted state acceptance - Null/undefined address handling - Malformed JSON detection - Wrong type rejection - Invalid Stellar address rejection - Tampered/modified address detection - Mixed valid/invalid data handling
|
@OZILSOLAR 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! 🚀 |
OZILSOLAR
force-pushed
the
feature/304-305-306-307-security-fixes
branch
from
August 31, 2026 07:45
8481748 to
49b33b8
Compare
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
Test plan
Closes
Closes #304
Closes #305
Closes #306
Closes #307