Security & Debounce Improvements: CSP, CSRF, SRI, & Autocomplete Debounce (#723-726)#826
Merged
Mystery-CLI merged 5 commits intoJun 26, 2026
Conversation
…st suite - Implement useDebounce hook to delay value updates by configurable delay (default 300ms) - Add unit tests verifying debounce behavior with rapid updates - Tests confirm only latest value fires after delay window - Tests verify cancellation of previous timeouts on new values - Tests cover numeric values, objects, and edge cases
…Add CSP, CSRF, and SRI security documentation - Add helmet package to backend for security headers - Add csrf-csrf package for modern CSRF protection - Document Content Security Policy configuration and directives - Document CSRF token delivery flow and API endpoint - Document Subresource Integrity (SRI) implementation for CDN assets - Add SRI hash generation instructions and monitoring guidance - Include cross-browser security header configurations
…ation and verification - Create SRI utility module with generateSRIHash and verifySRIHash functions - Support SHA256 and SHA512 algorithms - Add SRI headers middleware to attach X-SRI-Hash to CDN assets - Comprehensive test suite covering hash generation, verification, and edge cases - Tests verify different content produces different hashes - Tests verify hash tampering detection - Support both string and Buffer content
- Create useCSRFToken hook to fetch and manage CSRF tokens in memory - Implement addCSRFTokenToHeaders helper to add token to request headers - Token stored in memory only (not localStorage) to prevent XSS exfiltration - Fetch includes credentials for secure cookie handling - Comprehensive test suite covering token fetching and header management - Tests verify error handling for network and HTTP failures - Tests verify no token leakage to localStorage
|
@chukwudiikeh 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.
Overview
This PR addresses four critical security issues and one UX improvement:
Issues Addressed
Changes Made
1. Debounce Autocomplete Requests (#723)
useDebouncehook with configurable delay (default 300ms)2. CSRF Protection (#724)
useCSRFTokenhook for frontend token managementaddCSRFTokenToHeadershelper for request integration3. Content Security Policy (#725)
securityHeaders.jsdefault-src 'self'- block untrusted originsscript-src 'self' 'nonce-*'- no inline scripts without noncestyle-src 'self' 'unsafe-inline'- allow inline styles (future: tighten)connect-src 'self' https://horizon*.stellar.org- Horizon API onlyframe-ancestors 'none'- prevent clickjackingobject-src 'none'- block plugins4. Subresource Integrity (SRI) (#726)
generateSRIHash(content, algorithm)- generate SHA256/SHA512 hashesverifySRIHash(content, integrityAttribute)- verify asset integrityTest Results
All tests passing:
frontend/tests/useDebounce.test.js- 7 testsfrontend/tests/useCSRFToken.test.js- 9 testsbackend/tests/sriHash.test.js- 12 testsTotal: 28 new tests, all passing
Security Impact
frame-ancestors: 'none'blocks iframe embeddingDocumentation
docs/guides/security.mdwith:Breaking Changes
None. All changes are backward-compatible additions.
Migration Guide
For Frontend Developers
To use CSRF protection:
To use debounced autocomplete:
Review Checklist
Closes #723
Closes #724
Closes #725
Closes #726