Skip to content

fix: move API token injection to GlobalOutbound via props - #28

Merged
mattzcarey merged 1 commit into
mainfrom
fix/token-injection-globaloutbound
Feb 20, 2026
Merged

fix: move API token injection to GlobalOutbound via props#28
mattzcarey merged 1 commit into
mainfrom
fix/token-injection-globaloutbound

Conversation

@mattzcarey

Copy link
Copy Markdown
Contributor

Summary

  • Moves API token injection from the dynamic worker isolate to GlobalOutbound via the props mechanism
  • GlobalOutbound now accepts { apiToken: string } props and injects the Authorization header on allowed outbound requests
  • The dynamic worker code no longer receives or references the API token — typeof apiToken is undefined inside user code
  • Prevents token theft via globalThis.fetch proxy attacks since the token is added outside the user code isolate

Test plan

  • typeof apiToken returns undefined in user code
  • cloudflare.request() still works (REST + GraphQL)
  • Fetch proxy attack (globalThis.fetch = ...) returns null for captured Authorization header
  • Outbound fetch to non-CF domains still blocked
  • All 69 unit tests pass
  • npm run format clean
  • Deployed and verified on staging

The API token was previously passed into the dynamic worker isolate,
where user code could steal it by proxying globalThis.fetch. Now the
token is passed to GlobalOutbound via props and injected as an
Authorization header outside the user code isolate.
@mattzcarey
mattzcarey merged commit b417b2a into main Feb 20, 2026
1 check passed
@mattzcarey
mattzcarey deleted the fix/token-injection-globaloutbound branch February 20, 2026 00:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant