Skip to content

Security fixes: validation, verification, and schema enforcement - #372

Open
OZILSOLAR wants to merge 4 commits into
stellar-vortex-protocol:mainfrom
OZILSOLAR:feature/304-305-306-307-security-fixes
Open

Security fixes: validation, verification, and schema enforcement#372
OZILSOLAR wants to merge 4 commits into
stellar-vortex-protocol:mainfrom
OZILSOLAR:feature/304-305-306-307-security-fixes

Conversation

@OZILSOLAR

@OZILSOLAR OZILSOLAR commented Aug 31, 2026

Copy link
Copy Markdown

Summary

Test plan

  • Run existing test suite to ensure no regressions
  • Verify validation catches invalid inputs
  • Test wallet state restoration with various edge cases
  • Confirm transaction verification blocks unauthorized changes

Closes

Closes #304
Closes #305
Closes #306
Closes #307

…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
@drips-wave

drips-wave Bot commented Aug 31, 2026

Copy link
Copy Markdown

@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! 🚀

Learn more about application limits

@OZILSOLAR
OZILSOLAR force-pushed the feature/304-305-306-307-security-fixes branch from 8481748 to 49b33b8 Compare August 31, 2026 07:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant