fix(security): confine teardown paths and avoid interpolating exception data in logs

- routes/gallery/gallery_routes.py: use stable diagnostic log message without
  interpolating raw exception, resolver details, tokens, or destination strings.
- tests/e2e/teardown.js: remove environment-variable path overrides from production
  code, strictly confine test options and temp directories, and prevent arbitrary
  directory cleanup.
- Add regression tests covering non-leakage of synthetic tokens/queries/exceptions
  into logs and responses, and path confinement during teardown.
This commit is contained in:
Alexandre Teixeira
2026-10-28 21:14:43 +00:00
parent de8f151632
commit 6d102a213f
4 changed files with 184 additions and 82 deletions
+3 -4
View File
@@ -2195,10 +2195,9 @@ def setup_gallery_routes() -> APIRouter:
ok, reason = check_outbound_url(base, block_private=block_private)
if not ok:
# CodeQL #1203: Never expose internal addresses, resolver errors or raw
# exception details to clients. Log useful diagnostic server-side without
# printing credentials or raw destination URLs, and return a stable generic response.
safe_reason = re.sub(r"://([^:@\s]+):([^@\s]+)@", r"://\1:[REDACTED]@", str(reason))
logger.warning("edit-progress endpoint rejected: %s", safe_reason)
# exception details to clients or logs. Use a stable diagnostic message
# without interpolating untrusted exception content or destination strings.
logger.warning("edit-progress endpoint rejected: outbound URL policy check failed")
return {"available": False, "reason": "endpoint URL rejected"}
if not base.endswith("/v1"):