Skip to content

Restrict web dev server to loopback by default - #187595

Merged
auto-submit[bot] merged 8 commits into
flutter:masterfrom
tamirenkhbayar3-cmd:fix-web-dev-server-localhost-default
Oct 15, 2026
Merged

auto-submit[bot] merged 8 commits into
flutter:masterfrom
tamirenkhbayar3-cmd:fix-web-dev-server-localhost-default

Conversation

@tamirenkhbayar3-cmd

@tamirenkhbayar3-cmd tamirenkhbayar3-cmd commented Jun 5, 2026 •

Copy link
Copy Markdown
Contributor

This PR changes the Flutter web dev server default host from any to localhost.
Normal web debug runs now bind to loopback by default instead of all IPv4 interfaces.
Developers who intentionally need LAN/all-interface access can still opt in with
--web-hostname any.

This also restricts the project-root fallback used for Dart source lookups to
.dart paths, so unrelated project files are not returned through that lookup.

Fixes: no public GitHub issue is associated with this PR. This came from a Google
OSS VRP/security report, which is not publicly linkable from GitHub. If there is
an internal tracker that should be referenced, I can add it.

No changes were needed in the flutter/tests repo.

Test Coverage

Added/updated tests covering:

  • default web dev server configuration binds to loopback;
  • explicit host: any still binds to InternetAddress.anyIPv4;
  • non-Dart project-root files are not served through dartSourceContents.

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.

@github-actions github-actions Bot added the tool Affects the "flutter" command-line tool. See also t: labels. label Jun 5, 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 changes the default host for the web development server from 'any' to 'localhost' (using a new webDevServerDefaultHost constant) and restricts the local file system lookup in WebAssetServer to paths ending with .dart. It also adds and updates unit tests to verify these changes, including a test ensuring non-Dart files are not served from the project root. There are no review comments, and I have no feedback to provide.

@tamirenkhbayar3-cmd

Copy link
Copy Markdown
Contributor Author

Hi, I updated the branch again. The PR appears to be waiting for Googler approval / CICD label before required checks can complete. Please let me know if I need to change anything. Thanks!

@bkonyi
bkonyi requested review from bkonyi and nshahan and removed request for bkonyi and nshahan June 16, 2026 21:11
@bkonyi

bkonyi commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Hi @tamirenkhbayar3-cmd, it looks like this PR doesn't have a description. Can you please update the description and fill out the PR template and let me know when you're ready for a review? Also, is there an issue associated with this fix?

@bkonyi bkonyi added the waiting for response The Flutter team cannot make further progress on this issue until the original reporter responds label Jun 16, 2026
@tamirenkhbayar3-cmd

Copy link
Copy Markdown
Contributor Author

Thanks for the ping. I updated the PR description and filled out the template.

There is no public GitHub issue associated with this PR. It came from a Google
OSS VRP/security report, which is not publicly linkable from GitHub. If there is
an internal tracker that should be referenced, I can add it.

Ready for review from my side.

@github-actions github-actions Bot removed the waiting for response The Flutter team cannot make further progress on this issue until the original reporter responds label Jun 17, 2026
@bkonyi
bkonyi requested review from bkonyi and nshahan July 8, 2026 15:43
bkonyi
bkonyi previously approved these changes Jul 8, 2026
@bkonyi bkonyi added the CICD Run CI/CD label Jul 8, 2026
@flutter-dashboard

Copy link
Copy Markdown

This pull request executed golden file tests, but it has not been updated in a while (20+ days). Test results from Gold expire after as many days, so this pull request will need to be updated with a fresh commit in order to get results from Gold.

For more guidance, visit Writing a golden file test for package:flutter.

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

@flutter-dashboard flutter-dashboard Bot removed the CICD Run CI/CD label Sep 9, 2026
@bkonyi bkonyi added the CICD Run CI/CD label Oct 14, 2026
bkonyi
bkonyi previously approved these changes Oct 14, 2026

@bkonyi bkonyi 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.

