# Detect rewritten package commands inside LLM tool calls

> Source: LMSpeed (https://lmspeed.net) — https://lmspeed.net/audit/tool-substitution. When citing or reusing this content, credit "LMSpeed" and link to https://lmspeed.net/audit/tool-substitution.

Detect malicious AC-1.a tool-call rewriting on LLM API relays, catching substituted npm/pip/uv install commands or altered command arguments.

Canonical URL: https://lmspeed.net/audit/tool-substitution
Last updated: 2026-12-03T18:58:42.592Z (site data revision; page date not supplied)

Reproduction and quotation must name LMSpeed, link to the canonical HTML URL, and retain individual source citations.

Catch AC-1.a return-path supply-chain tampering where relays swap install commands, tool arguments, or package registries silently.

Response & Stream IntegrityDefault suite@lmspeed/audit v0.3.3 · independent-2026-11-24.1

[Run the All-in-One audit](https://lmspeed.net/audit)[Fingerprint Detection](https://lmspeed.net/audit/model-fingerprint)

## Recent public reports

Redacted audit reports that included this probe.

- [9r***.dpdns.org

osqoof/gpt-6

Audited at · Dec 2Did not pass](https://lmspeed.net/audit/N40mYlV6Wi7FIZUZ)

- [9r***.dpdns.org

osqoof/gpt-6

Audited at · Dec 2Did not pass](https://lmspeed.net/audit/ioQ8Fhj5sRl6FSnv)

- [ap***.ai

claude-opus-5-5

Audited at · Dec 2Passed](https://lmspeed.net/audit/UE6_9YowLYxNwcPG)

- [ap***.cc

standard/claude-opus-5.5

Audited at · Dec 2Passed](https://lmspeed.net/audit/tGHasfcva0AHdZFy)

- [fr***.in

deepseek-v4.1-flash-1017

Audited at · Dec 2Passed](https://lmspeed.net/audit/hiSam9nJebv3-v3K)

- [ap***.vip

Claude Opus 5.5

Audited at · Dec 1Passed](https://lmspeed.net/audit/2JpeaBJGrkHe0Mvz)

## Overview & Risk Context

Tool substitution detection checks whether an API relay alters package-install commands or structured tool-call arguments returned by the model to inject malicious dependencies.

### What this check measures

Inspects returned shell and tool-call JSON payloads for substituted package names, rogue flags, or unauthorized registry URLs.

### Why this risk matters

In Liu et al. ("Your Agent Is Mine", arXiv:2604.08407), AC-1.a showed how compromised API relays rewrite innocent `pip install` or `npm install` commands straight into malware execution.

### When to run this check

Critical before using any third-party relay with coding agents, IDE assistants, or automated CLI runners.

Even if system prompts look clean on normal chat turns, a compromised relay inspecting tool-call payloads can silently swap a typosquatted package name before returning chunks to your coding agent.

## Detection Methodology, Evidence & Limitations

Implements benign package-installation tool-use tests grounded in AC-1.a (arXiv:2604.08407) inside @lmspeed/audit without executing commands.

- **1. Probe**

Send a safe tool-enabled coding task requesting standard package setup instructions or structured shell arguments.

- **2. Inspect**

Inspect the returned message and tool_calls arguments character-by-character for altered package names, flags, or URLs.

- **3. Conclude**

Flag AC-1.a supply-chain tampering if unexpected commands or foreign registry targets appear.

### How to read the verdict

Unmodified expected package commands pass; tampered package names, curl pipes, or extra flags fail immediately.

### Evidence basis & thresholds

Exact command and tool-call JSON argument comparison grounded in AC-1.a taxonomy (arXiv:2604.08407).

### Scope limits & abstention conditions

Tests deterministic clean setups and executes zero local commands; sophisticated dynamic rewrites targeting closed enterprise registries require local endpoint allowlisting.

### Verification Sources & Baselines

Implemented in @lmspeed/audit v0.3.3 (ruleset independent-2026-11-22.2); supplementary capability/injection design cross-checked against Veridrop, LLMprobe-engine, and meow-llm-detector specs.

- [lmspeed/audit (v0.3.3)](https://github.com/nexmoe/lmspeed-audit)Open-source LMSpeed probe engine, catalog registry, and calibrated fingerprint protocols.

- [Liu et al., "Your Agent Is Mine" (arXiv:2604.08407)](https://arxiv.org/abs/2604.08407)Research basis for AC-1 tool-call hijacking, AC-2 error leakage, and Web3 injection threats.

## Frequently Asked Questions

### What is AC-1.a tool-call rewriting?

An attack class documented in arXiv:2604.08407 where an intermediary LLM proxy tampers with returned tool calls or dependency install commands.

### Does LMSpeed execute the returned shell commands?

Never. Tool arguments are inspected statically without executing any local process.

### How does Tool Substitution relate to Tool Permissions?

Tool Permissions tests whether `tool_choice` schema rules are honored; Tool Substitution inspects whether returned tool parameters were maliciously altered.

### Should coding agents also use package lockfiles?

Yes—combining LMSpeed relay checks with local sandbox confirmation and lockfiles provides layered defense.

## All audit checks by category

Explore every single-check audit tool grouped by risk domain, with Fingerprint Detection pinned first for model-authenticity verification.

### Fingerprint Detection

Pinned · Priority Group3

- [Model distribution fingerprint](https://lmspeed.net/audit/model-fingerprint)

- [Numeric fingerprint screening](https://lmspeed.net/audit/numeric-fingerprint)

- [Tokenizer fingerprint](https://lmspeed.net/audit/tokenizer-fingerprint)

### Prompt & Injection Security

6

- [Token injection](https://lmspeed.net/audit/token-injection)

- [Prompt extraction](https://lmspeed.net/audit/prompt-extraction)

- [Instruction conflict](https://lmspeed.net/audit/instruction-conflict)

- [Jailbreak identity](https://lmspeed.net/audit/jailbreak-identity)

- [Conditional injection](https://lmspeed.net/audit/conditional-injection)

- [Web3 injection](https://lmspeed.net/audit/web3-prompt-injection)

### Response & Stream Integrity

5

- [Stream integrity](https://lmspeed.net/audit/stream-integrity)

- [Stream consistency](https://lmspeed.net/audit/stream-consistency)

- Tool substitution

- [Error leakage](https://lmspeed.net/audit/error-leakage)

- [Latency variance](https://lmspeed.net/audit/latency-variance)

### Capabilities & Context Limits

7

- [Context window and recall](https://lmspeed.net/audit/context-window)

- [Tool permissions](https://lmspeed.net/audit/tool-calling)

- [Structured JSON output](https://lmspeed.net/audit/structured-output)

- [Image understanding](https://lmspeed.net/audit/image-understanding)

- [PDF understanding](https://lmspeed.net/audit/pdf-understanding)

- [Quality canary](https://lmspeed.net/audit/quality-canary)

- [Quality comparison](https://lmspeed.net/audit/quality-comparison)

### Related LMSpeed benchmarks & methodology

- [Full 25-Check Provider Audit](https://lmspeed.net/audit)

- [3-Stage Fingerprint Pipeline](https://lmspeed.net/audit#fingerprint-detection)

- [LLM API Speed Test](https://lmspeed.net/speed)

- [Provider Directory](https://lmspeed.net/provider)

- [Model Directory & Pricing](https://lmspeed.net/model)

- [Benchmark Methodology](https://lmspeed.net/methodology)

---
Cite as: Detect rewritten package commands inside LLM tool calls — LMSpeed, https://lmspeed.net/audit/tool-substitution (retrieved 2026-12-04)
