🏠 Project Page | 🛠️ Hijacking Tool | 📃 Paper
This repository contains code & data for the paper: "Hijacking JARVIS: Benchmarking Mobile GUI Agents against Unprivileged Third Parties".
Please clone the project first.
$ git clone https://github.com/Zsbyqx20/AgentHazard.gitIt is recommended to use uv for setting up the dependencies of this project.
$ uv sync --no-devIt is also okay to use your preferred dependency manager through
requirements.txt.
$ pip install -r requirements.txtYou can get access to our dynamic & static dataset through this link, or the commands below:
$ wget "https://cloud.tsinghua.edu.cn/f/392e8053a8a5494a8afb/?dl=1" -O data.tar.gz
$ mv data.tar.gz /path/to/the/repository
$ tar xzf data.tar.gzAfter decompress the file, please ensure the structure of the folders:
├── data
│ ├── dynamic
│ └── static
└── src
└── agenthazard
└── ...
We use jinja template to manage and generate configurations for the hijacking tool. Please download the latest release and install it on your AVD.
In order to convert the jinja files into JSON files, just run:
# if you are using uv
$ ah generate
# if you are using other dependency manager
$ python -m agenthazard.cli generateAfter that, please clone our customized Android World repository, and put the
generated JSON files into the config folder.
Here the
configfolder refers toAndroidWorldinstead of the current repository.
$ git clone https://github.com/Zsbyqx20/android_world.gitYou need to follow the instructions of Android World to set up environments and AVDs. Here is an example.
python run.py \
--suite_family=android_world \
--agent_name=t3a_gpt4 \
--perform_emulator_setup \
--tasks=ContactsAddContact,ClockStopWatchRunning \
--attack_config config/xxxxx.json \ # specify the configuration path here
--break_on_misleading_actions # if specified, the program will quit when a misleading action is detected.Note: to keep the consistency among all runs, we recommend you to save a checkpoint after you just finishing configurations of a fresh AVD. Refer to the
evalfolder under the Android World project to check more details on how to automatically run evaluations. We provide a solution on robust mechanisms including automatic reloading states when meeting an error and restarting AVDs if needed.
The static part of our dataset is under the data/static/ folder. Each scenario
contains 4 files, namely screenshot.jpg, filtered_elements.json,
metadata.json, and original_vh.json. The detailed logic can be found at
src/agenthazard/dataset.py.
For evaluation, you are required to set your API key in the .env file. You may
refer to .env.local file as an example, and refer to
src/agenthazard/api/client for more clients available, or customizing your own
LLM client.
OPENAI_API_KEY=sk-xxxx
OPENAI_BASE_URL=https://xxxx.comWe provide convenient evaluation entries through the eval command:
# if you are using uv
$ ah eval --help
# if you are using other dependency manager
$ python -m agenthazard.cli eval --helpFor each modality of the agent, we choose M3A, T3A and UGround (to be released) to implement for evaluation logic. We support to choose from different agents, different LLMs, as well as different misleading actions as settings.
Please check our paper for more details.
