Skip to content

Revert: [flutter_tools] Fix local CanvasKit asset paths on Windows - #195635

Merged
jtmcdole merged 1 commit into
flutter:masterfrom
flutteractionsbot:revert-193776-1793311572
Oct 29, 2026
Merged

jtmcdole merged 1 commit into
flutter:masterfrom
flutteractionsbot:revert-193776-1793311572

Conversation

@flutteractionsbot

@flutteractionsbot flutteractionsbot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Reverts: [flutter_tools] Fix local CanvasKit asset paths on Windows

Initiated by: @hellohuanlin

Reason for reverting: This is the first commit that breaks the tree

Original PR Author: @meg4cyberc4t

Reviewed By: @mdebbar

The original PR description is provided below:

On Windows, converting a CanvasKit request URI to a filesystem path before matching the canvaskit/ prefix causes valid asset requests to return HTTP 404. Match the URI path segments first, then build the asset path with the filesystem's path context.

Adds hermetic regression coverage for POSIX and Windows paths, including root and Chromium JavaScript/Wasm assets, response bodies and headers, and rejection of invalid CanvasKit paths.

Fixes #193505.

Pre-launch Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

If this change needs to override an active code freeze, provide a comment explaining why. The code freeze workflow can be overridden by code reviewers. See pinned issues for any active code freezes with guidance.

Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the gemini-code-assist bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.

@flutter-dashboard flutter-dashboard Bot added the CICD Run CI/CD label Oct 29, 2026
@github-actions github-actions Bot added the tool Affects the "flutter" command-line tool. See also t: labels. label Oct 29, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request refactors CanvasKit asset serving in FlutterWebPlatform by introducing the _canvasKitFile helper and simplifying path resolution from URIs, while deleting the corresponding test file. A security review highlights that this simplified path resolution introduces a path traversal vulnerability, as it lacks validation to ensure the resolved file path remains strictly within the designated CanvasKit directory.

}

final File canvasKitFile = _fileSystem.file(filePath);
final File canvasKitFile = _canvasKitFile(relativePath);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

security-high high

Reverting this commit re-introduces a Path Traversal vulnerability. By using _fileSystem.path.fromUri(request.url) and only checking if the path starts with canvaskit/, a request with directory traversal sequences (e.g., canvaskit/../../etc/passwd) can escape the CanvasKit directory and access arbitrary files on the host system.

To mitigate this, validate that the resolved canvasKitFile path is strictly within the expected CanvasKit directory using _fileSystem.path.isWithin before serving the file.

Suggested change
final File canvasKitFile = _canvasKitFile(relativePath);
final File canvasKitFile = _canvasKitFile(relativePath);
final String canvasKitPath = _fileSystem.path.join(
_artifacts.getHostArtifact(HostArtifact.flutterWebSdk).path,
'canvaskit',
);
if (!_fileSystem.path.isWithin(canvasKitPath, canvasKitFile.path)) {
return shelf.Response.notFound('Not a CanvasKit file request');
}

@hellohuanlin hellohuanlin added the autosubmit Merge PR when tree becomes green via auto submit App label Oct 29, 2026
@b-luk b-luk added the emergency Jump the queue; land PR in front of all others; only use for emergencies label Oct 29, 2026
@flutter-dashboard

Copy link
Copy Markdown

Detected the emergency label.

If you add the autosubmit label, the bot will wait until all presubmits pass but ignore the tree status, allowing fixes for tree breakages while still validating that they don't break any existing presubmits.

The "Merge" button is also unlocked. To bypass presubmits as well as the tree status, press the GitHub "Add to Merge Queue".

@jtmcdole
jtmcdole added this pull request to the merge queue Oct 29, 2026
Merged via the queue into flutter:master with commit ef1103b Oct 29, 2026
34 of 35 checks passed
@flutter-dashboard flutter-dashboard Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Oct 29, 2026
@flutteractionsbot
flutteractionsbot deleted the revert-193776-1793311572 branch October 29, 2026 23:03
molchanovia added a commit to molchanovia/flutter that referenced this pull request Nov 1, 2026
Reland flutter#193776, reverted by flutter#195635. Match CanvasKit requests by URI path
segments before constructing filesystem paths, preserving containment
checks and POSIX/Windows regression coverage.

Pass MustacheTemplateRenderer to FlutterWebPlatform.start in the regression
tests to satisfy the required templateRenderer parameter added by flutter#194062.
jpohhhh pushed a commit to Telosnex/flutter that referenced this pull request Nov 5, 2026
…flutter#195770)

<!--
Thanks for filing a pull request!
Reviewers are typically assigned within a week of filing a request.
To learn more about code review, see our documentation on Tree Hygiene:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md
-->

Relands flutter#193776, reverted by flutter#195635.

On Windows, converting a CanvasKit request URI to a filesystem path
before matching `canvaskit/` causes valid asset requests to return HTTP
404. Match URI path segments first, then construct and validate the
filesystem path. Restore regression coverage for POSIX and Windows
paths, including JavaScript/Wasm assets, response bodies and headers,
and invalid paths.

The regression tests now pass `MustacheTemplateRenderer` to
`FlutterWebPlatform.start`, addressing the required `templateRenderer`
parameter introduced by flutter#194062 that caused the original tree breakage.

Fixes flutter#193505.

## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [AI contribution guidelines] and understand my
responsibilities, or I am not using AI tools.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I updated/added relevant in-code documentation (doc comments with
`///`).
- [x] If this PR introduces a new feature or capability, I created and
linked a website documentation issue or PR in [flutter/website] (or
verified none is needed).
- [x] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [x] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [x] All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel
on [Discord].

If this change needs to override an active code freeze, provide a
comment explaining why. The code freeze workflow can be overridden by
code reviewers. See pinned issues for any active code freezes with
guidance.

**Note**: The Flutter team is currently trialing the use of [Gemini Code
Assist for
GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code).
Comments from the `gemini-code-assist` bot should not be taken as
authoritative feedback from the Flutter team. If you find its comments
useful you can update your code accordingly, but if you are unsure or
disagree with the feedback, please feel free to wait for a Flutter team
member's review for guidance on which automated comments should be
addressed.

<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview
[AI contribution guidelines]:
https://github.com/flutter/flutter/blob/main/CONTRIBUTING.ai.md
[Tree Hygiene]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md
[test-exempt]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md
[Features we expect every widget to implement]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[flutter/website]: https://github.com/flutter/website
[breaking change policy]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes
[Discord]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md
[Data Driven Fixes]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CICD Run CI/CD emergency Jump the queue; land PR in front of all others; only use for emergencies tool Affects the "flutter" command-line tool. See also t: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

flutter test --platform chrome hangs/fails on Windows: CanvasKit assets 404 due to backslash path from path.fromUri

4 participants