Thanks for the fix! Restoring localhost as the default host (which regressed in #172175) makes sense.

LGTM! We'll just need one more review before this can land.

nshahan
nshahan previously approved these changes Oct 15, 2026
Removes redundant `host: 'localhost'` arguments in `web_asset_server_test.dart` now that `WebDevServerConfig.host` defaults to `webDevServerDefaultHost` (`'localhost'`).
@bkonyi
bkonyi dismissed stale reviews from nshahan and themself via dfdcfd0 October 15, 2026 16:59
@flutter-dashboard flutter-dashboard Bot removed the CICD Run CI/CD label Oct 15, 2026
@bkonyi bkonyi added the CICD Run CI/CD label Oct 15, 2026

@bkonyi bkonyi 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.

Still LGTM!

@bkonyi
bkonyi requested a review from nshahan October 15, 2026 17:14

@nshahan nshahan 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.

Still LGTM.

@bkonyi bkonyi added the autosubmit Merge PR when tree becomes green via auto submit App label Oct 15, 2026
@auto-submit
auto-submit Bot added this pull request to the merge queue Oct 15, 2026
Merged via the queue into flutter:master with commit 1f57562 Oct 15, 2026
30 checks passed
@flutter-dashboard flutter-dashboard Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Oct 15, 2026
auto-submit Bot pushed a commit to flutter/packages that referenced this pull request Oct 16, 2026
flutter/flutter@5c7e45a...a3d71d8

2026-10-16 [email protected] 0 Initialize variables in the DlComplexityPathReceiver helper (flutter/flutter#194540)
2026-10-16 [email protected] Roll Fuchsia Test Scripts from V-qQL4158Nw6L-QLi... to 2T18KC7-LDQtmQiLP... (flutter/flutter#194527)
2026-10-16 [email protected] Remove BorderMaskBlur (flutter/flutter#194508)
2026-10-16 [email protected] Roll Skia from a577264dc087 to 470b8816a261 (1 revision) (flutter/flutter#194526)
2026-10-16 [email protected] [ios] Use DFS traversal to find engines of a scene automatically (rather than manually manage the engines list) (flutter/flutter#192457)
2026-10-16 [email protected] [Skia][DisplayList] Map local bounds through the local matrix in DlLocalMatrixImageFilter (flutter/flutter#193963)
2026-10-16 [email protected] [framework] Fix avoid_setters_without_getters warnings on mixin declarations  (flutter/flutter#193856)
2026-10-16 [email protected] Roll Dart SDK from 84686ea04815 to 55a734a01fb1 (3 revisions) (flutter/flutter#194522)
2026-10-16 [email protected] Roll Skia from d131b7789482 to a577264dc087 (7 revisions) (flutter/flutter#194514)
2026-10-16 [email protected] Roll Fuchsia GN SDK from PDJz3b3CL31uoLOkD... to kFdyRnojbVy0cxvRZ... (flutter/flutter#194510)
2026-10-16 [email protected] Roll GN to f9eca75ae554 (flutter/flutter#194471)
2026-10-16 [email protected] refactor(flutter_tools): migrate RunCommand and RunCommandBase to OptionDescriptor and OptionBundle (flutter/flutter#194362)
2026-10-15 [email protected] refactor(flutter_tools): finish TestCommand OptionDescriptor and OptionBundle migration (flutter/flutter#194361)
2026-10-15 [email protected] [iOS][a11y] Fix VoiceOver announcement for unfocused password fields (flutter/flutter#192851)
2026-10-15 [email protected] Roll pub packages (flutter/flutter#194477)
2026-10-15 [email protected] refactor(flutter_tools): finish DriveCommand OptionDescriptor migration (flutter/flutter#194360)
2026-10-15 [email protected] [flutter_tools] Roll package:vm_service to 15.4.0 (flutter/flutter#194467)
2026-10-15 [email protected] refactor(flutter_tools): migrate AttachCommand to OptionDescriptor and OptionBundle (flutter/flutter#194359)
2026-10-15 [email protected] [flutter_tools] Inject dependencies into update-packages and package_map (flutter/flutter#194046)
2026-10-15 [email protected] [impeller] parallelize opengles shader compiles (flutter/flutter#194022)
2026-10-15 [email protected] Roll pub packages (flutter/flutter#194469)
2026-10-15 [email protected] Restrict web dev server to loopback by default (flutter/flutter#187595)
2026-10-15 [email protected] Roll Packages from a1ed23c to da40eaf (33 revisions) (flutter/flutter#194459)
2026-10-15 [email protected] [web] Render soft hyphens on Skwasm (flutter/flutter#193850)
2026-10-15 [email protected] refactor(flutter_tools): migrate AssembleCommand to OptionDescriptor (flutter/flutter#194358)
2026-10-15 [email protected] [windows] Add OpenGL golden test against ANGLE at D3D11 feature level 10_0 (flutter/flutter#194321)

If this roll has caused a breakage, revert this CL and set the roller
to dry run mode using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC [email protected],[email protected] on the revert to ensure that a human
is aware of the problem.

To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
suryaKommana2662 pushed a commit to suryaKommana2662/flutter that referenced this pull request Oct 29, 2026
This PR changes the Flutter web dev server default host from `any` to
`localhost`.
Normal web debug runs now bind to loopback by default instead of all
IPv4 interfaces.
Developers who intentionally need LAN/all-interface access can still opt
in with
`--web-hostname any`.

This also restricts the project-root fallback used for Dart source
lookups to
`.dart` paths, so unrelated project files are not returned through that
lookup.

Fixes: no public GitHub issue is associated with this PR. This came from
a Google
OSS VRP/security report, which is not publicly linkable from GitHub. If
there is
an internal tracker that should be referenced, I can add it.

No changes were needed in the [flutter/tests] repo.

## Test Coverage

Added/updated tests covering:

- default web dev server configuration binds to loopback;
- explicit `host: any` still binds to `InternetAddress.anyIPv4`;
- non-Dart project-root files are not served through
`dartSourceContents`.

## Pre-launch Checklist

- [ ] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [ ] I read the [AI contribution guidelines] and understand my
responsibilities, or I am not using AI tools.
- [ ] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [ ] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [ ] I listed at least one issue that this PR fixes in the description
above.
- [x] I updated/added relevant documentation (doc comments with `///`).
- [x] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [ ] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [ ] 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/docs/contributing/Tree-hygiene.md#ai-contribution-guidelines
[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
[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

---------

Co-authored-by: tamirenkhbayar3-cmd <[email protected]>
Co-authored-by: Ben Konyi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CICD Run CI/CD tool Affects the "flutter" command-line tool. See also t: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants