user.email commited on
Commit ·
e1bc5da
1
Parent(s): b2cd136
unbroken-embedd
Browse files- README.md +1 -1
- server/app.py +6 -1
README.md
CHANGED
|
@@ -83,7 +83,7 @@ tests/ — Substrate and fixture tests
|
|
| 83 |
- Per-IP rate limiting on all API endpoints
|
| 84 |
- Path traversal prevention on file uploads
|
| 85 |
- No string interpolation of user input into queries, file paths, or shell commands
|
| 86 |
-
- Security headers: X-Content-Type-Options,
|
| 87 |
- Request body size limits (5 MB global, 2 MB lockfiles)
|
| 88 |
|
| 89 |
## Research Credits
|
|
|
|
| 83 |
- Per-IP rate limiting on all API endpoints
|
| 84 |
- Path traversal prevention on file uploads
|
| 85 |
- No string interpolation of user input into queries, file paths, or shell commands
|
| 86 |
+
- Security headers: X-Content-Type-Options, CSP frame-ancestors for Hugging Face embedding, Referrer-Policy
|
| 87 |
- Request body size limits (5 MB global, 2 MB lockfiles)
|
| 88 |
|
| 89 |
## Research Credits
|
server/app.py
CHANGED
|
@@ -41,9 +41,14 @@ async def body_size_limiter(request: Request, call_next):
|
|
| 41 |
async def security_headers(request: Request, call_next):
|
| 42 |
response = await call_next(request)
|
| 43 |
response.headers["X-Content-Type-Options"] = "nosniff"
|
| 44 |
-
response.headers["X-Frame-Options"] = "DENY"
|
| 45 |
response.headers["Referrer-Policy"] = "strict-origin-when-cross-origin"
|
| 46 |
response.headers["Permissions-Policy"] = "geolocation=(), camera=(), microphone=()"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
return response
|
| 48 |
|
| 49 |
|
|
|
|
| 41 |
async def security_headers(request: Request, call_next):
|
| 42 |
response = await call_next(request)
|
| 43 |
response.headers["X-Content-Type-Options"] = "nosniff"
|
|
|
|
| 44 |
response.headers["Referrer-Policy"] = "strict-origin-when-cross-origin"
|
| 45 |
response.headers["Permissions-Policy"] = "geolocation=(), camera=(), microphone=()"
|
| 46 |
+
# Hugging Face embeds Space apps in an iframe on the repo page, so using
|
| 47 |
+
# X-Frame-Options: DENY breaks the primary app view even though direct
|
| 48 |
+
# navigation to the hf.space domain still works.
|
| 49 |
+
response.headers["Content-Security-Policy"] = (
|
| 50 |
+
"frame-ancestors 'self' https://huggingface.co https://*.huggingface.co"
|
| 51 |
+
)
|
| 52 |
return response
|
| 53 |
|
| 54 |
|