[Security Hardening] Harden hosted vision provider requests (redirects, HTTPS, proxy)

Open
#110 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

@developingchet is already working on this.

Since Dec 4, 2026.

  • #117 by @developingchet — open

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

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

needs-triage security

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

Evidence

Source inspection at dab11d2a37fa860b0bb6894fcd8a7f6451c54d0d, plus local tests against aiohttp 3.14.3:

  • aiohttp's ClientSession.request() defaults allow_redirects to True for POST. In a local two-server test, a 307 POST redirect re-sent the full JSON body to the second origin. aiohttp strips the Authorization header when the origin changes, but not the body, so the image and prompt follow the redirect.
  • Neither _post_json() nor _post_openai() sets allow_redirects.
  • VisionConfig.base_url has no scheme validation. openai and anthropic can be configured with http://, which sends the API key and image over plaintext.
  • aiohttp defaults trust_env to False, so HTTP_PROXY/HTTPS_PROXY are ignored. There is no vision.proxy option.

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 the openai and anthropic providers unless the host is loopback; keep openai-compatible and ollama free to use local or custom http:// endpoints.
  • Add an optional vision.proxy (KEYSTONE_VISION_PROXY) passed explicitly on every request, with trust_env=False so 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 http and https targets.
  • An unreachable proxy fails instead of falling back to a direct connection.
  • openai and anthropic reject a non-loopback http:// base URL with a clear message.
  • Loopback http:// endpoints and openai-compatible endpoints 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

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from seeARMS/keystone

All issues in seeARMS/keystone

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.