Skip to content

Commit 9665e1f

Browse files
authored
Update cloudflare-workers-pass-through-proxy-ip-rotation.md
1 parent 01e37a9 commit 9665e1f

File tree

1 file changed

+17
-27
lines changed

1 file changed

+17
-27
lines changed

src/pentesting-ci-cd/cloudflare-security/cloudflare-workers-pass-through-proxy-ip-rotation.md

Lines changed: 17 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,21 @@
44

55
Cloudflare Workers can be deployed as transparent HTTP pass-through proxies where the upstream target URL is supplied by the client. Requests egress from Cloudflare's network so the target observes Cloudflare IPs instead of the client's. This mirrors the well-known FireProx technique on AWS API Gateway, but uses Cloudflare Workers.
66

7-
Key capabilities:
7+
### Key capabilities
88
- Support for all HTTP methods (GET, POST, PUT, DELETE, PATCH, OPTIONS, HEAD)
99
- Target can be supplied via query parameter (?url=...), a header (X-Target-URL), or even encoded in the path (e.g., /https://target)
1010
- Headers and body are proxied through with hop-by-hop/header filtering as needed
1111
- Responses are relayed back, preserving status code and most headers
1212
- Optional spoofing of X-Forwarded-For (if the Worker sets it from a user-controlled header)
1313
- Extremely fast/easy rotation by deploying multiple Worker endpoints and fanning out requests
1414

15-
How it works (flow):
16-
1) Client sends an HTTP request to a Worker URL (<name>.<account>.workers.dev or a custom domain route).
15+
### How it works (flow)
16+
1) Client sends an HTTP request to a Worker URL (`<name>.<account>.workers.dev` or a custom domain route).
1717
2) Worker extracts the target from either a query parameter (?url=...), the X-Target-URL header, or a path segment if implemented.
1818
3) Worker forwards the incoming method, headers, and body to the specified upstream URL (filtering problematic headers).
1919
4) Upstream response is streamed back to the client through Cloudflare; the origin sees Cloudflare egress IPs.
2020

21-
Worker implementation example
21+
### Worker implementation example
2222
- Reads target URL from query param, header, or path
2323
- Copies a safe subset of headers and forwards the original method/body
2424
- Optionally sets X-Forwarded-For using a user-controlled header (X-My-X-Forwarded-For) or a random IP
@@ -135,7 +135,8 @@ function randomIP() { return [1,2,3,4].map(() => Math.floor(Math.random()*255)+1
135135

136136
</details>
137137

138-
Automating deployment and rotation with FlareProx
138+
### Automating deployment and rotation with FlareProx
139+
139140
FlareProx is a Python tool that uses the Cloudflare API to deploy many Worker endpoints and rotate across them. This provides FireProx-like IP rotation from Cloudflare’s network.
140141

141142
Setup
@@ -148,7 +149,7 @@ cd flareprox
148149
pip install -r requirements.txt
149150
```
150151

151-
Create config file flareprox.json:
152+
**Create config file flareprox.json:**
152153

153154
```json
154155
{
@@ -159,7 +160,8 @@ Create config file flareprox.json:
159160
}
160161
```
161162

162-
CLI usage
163+
**CLI usage**
164+
163165
- Create N Worker proxies:
164166
```bash
165167
python3 flareprox.py create --count 2
@@ -177,7 +179,7 @@ python3 flareprox.py test
177179
python3 flareprox.py cleanup
178180
```
179181

180-
Routing traffic through a Worker
182+
**Routing traffic through a Worker**
181183
- Query parameter form:
182184
```bash
183185
curl "https://your-worker.account.workers.dev?url=https://httpbin.org/ip"
@@ -208,14 +210,16 @@ curl -X DELETE \
208210
"https://your-worker.account.workers.dev?url=https://httpbin.org/delete"
209211
```
210212

211-
X-Forwarded-For control
212-
If the Worker honors X-My-X-Forwarded-For, you can influence the upstream X-Forwarded-For value:
213+
**`X-Forwarded-For` control**
214+
215+
If the Worker honors `X-My-X-Forwarded-For`, you can influence the upstream `X-Forwarded-For` value:
213216
```bash
214217
curl -H "X-My-X-Forwarded-For: 203.0.113.10" \
215218
"https://your-worker.account.workers.dev?url=https://httpbin.org/headers"
216219
```
217220

218-
Programmatic usage
221+
**Programmatic usage**
222+
219223
Use the FlareProx library to create/list/test endpoints and route requests from Python.
220224

221225
<details>
@@ -274,30 +278,16 @@ except Exception as e:
274278

275279
</details>
276280

277-
Burp/Scanner integration
281+
**Burp/Scanner integration**
278282
- Point tooling (for example, Burp Suite) at the Worker URL.
279283
- Supply the real upstream using ?url= or X-Target-URL.
280284
- HTTP semantics (methods/headers/body) are preserved while masking your source IP behind Cloudflare.
281285

282-
Operational notes and limits
286+
**Operational notes and limits**
283287
- Cloudflare Workers Free plan allows roughly 100,000 requests/day per account; use multiple endpoints to distribute traffic if needed.
284288
- Workers run on Cloudflare’s network; many targets will only see Cloudflare IPs/ASN, which can bypass naive IP allow/deny lists or geo heuristics.
285289
- Use responsibly and only with authorization. Respect ToS and robots.txt.
286290

287-
Detection and mitigation (defender notes)
288-
If your application is the target and you wish to prevent access via generic Cloudflare-originated proxies (Workers, other Cloudflare egress):
289-
- Do not rely solely on IP allow/deny lists; Cloudflare Workers share Cloudflare IP space and ASN (AS13335). Blocking all Cloudflare IPs is often impractical.
290-
- Require strong request authentication at the application layer (tokens, HMAC-signed headers, mTLS, per-client API keys), and validate them server-side.
291-
- For Cloudflare-protected origins you control, consider:
292-
- Authenticated Origin Pulls or mTLS between Cloudflare and origin so only your own zone can reach the origin.
293-
- WAF/Firewall Rules that require a secret header or signed token and block requests missing them.
294-
- API Shield (schema validation, mTLS, JWT validation) and Bot Fight Mode/Super Bot Fight Mode to reduce automated abuse.
295-
- Rate limiting by path/user token; challenge or block requests lacking expected cookies/headers from your first-party app flows.
296-
- Monitor for anomalies: unusual user agents, inconsistent headers, rapidly shifting Cloudflare IPs, or requests to endpoints that should only be hit by your front-end.
297-
298-
Related techniques
299-
- FireProx (AWS API Gateway) pioneered pass-through proxying for IP rotation and header control; Workers provide a similar pattern with Cloudflare egress.
300-
301291
## References
302292
- [FlareProx (Cloudflare Workers pass-through/rotation)](https://github.com/MrTurvey/flareprox)
303293
- [Cloudflare Workers fetch() API](https://developers.cloudflare.com/workers/runtime-apis/fetch/)

0 commit comments

Comments
 (0)