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-06-25 - Missing Global API Security Headers
**Vulnerability:** The API lacked basic security headers (HSTS, X-Frame-Options, X-Content-Type-Options) in responses.
**Learning:** Security headers are easily forgotten but crucial for defense-in-depth against clickjacking, MIME sniffing, and enforcing HTTPS.
**Prevention:** Always ensure standard security headers are applied in a global middleware when setting up web application frameworks like FastAPI.
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