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.
@@ -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
- const host = c.req.header("host") ?? "";
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)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "teapot-coding-agent",
3
- "version": "0.35.28",
3
+ "version": "0.35.29",
4
4
  "description": "A lightweight, always-on multi-agent harness for AI coding agents",
5
5
  "type": "module",
6
6
  "license": "AGPL-3.0-or-later",