Skip to content

fix(producer): trusted renders refuse outside-linked compositions unless --include-outside-files - #8024

Merged
jrusso1020 merged 2 commits into
mainfrom
fix/outside-compositions-need-include-flag
Nov 17, 2026
Merged

jrusso1020 merged 2 commits into
mainfrom
fix/outside-compositions-need-include-flag

Conversation

@jrusso1020

@jrusso1020 jrusso1020 commented Nov 17, 2026 •

Copy link
Copy Markdown
Collaborator

What

In a trusted local render (hyperframes render), a sub-composition or entry file whose real file is outside the project now stops the render before it starts, unless --include-outside-files is passed. The error names the file and the flag. Untrusted renders already refused these files, and they still do.

Behavior change: a shared scene linked in from outside the project used to render without the flag. Now it needs the flag, even when it has no scripts.

Why

Without the flag, a trusted local render leaves out .js files outside the project, so outside scripts don't run unless the person asks. A linked composition file got around that. Its HTML is inlined into the render page, so inline scripts and event handlers in that outside file ran anyway.

Related work

Builds on the existing --include-outside-files policy (OutsideFilePolicy, outsideAssetRefusal in packages/producer/src/utils/paths.ts).

How

Claude Opus 5.5
  • compileForRender refuses an entry file inside the project whose real path leads outside it. It checks before reading the file, and only when outside assets are allowed and scripts are not.
  • assertSubCompositionsUsable, the pre-flight that already names every unusable data-composition-src, takes the outside-file policy and reports such a sub-composition as "it is outside the project and its scripts would run; pass --include-outside-files to hyperframes render to run it". The check covers nested sub-compositions too, since the pre-flight recurses.
  • plan() / distributed planning go through the same compile stage, so the same refusal covers them.

Why refuse instead of stripping scripts: a script stripper has to find every way HTML can run code: <script>, on* attributes, javascript: URLs, srcdoc, SVG, and <template> content, which linkedom's querySelectorAll does not see. Missing any of them puts the hole back. A refusal with a clear message has no such gap. Dropping the scene silently was also ruled out, because the pre-flight exists so a render never loses a scene without an error.

Limit: the check runs once in the pre-flight. parseSubCompositions and the entry read don't repeat it, so a file swapped for an outside link after the pre-flight and before the read would still be inlined. Closing that needs the readers to check too. I left it out here to keep this change small.

Test plan

  • Unit tests added/updated: in outsideProjectAssets.test.ts, "trusted local renders still import outside files" no longer expects a linked outside scene to come in. A new it.each over a symlinked scene and a symlinked entry checks that a trusted render and a trusted plan() both reject with the flag message, and that the render includes the scene once --include-outside-files is set. Fails without the fix: both new cases fail against main's htmlCompiler.ts with "promise resolved instead of rejecting". With the fix the file passes 17/17.
  • packages/cli/src/utils/receivedRender.test.ts: the parity helper that checks the compiler reaches an outside file through a scene in a linked folder outside the project now passes includeOutsideScripts: true, since that scene is refused without it. 57/57 pass (1 skipped).
  • Manual testing performed
  • Documentation updated (if applicable)
  • Comments follow CONTRIBUTING.md "Comments"

— Rames

🤖 Generated with Claude Code

…ess --include-outside-files

A sub-composition or entry file whose real file is outside the project is
inlined into the render page, so its scripts run even though outside .js files
are left out without the flag. The pre-flight now refuses it with a message
naming --include-outside-files.

— Rames

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@vanceingalls vanceingalls left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved at 82bf5fb. linksOutside realpaths both the project root and the file (realpathSync.native) and uses path.relative with ../absolute detection.

  • Containment: a symlinked root (/tmp → /private/tmp) isn't falsely refused, /proj vs /proj-evil is handled, and Windows drive and case differences are covered.
  • Scope: the gate is assetRoot === undefined, so untrusted renders are unchanged, and plan() shares the same compile stage.

