Retrieved article excerpt
Open article Β· Retrieved 2026-10-12T20:26:46.914663+00:00
# Tanuki
[Tanuki logo](https://github.com/Pigyon/tanuki/blob/master/avatar/avatar.svg)
*"The greatest craft is to hide craft."*
Thomas Fuller
**Proxy for AI-assisted security testing/privacy**
[Release](https://github.com/Pigyon/tanuki/releases/latest)
[CI](https://github.com/Pigyon/tanuki/actions/workflows/ci.yml)
[GHCR](https://github.com/Pigyon/tanuki/pkgs/container/tanuki)
[Go](https://go.dev)
[Docker](https://www.docker.com/)
[Claude Code](https://github.com/pigyon/tanuki#quick-start)
[Image](https://github.com/pigyon/tanuki#architecture)
[License](https://github.com/Pigyon/tanuki/blob/master/LICENSE)
---
Tanuki sits between your local **Claude Code** agent and the **Anthropic API**, rewriting every target-identifying string in real time. Your tools hit the real target; the model only ever sees a fictional localhost project.
## Table of Contents
- [Overview](https://github.com/pigyon/tanuki#overview)
- [How it works](https://github.com/pigyon/tanuki#how-it-works)
- [Example](https://github.com/pigyon/tanuki#example)
- [Quick start](https://github.com/pigyon/tanuki#quick-start)
- [Configuration](https://github.com/pigyon/tanuki#configuration)
- [CLI reference](https://github.com/pigyon/tanuki#cli-reference)
- [What gets rewritten](https://github.com/pigyon/tanuki#what-gets-rewritten)
- [Environment variables](https://github.com/pigyon/tanuki#environment-variables)
- [Architecture](https://github.com/pigyon/tanuki#architecture)
- [Verifying an engagement](https://github.com/pigyon/tanuki#verifying-an-engagement)
- [Known limitations](https://github.com/pigyon/tanuki#known-limitations)
- [Fail-closed behaviour](https://github.com/pigyon/tanuki#fail-closed-behaviour)
- [Disclaimer](https://github.com/pigyon/tanuki#disclaimer)
- [License](https://github.com/pigyon/tanuki#license)
## Overview
Tanuki is an anonymization proxy built for AI-assisted security testing and bug bounty hunting. When you drive an agent like Claude Code through a pentest, every real domain, IP, and payload in your prompts leaves your machine. That's an OpSec risk, and it can also breach bug bounty program rules or an NDA.
Tanuki runs as a Docker container and transparently intercepts that API traffic. Before a prompt leaves your machine, it swaps real target data (domains, subdomains, IPs, emails, paths, cloud identifiers, and aggressive security terminology) for harmless fictional development equivalents. When the model responds, the fiction is mapped back to reality so your local tools execute against the real targets. The model believes it is helping you debug a local dev application, and the upstream provider is blind to your actual engagement.
## How it works
```
flowchart TD
classDef default fill:#050505,stroke:#8b0000,stroke-width:1px,color:#ff3333,font-family:Courier
classDef proxy fill:#110000,stroke:#ff0000,stroke-width:2px,color:#ffffff,font-family:Courier
classDef hooks fill:#000000,stroke:#550000,stroke-width:1px,stroke-dasharray:4 4,color:#cc0000,font-family:Courier
classDef upstream fill:#0a0a0a,stroke:#333333,stroke-width:1px,color:#666666,font-family:Courier
classDef data fill:#1a0505,stroke:#aa0000,stroke-width:1px,color:#ff6666,font-family:Courier
subgraph Host["LOCAL MACHINE"]
C["Claude Code"]
H[/"Tanuki Hooks<br/>(docker exec)"/]
C -. "Tool execution" .-> H
end
subgraph Container["DOCKER CONTAINER"]
P{"Tanuki Proxy<br/>[scratch ~10MB]"}:::proxy
D[("( mappings volume )")]:::data
end
A((("Anthropic API"))):::upstream
C == "Real prompt data" ==> P
P -. "Loads config" .-> D
P -- "Rewrites to Fiction" --> A
A -- "Responds in Fiction" --> P
P == "Rewrites to Real" ==> C
class C default
class H hooks
style Host fill:transparent,stroke:#8b0000,stroke-width:1px,color:#8b0000,font-family:Courier
style Container fill:#020000,stroke:#4a0000,stroke-width:1px,stroke-dasharray:3 3,color:#8b0000,font-family:Courier
```
Loading
| Direction | Path | What happens |
| --- | --- | --- |
| **Inbound** | your prompt β API | Domains, org names, emails, IPs, paths, cloud identifiers, and pentest terminology are replaced with localhost fiction before the model sees them. |
| **Outbound** | API β Claude Code | Fiction terms are rewritten back to real values in the response stream, so Claude Code's local tools receive real target data. |
| **Tool calls** | hook via `docker exec` | A `PreToolUse` hook rewrites fictionβreal in tool arguments, so tools hit the actual targets. Tool output needs no hook: it reaches the model only inside the next request, which the proxy rewrites like any other. |
## Example
You're testing `bounty.amazon.com`. Here's what Tanuki does:
| You type (real) | LLM sees (fiction) |
| --- | --- |
| `amazon.com` | `localhost:9000` |
| `bounty.amazon.com` | `localhost:9002` |
| `any-other.amazon.com` | `localhost:9001` (wildcard) |
| `[email protected]` | `[email protected]` |
| `Amazon` | `DEVTARGET` |
| `52.94.236.248` | `127.0.0.3` |
| `/var/www/amazon/` | `/var/www/dev/devtarget/` |
| `s3://amazon-prod` | `file:///tmp/devtarget-prod` |
| `SQL injection` | `parameterized query test` |
| `reverse shell` | `remote debug session` |
Each target domain gets three mappings: the base domain, a wildcard for
subdomains that have not been seen yet, and a dedicated mapping per
subdomain as it is detected. The wildcard is what stops an unmapped host
like `internal-admin.amazon.com` from leaking its label upstream.
## Quick start
```
git clone https://github.com/Pigyon/tanuki.git
cd tanuki
docker compose up -d
claude
```
That pulls the latest published image from GitHub Container Registry, so no Go toolchain and no build are needed.
To build from source instead of pulling:
```
docker compose -f compose.yaml -f compose.dev.yaml up -d --build
```
On startup the proxy auto-configures the Claude Code hook and proxy env in `.claude/settings.json`, and writes the cover-story `.claude/CLAUDE.md`. Domains, emails, and IPs are **auto-detected** from your conversation, so no manual target configuration is needed.
When you type *"check bounty.amazon.com for SQL injection"*, the proxy:
1. Detects `amazon.com` and `bounty.amazon.com` as new domains
2. Creates all derivative mappings (org, email, path, cloud)
3. Rewrites the request before it reaches the API
### Wrapper script
A `./tanuki` wrapper is included so you don't have to type `docker compose exec tanuki /tanuki <command>`:
```
./tanuki add example.com
./tanuki map
./tanuki status
```
### Verify rewriting
Test the rewriting engine without hitting the API:
```
./tanuki test "scan bounty.amazon.com for SQL injection and contact [email protected]"
```
## Configuration
Everything is optional; without it, targets are auto-detected from your conversation. To pre-configure an engagement, edit `compose.yaml`:
```
environment:
# Custom fiction org name (default: DEVTARGET)
- TANUKI_FICTION_ORG=ACMECORP
# Pre-seed target domains (comma-separated)
- TANUKI_DOMAINS=example.com,api.example.com
# Pre-seed target IPs (comma-separated)
- TANUKI_IPS=93.184.216.34
# Custom rewrite rules (semicolon-separated, pipe-delimited real|fiction)
- TANUKI_RULES=John Smith|Jane Developer;Project Phoenix|Test Alpha
```
### Custom rewrite rules
For strings that aren't domains or IPs (people, project names, internal jargon), add custom rules via `compose.yaml` (applied on every container start) or at runtime:
```
./tanuki add-rule "John Smith" "Jane Developer"
./tanuki add-rule "Project Phoenix" "Test Alpha"
```
### Named engagements
For separate projects or custom fiction org names:
```
./tanuki init bugbounty --fiction-org ACMECORP
./tanuki add bounty.amazon.com
```
## CLI reference
All commands run via `./tanuki <command>` (or `docker compose exec tanuki /tanuki <command>`):
| Command | Description |
| --- | --- |
| `setup` | Configure Claude Code hooks (automatic on startup) |
| `init <name> [--fiction-org NAME]` | Create a named engagement |
| `add <domain> [--fiction-org NAME]` | Pre-seed a target domain |
| `add-ip <ip>` | Pre-seed an IP mapping |
| `add-rule <real> <fiction>` | Add a custom rewrite rule |
| `map` | Show the current mapping table |
| `status` | Show engagement info |
| `list` | List all engagements |
| `activate <name>` | Switch the active engagement |
| `test <text>` | Test rewriting on sample text |
| `verify [file...|-]` | Check the mappings hold; scan files for unmapped targets |
| `terms` | Show terminology mappings |
| `export [name]` | Export an engagement as JSON |
| `import <file.json>` | Import an engagement from JSON |
| `reset [--data]` | Remove hooks (`--data` also wipes engagements) |
| `version` | Show version and build info |
| `proxy` | Run the proxy server (container entrypoint) |
## What gets rewritten
### Mapping-based (per engagement, all auto-detected)
| Type | Detection | Fiction |
| --- | --- | --- |
| Domains | Auto-detected in prompts & tool output | `localhost:<port>` |
| Org names | Derived from domain | `DEVTARGET` (configurable) |
| Emails | Derived from domain | `[email protected]` |
| IPs (v4 + v6) | Auto-detected in prompts & tool output | `127.0.0.x` / `::ffff:...` |
| Paths | Derived from org name | `/dev/devtarget/` |
| Cloud resources | Derived from org name | `file:///tmp/devtarget...` |
| Custom rules | User-defined via env or CLI | User-defined |
### Terminology (built-in, applied to all engagements)
Compound pentest-specific terms are replaced with neutral dev equivalents. Only unambiguous multi-word terms are replaced. Single words like *target*, *payload*, or *exploit* are left alone so legitimate code discussions don't break.
Run `./tanuki terms` to see the full dictionary. The list lives in `internal/tanuki/terminology.json` and is embedded at build time; to customize it, edit the file and rebuild.
## Environment variables
Set in `compose.yaml`:
| Env var | Default | Description |
| --- | --- | --- |
| `TANUKI_DATA` | `/data` | Engagement data directory (volume) |
| `TANUKI_PROXY_PORT` | `18080` | Proxy listen port |
| `TANUKI_PORT_START` | `9000` | Starting port for domain assignments |
| `TANUKI_UPSTREAM` | `https://api.anthropic.com` | Upstream API URL |
| `TANUKI_FICTION_ORG` | `DEVTARGET` | Fiction org name for mappings |
| `TANUKI_DOMAINS` | *(none)* | Comma-separated domains to pre-seed |
| `TANUKI_IPS` | *(none)* | Comma-separated IPs to pre-seed |
| `TANUKI_RULES` | *(none)* | Custom rules: `real|fiction` pairs, semicolon-separated |
| `TANUKI_IGNORE` | *(none)* | Comma-separated domains never treated as targets (subdomains included). Always ignored: `anthropic.com`, `claude.com`, `claude.ai`, `json-schema.org`, the developer-platform domains Claude Code surfaces (`github.com`, `google.com`), and the operator's own email domain from Claude Code's account context. If one of these is your real target, `./tanuki add <domain>` maps it explicitly |
| `TANUKI_UID` / `TANUKI_GID` | `1000` | Owner for a `.claude/` directory Docker had to create; an existing one keeps its owner |
| `TANUKI_DEBUG` | *(none)* | Set to any non-empty value to enable debug logging |
| `TANUKI_ON_LEAK` | `refuse` | `refuse` or `warn` when a real value survives the rewrite |
## Architecture
**Container:** `scratch`-based image with a single static Go binary plus CA certs. No OS, no shell, no runtime, ~10MB total. All capabilities dropped, read-only filesystem, no privilege escalation.
**Everything runs in Docker.** The proxy, hooks, and CLI all execute inside the container; hooks are invoked by Claude Code via `docker exec`, so no host-side binary is needed.
**Matching:** an Aho-Corasick automaton does longest-first replacement in a single pass over the stream.
**JSON-aware:** request and response bodies are rewritten string by string, never as raw text. Protocol fields (`model`, `role`, `type`, ids, tool names) are left alone, base64 da