Repository navigation
Conversation
adb shell joins its arguments into one command line that the device's sh parses, so a package name containing shell metacharacters could run arbitrary commands on the device. The file manager already quotes its arguments with quoteShellArg; the app actions (launch, force stop, clear data, uninstall, app settings, dumpsys label lookup), the launcher component and the quick-settings tile list did not. Every interpolated package name is now quoted, and package names are also validated against the Android application ID grammar before any command is built, so a malformed name is logged and refused instead of sent. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Author
|
Closing for now; will reopen when the batch of fixes is ready for review. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
adb shelljoins its arguments into a single command line that the device'sshparses, so a package name containing shell metacharacters (;,$(...), backticks, spaces) would run arbitrary commands on the device. The file manager already quotes its arguments withquoteShellArg, but the app actions did not.launchPackage,forceStopPackage,clearPackageData,uninstallPackage(mobile path),uninstallPackageUser0,openAppSettingsand_getAppLabelnow pass the package name throughquoteShellArg.setDefaultLauncherquotes the launcher component andenableWirelessDebuggingquotes the tile list it reads back from the device, since both come from device output rather than the catalog.isValidAndroidPackageName(lib/services/android_package_name.dart) checks the Android application ID grammar. The package actions refuse and log an error for anything that fails it, as defence in depth ahead of the quoting.No behaviour change for well-formed package names:
pm clear com.example.appbecomespm clear 'com.example.app', which the device shell reads identically. This is the same quoting the file manager has used on Windows, macOS and Linux.Why
Package names reach these calls from
pm list packagesoutput, the catalog, and the launcher list. A hostile or malformed source should not be able to execute shell on the bike.How it was verified
dart format,flutter analyze,flutter test(121 tests) all pass on Flutter 3.44.4.test/adb_service_test.dartcapture the exact argument lists sent torunAdbCommandand assert the quoted forms for launch, force stop, clear data, uninstall for user 0, app settings, launcher component and tile list. A further test sendscom.example.app; rm -rf /sdcardthrough every package action and asserts that no command is run and each refusal is logged.test/android_package_name_test.dartcovers accepted and rejected names.Not verified on a Peloton: I have no hardware. The quoting form is identical to what the file manager already sends, so an on-device sanity check of Launch, Force stop and Clear data from the Installed App Manager would be welcome.
🤖 Generated with Claude Code