Security hardening: fix RCE, auth and SSRF issues
Critical: - backup: prevent Zip Slip path traversal and zip bombs in restore/convert via safe_extract(); serialize get_backup() with backup_lock and always restore CWD so concurrent requests can't corrupt the os.chdir state - app: only enable the Werkzeug debugger/reloader when ENVIRONMENT=dev; always init rate limits (also under WSGI), not just under __main__ - apikey: fix create_key never committing (session.commit -> commit()), validate roles against an allowlist, and fix revoke_key/update_last_used operating on detached instances so revocation actually persists - env_provider: redact DB_PASSWORD and SESSION_SECRET_KEY in summerize() High: - markdown: filter private/protected docs for non-admins in the listing, get_home, get_index and search endpoints (was an anonymous data leak); escape LIKE metacharacters and cap search results - webhooks: validate target URL to block SSRF (loopback/private/link-local/ metadata IPs), disable redirects, safely parse additional_header - auth: validate JWT issuer and require exp/iat; add timeout to JWKS fetch; harden Authorization header parsing against malformed values - log: require admin for GET /api/log and auth for POST; bound entry size Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -23,6 +23,12 @@ KC_CLIENT_ID = os.getenv("KC_CLIENT_ID")
|
||||
FRONTEND_HOST = os.getenv("FRONTEND_HOST")
|
||||
BACKEND_HOST = os.getenv("BACKEND_HOST")
|
||||
|
||||
def _redact(value):
|
||||
if not value:
|
||||
return "<unset>"
|
||||
return f"<set:{len(str(value))} chars>"
|
||||
|
||||
|
||||
def summerize():
|
||||
return {
|
||||
"ENVIRONMENT": ENVIRONMENT,
|
||||
@@ -30,9 +36,9 @@ def summerize():
|
||||
'DB_PORT': DB_PORT,
|
||||
'DB_NAME': DB_NAME,
|
||||
'DB_USER': DB_USER,
|
||||
'DB_PASSWORD': DB_PASSWORD,
|
||||
'DB_PASSWORD': _redact(DB_PASSWORD),
|
||||
'DB_SCHEMA_UPDATED': DB_SCHEMA_UPDATED,
|
||||
'SESSION_SECRET_KEY': SESSION_SECRET_KEY,
|
||||
'SESSION_SECRET_KEY': _redact(SESSION_SECRET_KEY),
|
||||
'KC_HOST': KC_HOST,
|
||||
'KC_REALM': KC_REALM,
|
||||
'KC_CLIENT_ID': KC_CLIENT_ID,
|
||||
|
||||
Reference in New Issue
Block a user