Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .jules/sentinel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
## 2024-05-30 - Added security headers in API response middleware
**Vulnerability:** Missing security headers in API responses, which can expose the application to clickjacking, MIME sniffing, and downgrade attacks.
**Learning:** Security headers should be handled centrally in the request lifecycle middleware (`apps/api/src/cortex_api/middleware/request_context.py`) rather than per-endpoint.
**Prevention:** Implement security headers in the global request context middleware to ensure all endpoints automatically inherit these protections.
6 changes: 6 additions & 0 deletions apps/api/src/cortex_api/middleware/request_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,10 @@ async def request_context_middleware(
response.headers[X_REQUEST_ID_HEADER] = request_id
if trace_context["trace_id"]:
response.headers[X_TRACE_ID_HEADER] = str(trace_context["trace_id"])

# Security headers
response.headers["Strict-Transport-Security"] = "max-age=31536000; includeSubDomains"
response.headers["X-Frame-Options"] = "DENY"
response.headers["X-Content-Type-Options"] = "nosniff"

return response
Loading