teapot-coding-agent 0.35.28 → 0.35.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/server/api.js +28 -1
- package/package.json +1 -1
- package/public/assets/{index-DfCPh6tw.js → index-BuOwDdBP.js} +5 -5
- package/public/assets/{index-DfCPh6tw.js.map → index-BuOwDdBP.js.map} +1 -1
- package/public/assets/index-QlwrdJke.css +1 -0
- package/public/assets/{shiki-2Yd0lqhl.js → shiki-BkT0ArEY.js} +2 -2
- package/public/assets/{shiki-2Yd0lqhl.js.map → shiki-BkT0ArEY.js.map} +1 -1
- package/public/index.html +2 -2
- package/public/assets/index-DMS0fUWe.css +0 -1
package/dist/server/api.js
CHANGED
|
@@ -160,7 +160,34 @@ export function buildApp(master) {
|
|
|
160
160
|
// no Origin at all: a non-browser client. A browser ALWAYS sets it cross-origin.
|
|
161
161
|
if (origin === undefined)
|
|
162
162
|
return true;
|
|
163
|
-
|
|
163
|
+
/**
|
|
164
|
+
* `Sec-Fetch-Site` FIRST — the browser computes it and NOTHING in the request path can rewrite
|
|
165
|
+
* it, unlike `Host`.
|
|
166
|
+
*
|
|
167
|
+
* MEASURED failure this fixes: the operator runs a reverse proxy
|
|
168
|
+
* (`http-proxy`, `changeOrigin: true`) from :7788 to :7789, so the browser's `Origin` says
|
|
169
|
+
* `:7788` while the `Host` reaching teapot says `:7789` — and comparing those two refused every
|
|
170
|
+
* prompt sent through the proxy ("リバースプロキシした先からプロンプトを送信できない").
|
|
171
|
+
*
|
|
172
|
+
* `Sec-Fetch-Site` is `same-origin` on the operator's own page and `cross-site` on an attacker's,
|
|
173
|
+
* regardless of how many proxies sit in between, because it describes the INITIATOR, not the
|
|
174
|
+
* URL. Modern browsers always send it on a state-changing request.
|
|
175
|
+
*/
|
|
176
|
+
const site = c.req.header("sec-fetch-site");
|
|
177
|
+
if (site === "cross-site")
|
|
178
|
+
return false;
|
|
179
|
+
if (site === "same-origin" || site === "none")
|
|
180
|
+
return true;
|
|
181
|
+
/**
|
|
182
|
+
* Older browsers do not send `Sec-Fetch-Site`, so fall back to comparing hosts — using
|
|
183
|
+
* `X-Forwarded-Host` when a proxy supplied one.
|
|
184
|
+
*
|
|
185
|
+
* That is not a bypass: `X-Forwarded-Host` is not a CORS-safelisted header, so a cross-origin
|
|
186
|
+
* page cannot set it without a preflight, and this server approves no preflight. A LOCAL process
|
|
187
|
+
* could forge it — and a local process can already read the config, so it is not the threat this
|
|
188
|
+
* guards.
|
|
189
|
+
*/
|
|
190
|
+
const host = c.req.header("x-forwarded-host") ?? c.req.header("host") ?? "";
|
|
164
191
|
try {
|
|
165
192
|
const u = new URL(origin);
|
|
166
193
|
if (u.host === host)
|