ulysses/tests
Jamieson O'Reilly 171c29dcf3
Fix email-thread HTML injection, attachment path traversal, and missing authz (#475)
Hardens issues found in a security review of the current tree (separate from
the cookbook SSH PR):

- Email thread rendering (static/js/emailLibrary.js): the flat read path runs
  inbound HTML through the allowlist sanitizer, but the two threaded paths
  (_renderTurnsAsBubbles / _renderTurnsFromServer — the default view) injected
  server-parsed `body_html` raw into the DOM. A crafted inbound email could
  inject arbitrary markup (phishing/form/credential-capture/tracking; full XSS
  if a deployment relaxes the script CSP). Now sanitized on all paths.

- Attachment extraction (routes/email_routes.py, routes/email_helpers.py): the
  on-disk extraction dir was `ATTACHMENTS_DIR / f"{folder}_{uid}"` with
  user-controlled folder/uid and no containment, so a folder like `../../tmp`
  could escape ATTACHMENTS_DIR. New attachment_extract_dir() flattens both to a
  single safe segment and asserts containment.

- Diagnostics routes (routes/diagnostics_routes.py): /api/db/stats,
  /api/rag/stats, /api/test/youtube, /api/test-research relied only on the
  global session check (any logged-in user). Now require_admin-gated.

- Defense-in-depth HTML escaping: session HTML export escapes the session name
  (routes/session_routes.py); the MCP OAuth page escapes the reflected Host
  header / server_id (routes/mcp_routes.py).

- Internal-tool token now compared with secrets.compare_digest (constant time)
  in core/middleware.py and app.py.

Adds regression tests in tests/test_security_regressions.py.
2026-06-01 22:20:17 +09:00
..
bombadil-spec.ts Odysseus v1.0 2026-05-31 23:58:26 +09:00
conftest.py Odysseus v1.0 2026-05-31 23:58:26 +09:00
test_action_intents.py Route calendar action requests to tools 2026-06-01 14:32:41 +09:00
test_agent_loop.py Fix fresh checkout test failures 2026-06-01 02:22:17 +00:00
test_app.py Fix fresh checkout test failures 2026-06-01 02:22:17 +00:00
test_auth_regressions.py Add native Windows compatibility layer 2026-06-01 15:09:47 +09:00
test_calendar_recurrence.py Fix YEARLY recurring CalDAV events only showing on DTSTART year (#179) 2026-06-01 13:42:44 +09:00
test_compare_js.py Odysseus v1.0 2026-05-31 23:58:26 +09:00
test_context_compactor.py Preserve large pasted messages in context 2026-06-01 12:38:35 +09:00
test_cookbook_helpers.py Add macOS Apple Silicon Cookbook support 2026-06-01 14:59:19 +09:00
test_deep_research_extraction_controls.py Add Deep Research extraction controls 2026-06-01 14:55:33 +09:00
test_endpoint_resolver.py feat(ai): add OpenRouter and Ollama Cloud providers (#231) 2026-06-01 14:26:10 +09:00
test_hwfit_macos.py Add macOS Apple Silicon Cookbook support 2026-06-01 14:59:19 +09:00
test_llm_core_ollama.py feat(ai): add OpenRouter and Ollama Cloud providers (#231) 2026-06-01 14:26:10 +09:00
test_model_context.py Odysseus v1.0 2026-05-31 23:58:26 +09:00
test_model_routes.py feat(ai): add OpenRouter and Ollama Cloud providers (#231) 2026-06-01 14:26:10 +09:00
test_null_owner_gates.py Odysseus v1.0 2026-05-31 23:58:26 +09:00
test_pdf_runtime.py Show a clear message when PyMuPDF is missing 2026-06-01 18:27:17 +09:00
test_rate_limiter.py Odysseus v1.0 2026-05-31 23:58:26 +09:00
test_reply_recipients_js.py Keep Cc recipients in reply-all 2026-06-01 18:29:22 +09:00
test_research_utils.py Odysseus v1.0 2026-05-31 23:58:26 +09:00
test_review_regressions.py Fix database stubs in regression tests (#301) 2026-06-01 16:55:09 +09:00
test_search_ranking.py Odysseus v1.0 2026-05-31 23:58:26 +09:00
test_security_regressions.py Fix email-thread HTML injection, attachment path traversal, and missing authz (#475) 2026-06-01 22:20:17 +09:00
test_session_mode_helpers.py Fix database stubs in regression tests (#301) 2026-06-01 16:55:09 +09:00
test_shell_routes.py Clarify Docker dependency status inside containers 2026-06-01 16:56:42 +09:00
test_task_scheduler_session_delivery.py Prevent task session delivery NOT NULL crashes 2026-06-01 18:28:48 +09:00
test_vision_model_detection.py Recognize local vision models so their images aren't dropped (#185) 2026-06-01 13:09:21 +09:00