GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Fix/adb shell injection by Abdullah-Builds · Pull Request #56 · google/artemis

Conversation

@Abdullah-Builds

@Abdullah-Builds Abdullah-Builds commented Sep 11, 2026

Copy link
Copy Markdown

Fixes #55

What

AndroidAdbDriver.launch_app / stop_app built adb shell command strings
by directly interpolating package_name with no validation, and
UnifiedMobileController.open_url wrapped url in naive single quotes
instead of proper shell escaping. Both are reachable from the MCP server
tools (launch_app, stop_app in artemis/mcp/adb_server.py) with
arbitrary string arguments and no sanitization anywhere in between, so a
crafted package_name or url could run arbitrary commands on the
connected device via the on-device shell.

Fix

  • Added _validate_package_name() in artemis/drivers/android/adb_driver.py,
    which checks the value against Android's package-name grammar
    (^[A-Za-z][A-Za-z0-9_]*(\.[A-Za-z][A-Za-z0-9_]*)+$) before it is used to
    build a shell command. Called at the top of both launch_app and
    stop_app, so it covers every caller (MCP tools and the LangChain agent
    tool path) at a single choke point.
  • Replaced the manual '{url}' wrapping in
    artemis/controllers/unified_controller.py's open_url with
    shlex.quote(url), so a URL containing a single quote can't break out of
    the quoting.

Why here and not only at the MCP tool layer

find_package() in artemis/tools/mobile/launch_app.py already validates
resolved package names against the device's installed package list, but
only on the LangChain agent path. The MCP server calls
(artemis/mcp/adb_server.py) skip that entirely. Validating inside the
driver methods themselves means the guarantee holds regardless of which
caller reaches them, rather than relying on every current and future caller
to remember to sanitize first.

Testing

  • python3 -m py_compile on both changed files.
  • Manually verified the regex accepts real package names
    (com.android.settings, com.google.android.gm, ...) and rejects
    injection payloads (com.android.settings; reboot,
    com.foo$(rm -rf /sdcard), com.foo`id`, com.foo && echo pwned).
  • Verified shlex.quote() neutralizes a single-quote-breakout URL payload
    (http://x'; reboot; echo ').
  • make test, make lint, make typecheck (please re-run in CI — not run
    against a live device in this environment).

Compatibility

Purely additive validation on two methods; no behavior change for valid
package names or URLs. Callers passing a malformed package name now get a
ValueError (surfaced as a failed launch/stop) instead of silently reaching
the device shell.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Abdullah-Builds added 2 commits September 12, 2026 03:30
@Abdullah-Builds
Fix analyzer clip framerate by explicitly setting ffmpeg output -r to…
f07cf1e
… requested fps
@Abdullah-Builds
fix: validate package_name and quote url to prevent shell injection
8604cf7
@Abdullah-Builds

Abdullah-Builds commented Sep 12, 2026

Copy link
Copy Markdown
Author

@weilinliu I am following up on this PR .Waiting for the approvals

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Abdullah-Builds

Abdullah-Builds commented Sep 12, 2026

Copy link
Copy Markdown
Author

@somew1nd I am following up on this PR. Waiting for the approvals

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@basil-k-aji-dev basil-k-aji-dev mentioned this pull request Sep 14, 2026
fix(adb): stop interpolating package names and URLs into device shell strings #85
Closed
@Abdullah-Builds
Merge branch 'main' into fix/adb-shell-injection
cf76f59
@Abdullah-Builds

Abdullah-Builds commented Oct 21, 2026

Copy link
Copy Markdown
Author

@google-admin waiting for the approval

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Abdullah-Builds

Abdullah-Builds commented Oct 23, 2026

Copy link
Copy Markdown
Author

@somew1nd waiting for approvals

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Shell command injection via unsanitized package_name/url in Android driver and MCP tools

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@Abdullah-Builds
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.