Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions packages/devtools_shared/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ Copyright 2025 The Flutter Authors
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file or at https://developers.google.com/open-source/licenses/bsd.
-->
# 13.0.2
* Validate the `devtoolsOptionsUri` query parameter in the extension enabled
state handler so it must be a `file:` URI named `devtools_options.yaml`,
preventing arbitrary file writes by the DevTools server process.

# 13.0.1
* Handle null values for `FlutterStore.flutterClientId`.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,27 @@ extension _ExtensionsApiHandler on Never {
final devtoolsOptionsFileUriString =
queryParams[ExtensionsApi.devtoolsOptionsUriPropertyName]!;
final devtoolsOptionsFileUri = Uri.parse(devtoolsOptionsFileUriString);

// Validate that the URI is a local file URI whose file name is exactly
// 'devtools_options.yaml'. Accepting arbitrary URIs from the query string
// would allow an untrusted caller to create or overwrite any file writable
// by the DevTools server process. Resolving the name through
// `Uri.toFilePath()` + `p.basename` handles both '/' and '\' path
// separators, so the check holds for Windows file URIs as well. Requiring
// an empty host rejects UNC paths (e.g. `file://server/share/...`) and
// keeps `toFilePath()` from throwing on a non-local authority.
final isFileUri = devtoolsOptionsFileUri.scheme == 'file' &&
devtoolsOptionsFileUri.host.isEmpty;
final fileName = isFileUri
? p.basename(devtoolsOptionsFileUri.toFilePath())
: '';
if (!isFileUri || fileName != 'devtools_options.yaml') {
return api.badRequest(
'Invalid devtoolsOptionsUri: must be a file: URI named '
"'devtools_options.yaml'.",
);
}

final extensionName = queryParams[ExtensionsApi.extensionNamePropertyName]!;

final activate = queryParams[ExtensionsApi.enabledStatePropertyName];
Expand Down
1 change: 1 addition & 0 deletions packages/devtools_shared/lib/src/server/server_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import 'dart:io';
import 'package:collection/collection.dart';
import 'package:dtd/dtd.dart';
import 'package:meta/meta.dart';
import 'package:path/path.dart' as p;
import 'package:shelf/shelf.dart' as shelf;
import 'package:vm_service/vm_service.dart';

Expand Down
2 changes: 1 addition & 1 deletion packages/devtools_shared/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
name: devtools_shared
description: Package of shared Dart structures between devtools_app, dds, and other tools.

version: 13.0.1
version: 13.0.2

repository: https://github.com/flutter/devtools/tree/master/packages/devtools_shared

Expand Down