fix: validate devtoolsOptionsUri in extensionEnabledState handler#9834
fix: validate devtoolsOptionsUri in extensionEnabledState handler#9834adilburaksen wants to merge 3 commits into
Conversation
…ledState handleExtensionEnabledState() accepted the devtoolsOptionsUri query parameter without validation and passed it directly to DevToolsOptions.setExtensionEnabledState(), which creates the file and parent directories if they do not exist. An untrusted caller could supply an arbitrary file: URI to create or overwrite any path writable by the DevTools server process. Add a guard that rejects URIs whose scheme is not 'file' or whose path does not end with 'devtools_options.yaml'. Both conditions must hold for a legitimate devtools options file.
There was a problem hiding this comment.
Code Review
This pull request adds validation for the devtoolsOptionsUri query parameter to ensure it is a local file URI pointing to a devtools_options.yaml file, mitigating potential file overwrite vulnerabilities. Feedback was provided to tighten the path validation logic, as the current implementation could match unintended filenames.
endsWith('devtools_options.yaml') matched paths like
'not_devtools_options.yaml'. Adding the path separator prefix
ensures only files literally named 'devtools_options.yaml' are accepted.
|
Friendly nudge — open ~18 days. Validates devtoolsOptionsUri in extensionEnabled to prevent the file-write primitive. Happy to address any feedback or add coverage if that helps move it along. |
| // string would allow an untrusted caller to create or overwrite any file | ||
| // writable by the DevTools server process. | ||
| if (devtoolsOptionsFileUri.scheme != 'file' || | ||
| !devtoolsOptionsFileUri.path.endsWith('/devtools_options.yaml')) { |
There was a problem hiding this comment.
will this forward slash work with windows file schemes?
kenzieschmoll
left a comment
There was a problem hiding this comment.
Please also add an entry to the devtools_shared changelog.
Resolve the file name via Uri.toFilePath() + p.basename instead of a forward-slash string match so the check holds for Windows file URIs (both '/' and '\' separators) and reject non-local (UNC) authorities. Bump devtools_shared to 13.0.2 and add a changelog entry.
|
Thanks for the review. Addressed both points in the latest commit:
The existing |
Summary
handleExtensionEnabledState()in_devtools_extensions.dartreadsdevtoolsOptionsUridirectly from query parameters and passes it without validation toDevToolsOptions.setExtensionEnabledState(), which creates the target file and any missing parent directories.An untrusted caller that can reach the DevTools server (e.g., another local process, or a browser tab via cross-origin requests) can create or overwrite any file writable by the server process:
The resulting file content is a valid YAML map:
Fix
Reject requests where
devtoolsOptionsUri:file:scheme, ordevtools_options.yamlBoth conditions are required for a legitimate DevTools options file. Any other value is rejected with HTTP 400.
Impact
Without the fix, any local process or browser tab able to reach the DevTools HTTP server can create or overwrite arbitrary files on the developer's machine with attacker-controlled YAML content.