Should-fix:

  1. Studio and benchmark renders: studioServer.ts:696-717 and benchmark.ts:110-135 call compileForRender without includeOutsideScripts. A Studio or benchmark render of a project with a linked outside scene is now refused, and the error points at a CLI flag those surfaces can't set. Either give them a way to opt in, or word the error for where it's raised.
  2. TOCTOU: the known gap is cheap to narrow by repeating linksOutside where the file is actually read (resolveHtml, parseSubCompositions).
  3. Wording: the error says "its scripts would run" even for a script-free file. Cosmetic.

@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Edit accuracy: accurate 267 (base branch 267), smooth 102 of those

The gate passes.
Smoothness is reported in the artifact, not gated. A case fails only if it fails 2 of 3 runs.

Quarantined, measured but not gated (8)

@miguel-heygen miguel-heygen left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed at 82bf5fb9. A trusted render without --include-outside-files now refuses a composition file whose real path is outside the project, before any of its markup is inlined. I checked every other way such a file could reach the render page and found none open.

Strengths

  • The check is in the existing pre-flight (htmlCompiler.ts:343-346), which already recurses, so a linked scene nested any number of levels down is named in the same error list as every other unusable scene.
  • linksOutside resolves both the project root and the file to real paths before comparing (outsideFile.ts:146, safePath.ts:37-44). A symlink, a .. reference (which resolveCompositionFile returns when outside assets are allowed) and a symlinked project root all come out right.
  • Refusing instead of stripping scripts is the right call for the reason the body gives.

Other paths to the render page, checked at this head (Rule 2)

  • An entry outside the project: the CLI refuses it before compile (cli/src/utils/compositionEntry.ts:47), so compileForRender only gating entries inside the project is enough.
  • A sub-composition the runtime fetches itself (core/src/runtime/compositionLoader.ts:732-799), or an outside .html in an iframe: the render file server refuses outside .html. COPIED_TYPE (outsideFile.ts:17) has no text/html, so outsideAssetRefusal answers file_type and fileServer.ts:851 skips the file.
  • The received-files rule sets assetRoot, so this check stays off and escapesAssetRoot already refuses. plan() and distributed renders go through the same compile stage.
  • Studio and benchmark renders: as Vance noted, they call compileForRender without includeOutsideScripts (cli/src/server/studioServer.ts:696-717, cli/src/commands/benchmark.ts:110-135). They now refuse a linked outside scene with a message naming a CLI flag they cannot pass. That fails closed, so it is not a blocker, but +1 to his should-fix.

Important

  • The new it.each covers a symlinked scene and a symlinked entry at the top level. Nothing pins the two other shapes this check claims to cover: a nested linked scene (one level down, through the pre-flight's recursion) and a plain data-composition-src="../shared/scene.html" with no symlink. Two more rows in the same table would keep a later refactor of the recursion or of resolveCompositionFile from silently dropping them.

Nit

  • The entry error reads as a broken sentence: Entry file ${htmlPath} ${OUTSIDE_COMPOSITION_NEEDS_FLAG} gives "Entry file /p/index.html it is outside the project and its scripts would run; ..." (htmlCompiler.ts:2247). Dropping the leading "it" from the shared text, or using "Entry file X is outside the project ..." here, fixes both call sites.

Also covered by Vance and not repeated: the window between the pre-flight check and the read, and "its scripts would run" on a script-free file.

Verdict: APPROVE
Reasoning: The refusal sits where every composition file is first examined, uses real paths on both sides, and I found no other route for outside markup into a trusted render; the gaps left are tests and wording, not leaks.

… in the received-render parity test

The parity test checks that the render compiler reaches an outside file through a
scene in a linked folder outside the project. Trusted renders now refuse that scene
unless --include-outside-files is passed, so the helper passes it.

— Rames

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@vanceingalls vanceingalls left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-approved at a7d2d02. The only change since 82bf5fb is a test: the received-render parity test now passes --include-outside-files for its linked outside scene. The source is unchanged.

@jrusso1020
jrusso1020 added this pull request to the merge queue Nov 17, 2026
Merged via the queue into main with commit 00d03a4 Nov 17, 2026
139 of 140 checks passed
@jrusso1020
jrusso1020 deleted the fix/outside-compositions-need-include-flag branch November 17, 2026 05:19
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.

3 participants