fix(security): add strict security headers to HTML error responses#119
Merged
NiklasSkulll merged 1 commit intodevfrom Nov 22, 2025
Conversation
Add comprehensive security headers to 404 and error handlers for defense-in-depth: - Content-Security-Policy with strict 'none' directives (blocks all resources) - X-Content-Type-Options: nosniff (prevents MIME sniffing) - X-Frame-Options: DENY (prevents clickjacking) - Content-Disposition: inline (prevents download misinterpretation) Changes: - Enhanced 404 handler in apps/backend/src/index.ts - Enhanced error handler in apps/backend/src/middlewares/errorHandler.ts - Added comprehensive unit tests for both handlers - Created integration tests with real HTTP requests - All 893 backend tests pass - Manual verification confirms headers are present Closes #100
|
NiklasSkulll
approved these changes
Nov 22, 2025
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
Implements strict security headers on HTML error responses (404 and 500) to address issue #100. This provides defense-in-depth protection even though the application currently returns JSON-only responses.
Changes
Code Changes
apps/backend/src/index.ts): Added strict security headers before JSON responseapps/backend/src/middlewares/errorHandler.ts): CreatedsetStrictSecurityHeaders()helper and applied to all error responsesSecurity Headers Enforced
✅ Content-Security-Policy:
default-src 'none'; script-src 'none'; style-src 'none'; img-src 'none'; object-src 'none'; base-uri 'none'; form-action 'none'; frame-ancestors 'none'✅ X-Content-Type-Options:
nosniff✅ X-Frame-Options:
DENY✅ Content-Disposition:
inlineTest Coverage
Manual Verification
Testing
Run tests:
Impact
Closes
Closes #100
🤖 Generated with Claude Code