An open API service indexing awesome lists of open source software.

https://github.com/ayuxsec/cachex

A high-accuracy, behavioral cache poisoning scanner for modern Web APIs
https://github.com/ayuxsec/cachex

bugbounty cache-poisoning hacking security-tools

Last synced: 5 months ago
JSON representation

A high-accuracy, behavioral cache poisoning scanner for modern Web APIs

Awesome Lists containing this project

README

          


cachex


A high-accuracy, behavioral cache poisoning scanner for modern Web APIs





## ๐ŸŒŸ Why CacheX?

Most cache poisoning scanners only check:

* whether a response changes with certain headers
* or whether cache-related headers exist

This produces **tons of false positives** and rarely confirms a real exploit.

**CacheX is different.**

It performs **behavioral diffing**, **multi-threaded poisoning**, and **persistence verification**, confirming only real, weaponizable cache poisoning.

[![demo](https://asciinema.org/a/0t6ga94iTdGmMuCP99KQsAZDs.svg)](https://asciinema.org/a/0t6ga94iTdGmMuCP99KQsAZDs)

## ๐Ÿ”ฅ Features

* โšก **High-speed multi-threaded scanning**
* ๐ŸŽฏ **Zero-FP design with behavioral diffing**
* ๐Ÿ” **Real-time cache poisoning attempts**
* ๐Ÿงช **Persistence confirmation for true vulnerabilities**
* ๐Ÿ” **Single and multi-header scan modes**
* ๐Ÿงฉ **YAML-based payload configuration**
* ๐Ÿ“ค **JSON or pretty output formats**
* ๐Ÿ“ **Optional file-based export**
* ๐Ÿท **Tentative vs confirmed vuln tagging**

## ๐Ÿ”ง Installation

```bash
go install github.com/ayuxsec/cachex/cmd/cachex@latest
```

Or build manually:

```bash
git clone --depth=1 https://github.com/ayuxsec/cachex
cd cachex
go build -o cachex "cmd/cachex/main.go"
./cachex -h
```

## ๐Ÿš€ Usage

### โ–ถ๏ธ Scan a single URL

```bash
cachex -u https://example.com
```

### โ–ถ๏ธ Scan multiple targets

```bash
cachex -l urls.txt
```

### โ–ถ๏ธ Scan URLs via pipeline

```bash
echo "https://example.com" | cachex
```

or:

```bash
cat urls.txt | cachex
```

---

## ๐Ÿ“Œ All CLI Flags

| Category | Flag | Description |
| ----------------- | ----------------- | --------------------------- |
| Input | `-u, --url` | URL to scan |
| | `-l, --list` | File with list of URLs |
| Concurrency | `-t, --threads` | Number of scanning threads |
| | `-m, --scan-mode` | `single` or `multi` |
| HTTP Client | `--timeout` | Total request timeout |
| | `--proxy` | Proxy URL |
| Persistence Check | `--no-chk-prst` | Disable persistence checker |
| | `--prst-requests` | Poisoning requests |
| | `--prst-threads` | Threads for poisoning |
| Output | `-o, --output` | Output file |
| | `-j, --json` | JSON output |
| Payloads | `--pcf` | Custom payload config file |

## ๐Ÿ’ก Example

```bash
cachex -l targets.txt -t 50 --pcf payloads.yaml --json -o results.json
```

## โš™๏ธ Configuration

CacheX automatically loads:

```
~/.config/cachex/config.yaml
~/.config/cachex/payloads.yaml
```

You can configure:

* Payload headers
* Default request headers
* Timeouts & concurrency
* Logging mode
* Proxy settings
* Persistence checker behavior

## ๐Ÿ“ Output Formats

### Pretty Output

```
[vuln] [https://target.com] [Location Poisoning] [header: X-Forwarded-Host: evil.com] [poc: https://target.com?cache=XYZ]
```

### JSON Output

```json
{
"URL": "https://target.com/",
"IsVulnerable": true,
"IsResponseManipulable": true,
"ManipulationType": "ChangedBody",
"RequestHeaders": {
"Accept": "*/*",
"User-Agent": "Mozilla/5.0"
},
"PayloadHeaders": {
"X-Forwarded-Host": "evil.com"
},
"OriginalResponse": {
"StatusCode": 200,
"Headers": {
"...": "..."
},
"Body": "...",
"Location": ""
},
"ModifiedResponse": {
"StatusCode": 200,
"Headers": {
"...": "..."
},
"Body": "...",
"Location": ""
},
"PersistenceCheckResult": {
"IsPersistent": true,
"PoCLink": "https://target.example.com/?cache=XYZ",
"FinalResponse": {
"StatusCode": 200,
"Headers": {
"...": "..."
},
"Body": "...",
"Location": ""
}
}
}
```

## ๐ŸŽ› Scan Modes

* `single`: precise, tests each header independently
* `multi`: fast, tests all payload headers together

## ๐Ÿงฉ Payload Headers

Defined in:

```
~/.config/cachex/payloads.yaml
```

Example:

```yaml
payload_headers:
X-Forwarded-Host: evil.com
X-Forwarded-For: 127.0.0.1
X-Original-URL: /evilpath
X-Client-IP: 127.0.0.1
```

## ๐Ÿ“ Configuration File Example (`config.yaml`)

```yaml
scan_mode: single
threads: 25

request_headers:
Accept: '*/*'
User-Agent: Mozilla/5.0 (...)

client:
dial_timeout: 5
handshake_timeout: 5
response_timeout: 10
proxy_url: ""

persistence_checker:
enabled: true
num_requests_to_send: 10
threads: 5

logger:
log_error: false
log_mode: pretty
debug: false
output_file: ""
skip_tentative: true
```

## ๐Ÿง  How CacheX Works

1. Fetches baseline response
2. Injects payload headers
3. Detects response manipulation (body, code, redirect)
4. If changed โ†’ launches concurrent poisoning attempts
5. Fetches clean requests
6. If poisoned response persists โ†’ confirmed vulnerability
7. Outputs PoC link

## ๐Ÿ“ Project Structure

```console
cachex/
โ”œโ”€โ”€ cmd/
โ”‚ โ””โ”€โ”€ cachex/
โ”‚ โ””โ”€โ”€ main.go # CLI entrypoint
โ”‚
โ”œโ”€โ”€ internal/
โ”‚ โ”œโ”€โ”€ app/
โ”‚ โ”‚ โ””โ”€โ”€ cachex/
โ”‚ โ”‚ โ””โ”€โ”€ cmd/
โ”‚ โ”‚ โ”œโ”€โ”€ banner.go # ASCII banner
โ”‚ โ”‚ โ”œโ”€โ”€ flags.go # CLI flags + config binding
โ”‚ โ”‚ โ”œโ”€โ”€ helper.go # Help message builder
โ”‚ โ”œโ”€โ”€ root.go # Main CLI logic & runner
โ”‚ โ””โ”€โ”€ utils.go # File helpers
โ”‚
โ”‚ โ”œโ”€โ”€ pkg/
โ”‚ โ”‚ โ”œโ”€โ”€ client/
โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ client.go # Custom HTTP client & transport
โ”‚ โ”‚ โ”‚ โ””โ”€โ”€ request.go # Fetch + send raw requests
โ”‚ โ”‚ โ”œโ”€โ”€ config/
โ”‚ โ”‚ โ”‚ โ””โ”€โ”€ config.go # Legacy internal config
โ”‚ โ”‚ โ””โ”€โ”€ logger/
โ”‚ โ”‚ โ”œโ”€โ”€ colors.go # Color themes
โ”‚ โ”‚ โ””โ”€โ”€ logger.go # Pretty logger (info/warn/debug/vuln)
โ”‚
โ”‚ โ””โ”€โ”€ scanner/
โ”‚ โ”œโ”€โ”€ core.go # Core poisoning test logic
โ”‚ โ”œโ”€โ”€ detector.go # Behavioral response diffing
โ”‚ โ”œโ”€โ”€ logger.go # Pretty + JSON output formatter
โ”‚ โ”œโ”€โ”€ output.go # JSON serialization helpers
โ”‚ โ”œโ”€โ”€ persistchk.go # Persistence checker (real-time poisoning)
โ”‚ โ”œโ”€โ”€ scanner.go # Scan controller (single/multi mode)
โ”‚ โ”œโ”€โ”€ types.go # All scanner structs & enums
โ”‚ โ””โ”€โ”€ utils.go # Cache buster, merging maps, helpers
โ”‚
โ”œโ”€โ”€ pkg/
โ”‚ โ””โ”€โ”€ cachex/
โ”‚ โ”œโ”€โ”€ scanner.go # Public API wrapper for internal scanner
โ”‚ โ”œโ”€โ”€ utils.go # Config mappers (log mode, scan mode)
โ”‚ โ””โ”€โ”€ validate.go # Config validation
โ”‚
โ”‚ โ””โ”€โ”€ config/
โ”‚ โ”œโ”€โ”€ config.go # YAML config schema
โ”‚ โ”œโ”€โ”€ default.go # Default paths + default config
โ”‚ โ””โ”€โ”€ payloads.go # Default payload headers
โ”‚
โ”œโ”€โ”€ .github/workflows/
โ”‚ โ””โ”€โ”€ release.yml # Automated builds via GoReleaser
โ”‚
โ”œโ”€โ”€ images/
โ”‚ โ”œโ”€โ”€ cachex-logo.png # Logo
โ”‚ โ””โ”€โ”€ cachex-demo.gif # Showcase GIF
โ”‚
โ”œโ”€โ”€ .goreleaser.yaml # Multi-platform binary releases
โ”œโ”€โ”€ .gitignore
โ”œโ”€โ”€ go.mod
โ”œโ”€โ”€ go.sum
โ”œโ”€โ”€ LICENSE
โ””โ”€โ”€ Makefile # Build / install helpers
```

## ๐Ÿค Contribute

Sure, PRs are welcome!

## ๐Ÿ“œ License

MIT ยฉ [@ayuxsec](https://github.com/ayuxsec)