4.9 KiB
id, title, status, wave, depends_on, plan, requirements, acceptance_criteria, system_design
| id | title | status | wave | depends_on | plan | requirements | acceptance_criteria | system_design | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 01-runtime | Enable trusted same-origin runtime requests | done | 1 | plan.md |
|
|
|
Task 01: Enable trusted same-origin runtime requests
Summary
Update both browser sandbox declarations and the host-owned startup request. Keep runtime capability validation and all ordinary backend checks effective.
In scope
- Use TDD for exact iframe/CSP sandbox token sets and startup credential behavior.
- Add
allow-same-origintoWebAppFrameandBuildContentSecurityPolicytogether. - Use
credentials: "same-origin"inhostRuntimeBootstrap.checkContext. - Replace comments and assertions that describe an opaque browser boundary.
- Test cookies alongside invalid, expired, and stale tokens and denied writes.
- Preserve immutable artifacts, startup messages, CSP sources, and exact ancestors.
Out of scope
- Broad CORS changes, cross-origin cookie forwarding, fetch interception, and a bridge.
- Editing retained canvas packages or adding a mode/feature toggle.
- New UI composition and Cloudflare account changes.
Acceptance
- Framed and top-level runtime documents retain their served origin; both policy layers agree.
- Startup uses same-origin cookies; a cookie cannot replace a token or bypass capability grant/input validation.
- Existing startup, retry, source validation, and artifact immutability tests pass with the revised trust assertions.
Verification
Run focused RED tests before changing production code. Do not weaken unrelated assertions. Run each command from the repository root:
(cd apps/backend && go test ./internal/plugins/webapp ./internal/plugins ./internal/backendapp)
(cd apps/web && pnpm exec vitest run components/plugins/web-app-frame.test.tsx components/plugins/web-app-startup.test.ts components/plugins/canvas-page.test.tsx components/settings/canvas-host-route.test.tsx components/settings/canvas-host-components.test.tsx)
(cd apps/web && pnpm run typecheck)
git diff --check
Add TestRuntimeCookieDoesNotReplaceCapability and a protocol test named
TestWebAppProtocolCookieDoesNotExpandPermissions. Extend the existing policy
test to compare the parsed sandbox token set, rather than a substring that
would also pass with unintended permissions.
Files likely touched
apps/web/components/plugins/web-app-frame.tsxand its component test.apps/backend/internal/plugins/webapp/policy.goandpolicy_test.go.apps/backend/internal/plugins/webapp/runtime_bootstrap.goandruntime_test.go.apps/backend/internal/plugins/webapp_protocol_test.go.apps/backend/internal/backendapp/middleware_test.go, if same-origin request coverage is missing.
Dependencies
None. Read scoped backend and web AGENTS.md before implementation.
Risks
Same-origin code gains ordinary user-session authority. Capability tests must not falsely assert that the runtime limits every possible action of that code.
Parallelism
sequential
Inputs
- Runtime design.
- Decision.
- Existing
Runtime.Serve,corsMiddleware, andhandleWebAppProtocoltests.
Results
Implemented trusted same-origin runtime transport. The iframe and runtime
response CSP both declare allow-same-origin, and the host startup bootstrap
uses credentials: "same-origin" for its relative context request. Runtime
token validation, scope checks, protocol grants, and input validation remain
unchanged. Added regressions for the exact CSP sandbox token set, startup
credentials, cookie-plus-capability behavior, and cookie-plus-protocol
permissions.
Checks passed:
go test ./internal/plugins/webapp ./internal/plugins ./internal/backendapppnpm exec vitest run components/plugins/web-app-frame.test.tsx components/plugins/web-app-startup.test.ts components/plugins/canvas-page.test.tsx components/settings/canvas-host-route.test.tsx components/settings/canvas-host-components.test.tsxpnpm run typecheckgit diff --check