Repository navigation
Commit e6edad1
fix(api): require HTTPS for custom Google Gemini base URLs (CWE-319) (#2033)
* fix(api): require HTTPS for custom Google Gemini base URLs (CWE-319)
googleGeminiBaseUrl is user-editable (settings, imported profiles) and the
@google/genai client keeps API-key authentication for custom endpoints, so a
cleartext base URL would send the API key over an insecure endpoint (CWE-319).
Validate the endpoint before any request in createMessage and completePrompt:
HTTPS is required; plain HTTP is accepted only for loopback test proxies
(localhost, [::1], and literal 127.0.0.0/8 IPv4 hosts). Hostnames that merely
resemble the loopback range (127.example.test, 127.0.0.a, 127.0.0.1.a,
foo127.bar) or fall outside it (10.0.0.1) are rejected, as are non-HTTP
schemes such as ftp://localhost and malformed URLs. Violations surface as a
structured ApiProviderError before the request is built, so the key never
leaves the process.
Carved out of the abort-signal provider rollout (fork PR 1303) at the
maintainer's request so the endpoint policy can be reviewed independently of
the cancellation changes.
* chore(lint): limit Stryker directive comments to 300 characters
* test(api): cover Gemini HTTPS accept path and completePrompt rejects
* docs(agents): require accept and reject tests for guards
---------
Co-authored-by: Eason Liang <easonliang28@gmail.com>
Co-authored-by: Elliott de Launay <edelauna@gmail.com>1 parent e4e112e commit e6edad1
8 files changed
Lines changed: 663 additions & 9 deletions
File tree
- src
- api/providers
- __tests__
- core/task
- utils
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
82 | 85 | | |
83 | 86 | | |
84 | 87 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
57 | 60 | | |
58 | 61 | | |
59 | 62 | | |
| |||
0 commit comments