Back to skill

Security audit

Apktool

Security checks for vulnerabilities and agentic risk

Overview

This APK reverse-engineering skill is mostly coherent, but its install instructions include unverified downloads into system-wide executable paths.

Review the install steps before enabling this skill. Prefer package-manager installs, avoid running whole network-download scripts as root, verify release checksums or signatures where available, and consider user-local installs instead of writing to /opt or /usr/local/bin. The skill appears useful for legitimate APK analysis, but its manual installation paths deserve careful review.

Vulnerability Patterns
  • Remote Payload Retrieval and ExecutionFetches external code whose behavior can change after review
  • Insecure DependenciesIntroduces malicious components through unsafe dependency sources
  • Skill Instruction HijackingAlters the agent's session goals or safety constraints when the skill loads
  • Agent Memory PoisoningWrites attacker-controlled rules into memory that affect later sessions
  • Embedded Malicious CodeShips malicious scripts inside the skill and executes them locally
Findings (3)

T03 · Remote Payload Retrieval and Execution

Warning
Location
SKILL.md:31
Finding
Unverified JADX Archive Installed into System-Wide Executable Paths<![CDATA[ ## Vulnerability Details **File Location**: `SKILL.md:31` **Vulnerability Type**: Unverified remote executable retrieval and privileged system-wide installation **Risk Level**: Medium ### Vulnerable Code ```json "script": "cd /tmp && curl -L -o jadx.zip https://github.com/skylot/jadx/releases/download/v1.5.0/jadx-1.5.0.zip && unzip -o jadx.zip && mkdir -p /opt/jadx && cp -r lib /opt/jadx/ && cp bin/jadx /opt/jadx/ && sed -i 's|APP_HOME=\".*\"|APP_HOME=\"/opt/jadx\"|g' /opt/jadx/jadx && ln -sf /opt/jadx/jadx /usr/local/bin/jadx", ``` ### Technical Analysis The installation command downloads a ZIP archive from an external GitHub release and immediately extracts and installs its contents without verifying a cryptographic checksum or release signature. Pinning the URL to JADX version `1.5.0` improves reproducibility but does not establish the integrity or authenticity of the downloaded bytes. The archive is extracted directly in the shared `/tmp` directory rather than a newly created, permission-restricted temporary directory. Existing `lib` and `bin/jadx` paths in the working directory could consequently influence what is copied if extraction fails to replace them as expected or if the command operates in an unsafe multi-user environment. The command writes to `/opt/jadx` and creates `/usr/local/bin/jadx`, which normally requires elevated privileges and exposes the downloaded launcher through the global executable search path. JADX is relevant when Java-like source decompilation is requested, but it is supplementary to Apktool's core APK resource and smali operations. Requiring and installing it globally exceeds the minimum privilege and dependency scope for Apktool-only workflows. ### Attack Path 1. An attacker compromises or replaces the referenced release asset, its hosting account, or another component of the download trust path. 2. The installation command follows redirects and accepts the resulting archive without checksum or signature vali ...[truncated 1262 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Publish and pin an expected SHA-256 digest for the exact JADX archive, then verify it before extraction: ```sh printf '%s %s\n' "$EXPECTED_SHA256" "$archive" | sha256sum -c - ``` 2. Where available, verify an upstream cryptographic release signature using a separately trusted signing key. 3. Create a private temporary directory with `mktemp -d`, apply restrictive permissions, and install only from that directory. 4. Use `set -euo pipefail`, validate the extracted file layout, and abort on any unexpected entry or failed validation. 5. Avoid extracting into a shared directory with predictable filenames. 6. Prefer a trusted operating-system package manager where an appropriate package is available. 7. Install JADX under a user-controlled directory such as `~/.local/opt/jadx`, with a link under `~/.local/bin`, unless the user explicitly approves a system-wide installation. 8. Declare JADX as optional and install it only when Java decompilation is specifically requested. 9. Require explicit user confirmation before modifying `/opt` or `/usr/local/bin`. ]]>

T08 · Insecure Dependencies

Warning
Location
references/install.md:63
Finding
Manual Apktool Installation Trusts Unverified Executable Artifacts<![CDATA[ ## Vulnerability Details **File Location**: `references/install.md:63-83` **Vulnerability Type**: Unverified third-party dependency installation into global system paths **Risk Level**: Medium ### Vulnerable Code ```bash # 创建安装目录 sudo mkdir -p /opt/apktool cd /opt/apktool # 下载最新版本的 wrapper 脚本和 jar 文件 # 从官方 GitHub releases 获取 sudo wget -O apktool.jar https://github.com/iBotPeaches/Apktool/releases/download/v3.0.1/apktool_3.0.1.jar sudo wget -O apktool https://github.com/iBotPeaches/Apktool/releases/download/v3.0.1/apktool_3.0.1 # 设置执行权限 sudo chmod +x /opt/apktool/apktool # 添加到系统路径 sudo ln -sf /opt/apktool/apktool /usr/local/bin/apktool # 验证 which apktool apktool --version ``` ### Technical Analysis The guide downloads the Apktool JAR and wrapper from an upstream GitHub release but performs no checksum or signature verification before granting executable permission and linking the wrapper into the global PATH. The version is pinned to `3.0.1`, and the domain and repository correspond to the documented upstream Apktool project. These properties reduce accidental version drift and suspicious-source concerns, but they do not protect against a compromised release asset, maintainer account, repository, or download trust path. Using `sudo wget` writes remotely supplied data directly into a privileged installation directory. This unnecessarily gives the network retrieval process permission to overwrite root-owned installation files. The recommended package-manager installation method is safer and usually sufficient for the declared functionality. ### Attack Path 1. An attacker compromises or substitutes one of the referenced GitHub release artifacts. 2. The user follows the manual installation instructions using `sudo wget`. 3. The altered wrapper or JAR is written directly into `/opt/apktool` without integrity validation. 4. The wrapper is marked executable and linked as `/usr/local/bin/apktool`. 5. The user runs `apktool --version` or later analy ...[truncated 838 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Keep the package-manager installation method as the primary recommendation. 2. Download artifacts as an unprivileged user into a private temporary directory. 3. Verify separately published, pinned SHA-256 digests for both the wrapper and JAR before installation. 4. Verify upstream release signatures where supported and document how the signing key is authenticated. 5. Use administrative privileges only for the final validated copy and symlink operations. 6. Refuse installation if either artifact fails validation or has an unexpected filename, type, or structure. 7. Prefer a user-local installation under `~/.local` when only the current user requires Apktool. 8. Avoid `ln -sf` unless replacement of an existing global command has been explicitly approved; first inspect and report any existing target. ]]>

T03 · Remote Payload Retrieval and Execution

Warning
Location
references/install.md:99
Finding
Automated Apktool Installer Executes an Unverified Installation Workflow with Root Privileges<![CDATA[ ## Vulnerability Details **File Location**: `references/install.md:99-136` **Vulnerability Type**: Root-executed installer downloads and exposes unverified remote components **Risk Level**: Medium ### Vulnerable Code ```bash #!/bin/bash # install-apktool.sh set -e INSTALL_DIR="/opt/apktool" APKTOOL_VERSION="3.0.1" echo "🔧 开始安装 Apktool ${APKTOOL_VERSION}..." # 检查 Java if ! command -v java &> /dev/null; then echo "❌ Java 未安装,请先安装 Java" exit 1 fi # 创建目录 sudo mkdir -p ${INSTALL_DIR} cd ${INSTALL_DIR} # 下载文件 echo "📥 下载 Apktool..." sudo wget -q --show-progress -O apktool.jar \ https://github.com/iBotPeaches/Apktool/releases/download/v${APKTOOL_VERSION}/apktool_${APKTOOL_VERSION}.jar sudo wget -q --show-progress -O apktool \ https://github.com/iBotPeaches/Apktool/releases/download/v${APKTOOL_VERSION}/apktool_${APKTOOL_VERSION} # 设置权限 sudo chmod +x apktool # 创建链接 sudo ln -sf ${INSTALL_DIR}/apktool /usr/local/bin/apktool echo "✅ Apktool 安装完成!" apktool --version ``` The guide then instructs users to execute the installer as follows: ```bash chmod +x install-apktool.sh sudo ./install-apktool.sh ``` ### Technical Analysis The installer retrieves executable components without checksum or signature verification and is explicitly launched using `sudo`. Once run this way, the whole script—including external command resolution, downloads, directory changes, file writes, and the final version check—operates in a root execution context. The script also redundantly invokes `sudo` internally. Running an entire network-enabled installation script as root exceeds the privilege required for downloading and verifying artifacts. Only the final installation into protected system directories needs elevation. `set -e` provides limited failure handling but does not enable undefined-variable detection or pipeline failure handling. Variables such as `${INSTALL_DIR}` are not quoted, although their current values are hardcoded and therefore do not pr ...[truncated 1342 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Do not instruct users to run the entire installer with `sudo`. 2. Download and verify artifacts as an unprivileged user in a directory created with `mktemp -d`. 3. Pin and validate SHA-256 checksums for both downloaded files before any privileged operation. 4. Use `sudo install` only after validation, for example to copy files with explicit ownership and modes into `/opt/apktool`. 5. Invoke the installed executable for verification without elevated privileges. 6. Replace `set -e` with `set -euo pipefail` and quote all variable expansions. 7. Resolve required tools using trusted absolute paths in privileged installation steps where practical. 8. Detect an existing `/usr/local/bin/apktool` target and require confirmation before replacing it. 9. Prefer a user-local installation or the documented package-manager method unless a system-wide installation is explicitly necessary. ]]>
Vulnerability Patterns
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Tool MisuseTool Parameter Abuse, Chaining Abuse, Unsafe Defaults
  • Rogue AgentSelf-Modification, Session Persistence
  • YARA SignaturesMalware Match, Webshell Match, Cryptominer Match
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
Findings (41)

YARA rule 'backdoor_persistence': Backdoor persistence with malicious payloads (shell commands, SSH key injection, hidden root users) [malware]

High
Category
YARA Match
Content
### ❌ 问题:权限不足

**症状**:
```bash
$ apktool d app.apk
Error: Unable to create directory
```

**原因**: 输出目录权限不足

**解决方案**:

```bash
# 1. 使用有权限的目录
apktool d app.apk -o ~/tmp/app_decompiled

# 2. 或修改目录权限
sudo chown -R $USER:$USER /opt/apktool

# 3. 或在用户目录安装
mkdir -p ~/bin/apktool
cp apktool.jar ~/bin/apktool/
echo 'alias apktool="java -jar ~/bin/apktool/apktool.jar"' >> ~/.bashrc
source ~/.bashrc
```

---

## 反编译问题

### ❌ 问题:反编译失败 "Unknown version"

**症状**:
```bash
$ apktool d app.apk
I: Using Apktool 3.0.1 on app.apk
W: Unknown version. Code might not work properly.
Exception in thread "main" brut.androlib.AndrolibException
```

**原因**: APK 使用了较新版本的资源表格式

**解决方案**:

```bash
# 1. 更新 Apktool 到最新版本
# 参考 install.md 更新

# 2. 尝试不使用资源解码
apktool d app.apk -r -o app_output

# 3. 安装框架文件
Confidence
75% confidence
Finding
YARA rule matched a known malware signature (reverse shell, backdoor, ransomware, C2 framework, or info stealer).

Tool Parameter Abuse

High
Category
Tool Misuse
Content
# 从备份恢复未修改的资源

# 4. 清理后重新编译
rm -rf app_folder/build
apktool b app_folder -o app.apk

# 5. 检查 AndroidManifest.xml 格式
Confidence
92% confidence
Finding
The raw rm -rf cleanup command is destructive and presented without a warning, confirmation guidance, or a safer alternative. Even though the target is a build directory, users may adapt the command incorrectly or run it from the wrong context, causing unintended data loss.

Tool Parameter Abuse

High
Category
Tool Misuse
Content
apktool empty-framework-dir -f

# 3. 或手动删除
rm ~/.local/share/apktool/framework/*.apk

# 4. 重新安装
apktool if framework-res.apk
Confidence
94% confidence
Finding
Deleting all APK files from the local Apktool framework directory is a destructive action that can remove cached framework state and any manually installed files. In context this is troubleshooting, but without backup or validation guidance it can still cause avoidable data loss or user confusion.

Natural-Language Policy Violations

Medium
Confidence
96% confidence
Finding
The file’s user-facing description and instructions are written entirely in Chinese, including the title, labels, and usage guidance. Under the policy, forcing a specific language without opt-in is a natural-language locale violation unless the skill offers a language choice or clearly documents a region-specific justification, which this file does not.

Sudo/Root Execution

Medium
Category
Privilege Escalation
Content
```bash
# 安装 Java(如未安装)
sudo apt-get update
sudo apt-get install -y openjdk-11-jdk

# 安装 Apktool
Confidence
70% confidence
Finding
Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Sudo/Root Execution

Medium
Category
Privilege Escalation
Content
```bash
# 安装 Java(如未安装)
sudo apt-get update
sudo apt-get install -y openjdk-11-jdk

# 安装 Apktool
Confidence
70% confidence
Finding
Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Sudo/Root Execution

Medium
Category
Privilege Escalation
Content
```bash
# 安装 Java(如未安装)
sudo apt-get update
sudo apt-get install -y openjdk-11-jdk

# 安装 Apktool
Confidence
70% confidence
Finding
Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Sudo/Root Execution

Medium
Category
Privilege Escalation
Content
```bash
# 安装 Java(如未安装)
sudo apt-get update
sudo apt-get install -y openjdk-11-jdk

# 安装 Apktool
Confidence
70% confidence
Finding
Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Sudo/Root Execution

Medium
Category
Privilege Escalation
Content
```bash
# 安装 Java(如未安装)
sudo apt-get update
sudo apt-get install -y openjdk-11-jdk

# 安装 Apktool
Confidence
70% confidence
Finding
Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Sudo/Root Execution

Medium
Category
Privilege Escalation
Content
```bash
# 安装 Java(如未安装)
sudo apt-get update
sudo apt-get install -y openjdk-11-jdk

# 安装 Apktool
Confidence
70% confidence
Finding
Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Sudo/Root Execution

Medium
Category
Privilege Escalation
Content
```bash
# 安装 Java(如未安装)
sudo apt-get update
sudo apt-get install -y openjdk-11-jdk

# 安装 Apktool
Confidence
70% confidence
Finding
Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Sudo/Root Execution

Medium
Category
Privilege Escalation
Content
```bash
# 安装 Java(如未安装)
sudo apt-get update
sudo apt-get install -y openjdk-11-jdk

# 安装 Apktool
Confidence
70% confidence
Finding
Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Sudo/Root Execution

Medium
Category
Privilege Escalation
Content
```bash
# 安装 Java(如未安装)
sudo apt-get update
sudo apt-get install -y openjdk-11-jdk

# 安装 Apktool
Confidence
70% confidence
Finding
Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Sudo/Root Execution

Medium
Category
Privilege Escalation
Content
```bash
# 安装 Java(如未安装)
sudo apt-get update
sudo apt-get install -y openjdk-11-jdk

# 安装 Apktool
Confidence
70% confidence
Finding
Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Sudo/Root Execution

Medium
Category
Privilege Escalation
Content
```bash
# 安装 Java(如未安装)
sudo apt-get update
sudo apt-get install -y openjdk-11-jdk

# 安装 Apktool
Confidence
70% confidence
Finding
Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Sudo/Root Execution

Medium
Category
Privilege Escalation
Content
```bash
# 安装 Java(如未安装)
sudo apt-get update
sudo apt-get install -y openjdk-11-jdk

# 安装 Apktool
Confidence
70% confidence
Finding
Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Sudo/Root Execution

Medium
Category
Privilege Escalation
Content
sudo apt-get install -y openjdk-11-jdk

# 安装 Apktool
sudo apt-get install -y apktool

# 验证安装
apktool --version
Confidence
70% confidence
Finding
Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Sudo/Root Execution

Medium
Category
Privilege Escalation
Content
sudo apt-get install -y openjdk-11-jdk

# 安装 Apktool
sudo apt-get install -y apktool

# 验证安装
apktool --version
Confidence
70% confidence
Finding
Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Sudo/Root Execution

Medium
Category
Privilege Escalation
Content
sudo apt-get install -y openjdk-11-jdk

# 安装 Apktool
sudo apt-get install -y apktool

# 验证安装
apktool --version
Confidence
70% confidence
Finding
Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Sudo/Root Execution

Medium
Category
Privilege Escalation
Content
sudo apt-get install -y openjdk-11-jdk

# 安装 Apktool
sudo apt-get install -y apktool

# 验证安装
apktool --version
Confidence
70% confidence
Finding
Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Sudo/Root Execution

Medium
Category
Privilege Escalation
Content
sudo apt-get install -y openjdk-11-jdk

# 安装 Apktool
sudo apt-get install -y apktool

# 验证安装
apktool --version
Confidence
70% confidence
Finding
Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Sudo/Root Execution

Medium
Category
Privilege Escalation
Content
sudo apt-get install -y openjdk-11-jdk

# 安装 Apktool
sudo apt-get install -y apktool

# 验证安装
apktool --version
Confidence
70% confidence
Finding
Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Sudo/Root Execution

Medium
Category
Privilege Escalation
Content
sudo apt-get install -y openjdk-11-jdk

# 安装 Apktool
sudo apt-get install -y apktool

# 验证安装
apktool --version
Confidence
70% confidence
Finding
Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Sudo/Root Execution

Medium
Category
Privilege Escalation
Content
sudo apt-get install -y openjdk-11-jdk

# 安装 Apktool
sudo apt-get install -y apktool

# 验证安装
apktool --version
Confidence
70% confidence
Finding
Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Session Persistence

Medium
Category
Rogue Agent
Content
```bash
# 创建安装目录
sudo mkdir -p /opt/apktool
cd /opt/apktool

# 下载最新版本的 wrapper 脚本和 jar 文件
Confidence
60% confidence
Finding
Skill establishes unauthorized persistence across sessions via cron jobs, startup scripts, or state files. Session persistence allows an attacker to maintain access beyond the current interaction.

Static analysis

No suspicious patterns detected.