Code Mode GlobalOutbound combines Authorization bearers for Workers assets JWT uploads

Aperta
#389 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
typescript
Ambito
api, security

Direzione di ricerca

Start by reading src/tools/execute.ts around the header composition at lines 68–73 and trace how outbound requests reach GlobalOutbound. The issue describes an offline reproduction and a restricted composition proposal, but the hosted incident is not tied to a confirmed revision. Done means establishing the supported upload-session authentication path or a host-authorized fix that preserves the stated account, session, endpoint, redirect, retry and permission constraints.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Summary

Code Mode's outbound header composition appears incompatible with Workers static-assets uploads authenticated using an upload-session JWT. At public commit 563b71037a3cc1f1ed52d944133abb3aca5a0901, src/tools/execute.ts lines 68–73 constructs Headers from the original entries plus another Authorization bearer from the MCP connection. Standard Headers semantics combine the values instead of preserving the exclusive upload JWT.

This is a reproducible source-level mechanism, not a confirmed attribution of our historical 401 to that deployed revision. We cannot identify the hosted deployment from the static SERVER_INFO version.

Minimal offline reproduction (synthetic strings; no network or credentials)

import assert from 'node:assert/strict';
const original = new Headers({ Authorization: 'Bearer synthetic-upload-session' });
const composed = new Headers([
  ...original.entries(),
  ['Authorization', 'Bearer synthetic-mcp-connection'],
]);
assert.equal(composed.get('authorization'), 'Bearer synthetic-upload-session');
// Fails: actual is two comma-separated bearer values.

An offline test extracting the composition expression from the pinned source failed as expected. A restricted pure-function composition proposal passed 10 tests, including normal administrative auth, rejecting arbitrary overrides, exact account/origin/method/path/query restrictions, redirect handling and multipart body preservation. This is not an integrated workerd test or a deployable security policy.

Observed hosted behavior (sanitized)

  • Administrative authenticated reads succeed from both coordinator and delegated contexts; this does not prove identical OAuth identity or historical scopes.
  • Creation of one upload session succeeded; the subsequent single POST /accounts/{account_id}/workers/assets/upload?base64=true returned HTTP 401.
  • Local checks reported the upload JWT not expired at send and the constructed Authorization matching that JWT. These checks do not prove signature validation or the outbound header after proxy processing.
  • No usable JSON error body or provider error codes were recovered.
  • No retry, version publication or traffic activation followed the rejected diagnostic upload.
  • Event window for deployment correlation: 2026-11-09 01:18:46–01:20:46 UTC.

Both native fetch and cloudflare.request traverse GlobalOutbound in the inspected implementation; the wrapper schema does not expose an authentication selector. Reconnecting OAuth is therefore not an evidence-backed fix for this particular failure.

Requested clarification / fix

  1. Can you correlate the hosted deployment revision for the incident window and confirm whether outbound Authorization would contain a single upload bearer or combined values? Please do not disclose tokens or raw headers.
  2. Is there an officially supported mechanism for upload-session JWT authentication through Code Mode?
  3. If not, please consider a host-authorized assets-upload path that preserves exactly the session JWT for the admitted account/session/endpoint while retaining normal administrative authentication, permission checks and refusal handling.

Simply allowing arbitrary sandbox-provided Authorization is not the proposed fix. Any exception needs trusted host-side admission and account/session binding; JWT shape alone is not authorization. Redirects and retries must also respect the explicitly admitted operation count.

No tokens, cookies, account identifiers, private repository details or application payloads are included. We have not changed the hosted service, used an alternative provider route or repeated the rejected upload to test this hypothesis.

Lingua principale
TypeScript
Stelle
1.1k
Fork
171
Merge medio
1g 2h
PR unite (30g)
60

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di cloudflare/mcp

Tutte le issue di cloudflare/mcp

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.