Harden API-token chat endpoint selection #598
No reviewers
Labels
No labels
area:chat
area:core
area:llm
area:routes
area:tools
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
refactor
wontfix
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
sleepy/odysseus!598
Loading…
Reference in a new issue
No description provided.
Delete branch "alteixeira20/harden-api-token-chat-endpoints"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Hardens
/api/v1/chatendpoint selection for private/self-hosted deployments.This PR tightens handling of API-token supplied OpenAI-compatible
base_urlvalues before Odysseus sends server-side chat traffic to them. The validator rejects URLs that point to localhost, private networks, link-local/metadata addresses, multicast, unspecified/reserved addresses, internal hostnames, or DNS names resolving to blocked addresses.Configured admin-created
ModelEndpointrows remain trusted, so local/private providers such as Ollama, vLLM, llama.cpp, LAN, or Tailscale endpoints continue to work when explicitly configured inside Odysseus.Changes
src/url_security.pywith focused public HTTP(S) endpoint validation./api/v1/chatbase_urlvalues before building the chat URL./api/v1/chatconfigured endpoint fallback to the API token owner.Motivation
I’m evaluating Odysseus for a private self-hosted deployment and wanted to harden this path before running it behind a reverse proxy / Cloudflare Access.
The goal is to keep the patch small, reviewable, and useful for deployment safety without changing normal admin-configured local model behavior.
Tests
python3 -m py_compile src/url_security.py routes/webhook_routes.py tests/test_api_chat_security.pypython3 -m pytest tests/test_api_chat_security.pygit diff --checkNotes
This intentionally does not change admin-configured model endpoint behavior. Private/local model endpoints remain supported when created through Odysseus admin settings.
Redirect-aware URL validation is intentionally out of scope for this PR because
/api/v1/chatdoes not follow redirects in this path.Merged via squash. URL validator blocks internal/private/metadata/loopback/multicast addresses including DNS-resolved private IPs. Fallback endpoint scoping tightened to owned-or-shared-only. 16 tests pass.