Skip to content

Conversation

@jonastemplestein
Copy link
Contributor

@jonastemplestein jonastemplestein commented Jan 15, 2026

  • Install http-mitm-proxy package
  • Add test script demonstrating header injection
  • Auto-generates certs per domain on first connect
  • Works with curl, Python, Node when CA is trusted

To use system-wide:
cp .http-mitm-proxy/certs/ca.pem /usr/local/share/ca-certificates/mitm.crt
update-ca-certificates
export https_proxy=http://localhost:8080


Note

Adds a developer MITM proxy for HTTPS interception with header injection, response body modification, and traffic logging.

  • New test/mitm-proxy.ts (uses Proxy.gunzip) and test/mitm-proxy-mkcert.ts (mkcert-based certs for Go compatibility) with per-host cert generation
  • Integration coverage via test/mitm-proxy.test.ts and helper scripts (test/mitm-scripts/*) validating header injection and response modification using undici ProxyAgent
  • Documentation in docs/MITM-PROXY.md with setup, client configuration (curl/wget/Python/Node/npm), system trust, and Go caveats
  • Dependency updates: add http-mitm-proxy and undici; update .gitignore to ignore .http-mitm-proxy/, .mkcert-ca/, .mitm-mkcert-certs/

Written by Cursor Bugbot for commit e09e0d3. This will update automatically on new commits. Configure here.

- Install http-mitm-proxy package
- Add test script demonstrating header injection
- Auto-generates certs per domain on first connect
- Works with curl, Python, Node when CA is trusted

To use system-wide:
  cp .http-mitm-proxy/certs/ca.pem /usr/local/share/ca-certificates/mitm.crt
  update-ca-certificates
  export https_proxy=http://localhost:8080
"@opentui/core": "^0.1.55",
"@opentui/react": "^0.1.55",
"effect": "^3.19.8",
"http-mitm-proxy": "^1.1.0",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test dependency added to production dependencies

Medium Severity

The http-mitm-proxy package is added to dependencies rather than devDependencies. Based on the PR description stating this is a "test script demonstrating header injection," this appears to be development/testing tooling. A Man-in-the-Middle proxy for HTTPS interception is a security-sensitive tool that typically should not be bundled with production builds. The accompanying test-mitm-proxy.ts script at root level further suggests this is test infrastructure.

Fix in Cursor Fix in Web

- test/mitm-proxy.ts: Main proxy with header injection and response modification
- test/mitm-proxy-mkcert.ts: Variant using mkcert for Go-compatible certs
- test/mitm-proxy.test.ts: Vitest tests covering curl, wget, Python, Node
- test/mitm-scripts/: Individual test scripts for each client
- docs/MITM-PROXY.md: Setup documentation

Key features:
- Uses Proxy.gunzip for automatic gzip/deflate decompression
- Injects X-Proxy-Injected header on outgoing requests
- Appends marker to text responses (html/json/plain)
- Auto-generates certs per domain

Client compatibility tested:
- curl, wget, Python urllib, Node undici: ✅
- npm: ✅ (needs explicit config)
- Go/gh: ⚠️ (cert serial number issues with node-forge)
export const RESPONSE_MARKER = "\n<!-- MITM_PROXY_MARKER -->"

const MKCERT_CAROOT = process.env.MKCERT_CAROOT || "/home/user/mini-agent/.mkcert-ca"
const CERTS_DIR = "/home/user/mini-agent/.mitm-mkcert-certs"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hardcoded absolute paths will break other environments

Medium Severity

The MKCERT_CAROOT fallback and CERTS_DIR constants use hardcoded absolute paths (/home/user/mini-agent/...) that are specific to one developer's machine. Unlike test/mitm-proxy.ts which correctly uses process.cwd() for its caPath, these paths will fail for other developers and CI environments. CERTS_DIR has no environment variable override at all.

Fix in Cursor Fix in Web

Comment on lines +19 to +20
export https_proxy=http://localhost:8080
curl --cacert .http-mitm-proxy/certs/ca.pem https://httpbin.org/headers
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need the --cacert? Check that it works without, too! Because we trust the signing cert at a system level no?

| **wget** || `--ca-certificate=path/to/ca.pem` |
| **Python urllib** || `ssl.load_verify_locations(ca_path)` |
| **Node.js/Bun** || `NODE_EXTRA_CA_CERTS=path/to/ca.pem` |
| **npm** || Requires explicit config (see below) |
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try pnpm and bun and pip and go get and try cloning a git repo via https or git push via https

Moar testing!!!!

wget --ca-certificate=.http-mitm-proxy/certs/ca.pem https://example.com
```

### Python
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add other popular ways to make http requests from python

curl --cacert .http-mitm-proxy/certs/ca.pem https://httpbin.org/headers
```

## Client Compatibility
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add deno and rust and apt-get and 3 other popular things you can think of

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants