[Security Hardening] Harden hosted vision provider requests (redirects, HTTPS, proxy)
Maintainers usually reply within 1 day
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Stale
- Tech stack
- python
- Domain
- backend, networking, security
Research direction
Read src/keystone/vlm.py, especially _get_session(), _post_json(), and _post_openai(), then inspect VisionConfig in src/keystone/config.py. Trace redirect handling, URL scheme validation, proxy selection, and credential-safe errors before changing the relevant request configuration. Verify the acceptance criteria with the project's vision-client tests: redirects are rejected, proxies are used for HTTP and HTTPS, invalid hosted URLs fail clearly, and credentials or payloads never appear in errors.
Written by the indexing model from the issue text.
Description
Summary
The vision client's HTTP session leaves several outbound-request decisions at aiohttp defaults. ClientSession.post() follows redirects, so a 307 or 308 from the configured endpoint re-sends the request body, including the base64 camera image and prompt, to the redirect target. The openai and anthropic providers accept a plain http:// base URL, and there is no way to route requests through an outbound proxy.
Affected code
_get_session()_post_json()_post_openai()VisionConfig, including the defaultbase_url
Evidence
Source inspection at dab11d2a37fa860b0bb6894fcd8a7f6451c54d0d, plus local tests against aiohttp 3.14.3:
- aiohttp's
ClientSession.request()defaultsallow_redirectstoTruefor POST. In a local two-server test, a 307 POST redirect re-sent the full JSON body to the second origin. aiohttp strips theAuthorizationheader when the origin changes, but not the body, so the image and prompt follow the redirect. - Neither
_post_json()nor_post_openai()setsallow_redirects. VisionConfig.base_urlhas no scheme validation.openaiandanthropiccan be configured withhttp://, which sends the API key and image over plaintext.- aiohttp defaults
trust_envtoFalse, soHTTP_PROXY/HTTPS_PROXYare ignored. There is novision.proxyoption.
No hosted provider was called and no real credential was used.
Impact
When the configured endpoint redirects, camera frames and prompt text can be delivered to the redirect destination. A plaintext base URL exposes the API key and frames to anyone on the path. In networks that require an outbound proxy, the vision feature does not work at all and there is no supported way to make it work. None of these requires a compromised provider if the endpoint is misconfigured; a redirect from a legitimate provider to another host is enough to forward the body.
Suggested remediation
- Do not follow redirects on vision requests. Treat a 3xx as an error that names the final endpoint URL.
- Require
https://for theopenaiandanthropicproviders unless the host is loopback; keepopenai-compatibleandollamafree to use local or customhttp://endpoints. - Add an optional
vision.proxy(KEYSTONE_VISION_PROXY) passed explicitly on every request, withtrust_env=Falseso a configured proxy is the only route and there is no silent direct fallback. - Keep TLS verification enabled and keep credentials out of error text and logs.
Acceptance criteria
- A direct Anthropic request succeeds.
- A cross-origin 307/308 redirect is not followed and the body is not sent to the target.
- A configured proxy is used for both
httpandhttpstargets. - An unreachable proxy fails instead of falling back to a direct connection.
openaiandanthropicreject a non-loopbackhttp://base URL with a clear message.- Loopback
http://endpoints andopenai-compatibleendpoints keep working. - TLS verification remains enabled.
- Error messages do not contain the API key or the image payload.
Compatibility considerations
openai-compatible and ollama are the local/custom paths and keep working over http://. Hosted openai and anthropic users with a non-loopback http:// URL must switch to https:// or use openai-compatible; the startup error explains both. Redirects from an API endpoint are not part of any supported provider contract, so refusing them does not remove a working configuration, but it should be called out in the release notes.
- Dominant language
- Python
- Stars
- 1k
- Forks
- 114
- Avg merge
- 1h
- Merged PRs (30d)
- 115
Getting set up
- Ships a Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from seeARMS/keystone
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
Maintainers usually reply within 1 day
-
needs-triage
Difficulty 3/5 1-2 days Newbie friendliness 52/100
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 52/100
Maintainers usually reply within 1 day
All issues in seeARMS/keystone
Similar issues
-
docs(contributing): the two things that silently block a PRPossibly taken A pull request linked to this issue is open or already merged. Openavailable documentation good first issue
Difficulty 1/5 1-3 hours Newbie friendliness 95/100
Nixitov/Riptide-Native#944 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
JTHCode/secretguard#24 ·
Maintainers usually reply within 1 day
-
area: middleware documentation good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
enhancement good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
Maintainers usually reply within 1 day
-
good first issue
Difficulty 1/5 Under an hour Newbie friendliness 95/100
omarelshamy25x/shamy-hijri#63 ·
Maintainers usually reply within 1 day