@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,157 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: argument-injection
|
|
3
|
+
description: Test shell-free command argument injection across argv builders and CLI parsers, including option smuggling, response/config-file parsing, argument-boundary reparsing, and Windows Unicode-to-ANSI Best-Fit transformations
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Argument Injection
|
|
7
|
+
|
|
8
|
+
Use this skill when attacker-influenced data reaches a trusted command-line program, even when no shell is involved. The security question is whether the input changes the program's **option set, operands, configuration, subcommand, or downstream parser state**.
|
|
9
|
+
|
|
10
|
+
Load `rce` when a shell parses the command string. Load `semantic_confusion` when validation and the final CLI/filesystem/configuration consumer see different representations.
|
|
11
|
+
|
|
12
|
+
## Model Every Parser Boundary
|
|
13
|
+
|
|
14
|
+
Build the actual transformation chain:
|
|
15
|
+
|
|
16
|
+
```text
|
|
17
|
+
request value
|
|
18
|
+
-> application validation
|
|
19
|
+
-> argv builder or command-line string serializer
|
|
20
|
+
-> OS/process creation API
|
|
21
|
+
-> runtime argv construction
|
|
22
|
+
-> target option parser
|
|
23
|
+
-> response/config/auth file parser, URL parser, or subcommand
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Do not treat all process APIs alike:
|
|
27
|
+
|
|
28
|
+
- POSIX `execve(path, argv, envp)` and list-form subprocess APIs preserve array-element boundaries. Whitespace inside one element does not create another argument.
|
|
29
|
+
- Shell/string forms introduce shell tokenization before the target program sees `argv`.
|
|
30
|
+
- Windows process creation commonly serializes an argument array into one command-line string and lets the child runtime parse it back. Quoting rules differ across CRTs and applications.
|
|
31
|
+
- Some programs deliberately reparse an argument as a response file, configuration file, URL, expression, template, or nested command language.
|
|
32
|
+
|
|
33
|
+
Record the exact API, platform, runtime, target binary/version, option parser, and final `argv` observed by the child.
|
|
34
|
+
|
|
35
|
+
## Primitive 1: Option and Subcommand Injection
|
|
36
|
+
|
|
37
|
+
An attacker-controlled value placed where an operand is expected can be interpreted as an option when it begins with an option prefix:
|
|
38
|
+
|
|
39
|
+
```text
|
|
40
|
+
intended: ["tool", USER_VALUE]
|
|
41
|
+
supplied: USER_VALUE = "--output=/controlled/path"
|
|
42
|
+
actual: tool parses an output option instead of an operand
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Inventory security-relevant option classes rather than memorizing one payload:
|
|
46
|
+
|
|
47
|
+
- output, upload, extraction, log, cache, plugin, template, or configuration paths
|
|
48
|
+
- alternate URL schemes, proxies, certificates, credentials, and authentication files
|
|
49
|
+
- hooks, helpers, filters, interpreters, external programs, or dynamic libraries
|
|
50
|
+
- config overrides, environment definitions, working directories, and search paths
|
|
51
|
+
- subcommands that expose administrative, import/export, restore, diagnostic, or execution features
|
|
52
|
+
|
|
53
|
+
Check whether the target supports `--` as an end-of-options marker and whether the application places it before the untrusted operand. Do not assume every CLI honors `--`, or that it applies after a subcommand switches to a second parser.
|
|
54
|
+
|
|
55
|
+
## Primitive 2: Argument-Boundary Breakout
|
|
56
|
+
|
|
57
|
+
Require a component that reparses or reconstructs arguments. Candidate boundaries include:
|
|
58
|
+
|
|
59
|
+
- shell or command-string construction
|
|
60
|
+
- Windows quoting/escaping mismatches between parent and child runtimes
|
|
61
|
+
- newline-, NUL-, delimiter-, or quote-sensitive custom launchers
|
|
62
|
+
- wrappers that join an array and later split it
|
|
63
|
+
- CGI/interpreter mappings that turn request data into command-line options
|
|
64
|
+
|
|
65
|
+
Distinguish these outcomes:
|
|
66
|
+
|
|
67
|
+
```text
|
|
68
|
+
["tool", "user --flag"] # one argv element; no split by execve
|
|
69
|
+
["tool", "user", "--flag"] # extra argv element reached the target
|
|
70
|
+
["tool", "@args.txt"] # one element, then reparsed by the target
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Logs often render arrays as strings and can falsely suggest splitting. Capture the child's real arguments through source instrumentation, a wrapper process, debugger, audit trace, `/proc/<pid>/cmdline`, or the platform equivalent.
|
|
74
|
+
|
|
75
|
+
## Primitive 3: Response, Config, and Authentication Files
|
|
76
|
+
|
|
77
|
+
Many trusted programs consume a second language after argv parsing:
|
|
78
|
+
|
|
79
|
+
- `@response-file` syntax used by compilers, linkers, JVM tooling, and custom launchers
|
|
80
|
+
- `--config`, `-K`, credentials/auth files, include files, and rc/profile paths
|
|
81
|
+
- newline-delimited key/value files generated from attacker-controlled fields
|
|
82
|
+
- file contents where control characters create a new directive, identity, host, or option
|
|
83
|
+
|
|
84
|
+
Trace both attacker influence over the **file path** and influence over the **file content**. Correct shell quoting does not protect a file that is later tokenized by a different grammar. Record duplicate-key behavior, newline rules, comments, escaping, include directives, and first/last-value precedence.
|
|
85
|
+
|
|
86
|
+
## Windows Unicode-to-ANSI Best-Fit
|
|
87
|
+
|
|
88
|
+
On Windows, narrow-character APIs and CRT startup paths can convert Unicode command-line, environment, or filesystem data into an ANSI code page. Best-Fit mappings may introduce ASCII characters after earlier validation.
|
|
89
|
+
|
|
90
|
+
Relevant boundaries include:
|
|
91
|
+
|
|
92
|
+
- `GetCommandLineA` or a narrow `main(int, char **)` startup path
|
|
93
|
+
- `GetEnvironmentVariableA`, `GetCurrentDirectoryA`, and narrow filesystem APIs
|
|
94
|
+
- framework or native-extension transitions from UTF-16 strings to an ANSI code page
|
|
95
|
+
|
|
96
|
+
`CommandLineToArgvW` is the documented Windows command-line parser; there is no documented `CommandLineToArgvA`. Determine which CRT or application-specific parser constructs narrow `argv`.
|
|
97
|
+
|
|
98
|
+
Treat mappings as code-page-specific hypotheses, not universal payloads. Candidate transformations include soft hyphen to `-`, fullwidth/compatibility slash characters to `/` or `\`, and compatibility quotes or letters to ASCII equivalents. Capture:
|
|
99
|
+
|
|
100
|
+
- submitted Unicode code points and encoded bytes
|
|
101
|
+
- active system/process code page
|
|
102
|
+
- wide string before conversion
|
|
103
|
+
- narrow bytes and final `argv` or filesystem path after conversion
|
|
104
|
+
|
|
105
|
+
Using wide-character APIs removes this particular conversion boundary but does not fix ordinary option injection.
|
|
106
|
+
|
|
107
|
+
## Reconnaissance
|
|
108
|
+
|
|
109
|
+
In source, locate process creation and work forward into the consumer:
|
|
110
|
+
|
|
111
|
+
```text
|
|
112
|
+
exec* posix_spawn subprocess ProcessBuilder Runtime.exec
|
|
113
|
+
CreateProcess ShellExecute child_process os/exec Command
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
For each attacker-controlled argument, answer:
|
|
117
|
+
|
|
118
|
+
1. Is it a distinct argv element or part of a command string?
|
|
119
|
+
2. Can it begin with the target's option prefix?
|
|
120
|
+
3. Is an end-of-options marker supported and correctly positioned?
|
|
121
|
+
4. Does a wrapper, CRT, shell, or target reparse it?
|
|
122
|
+
5. Can it select a response/config/auth file or inject directives into one?
|
|
123
|
+
6. Which target option or subcommand turns that control into read, write, request, identity, or execution capability?
|
|
124
|
+
|
|
125
|
+
For black-box testing, compare an ordinary operand with option-prefixed, delimiter-bearing, control-character, and platform-specific Unicode variants. Match tests to options that actually exist in the deployed binary/version.
|
|
126
|
+
|
|
127
|
+
## Validation
|
|
128
|
+
|
|
129
|
+
- Show the final `argv` or secondary parser input, not only the application log line.
|
|
130
|
+
- Pair the candidate with a control where the same bytes remain a literal operand.
|
|
131
|
+
- Demonstrate the exact option, directive, subcommand, path, or handler selected.
|
|
132
|
+
- Reproduce against the deployed binary, runtime, code page, and configuration.
|
|
133
|
+
- Separate option control, additional-argument control, arbitrary directive control, and command execution; they are different primitives.
|
|
134
|
+
|
|
135
|
+
## False Positives
|
|
136
|
+
|
|
137
|
+
- The input is one argv element and the target treats it only as a positional operand.
|
|
138
|
+
- `--` is supported, placed before the value, and not bypassed by a subparser.
|
|
139
|
+
- A strict allowlist prevents option prefixes and all later transformations preserve it.
|
|
140
|
+
- A delimiter appears only in logging or display formatting.
|
|
141
|
+
- A response/config path is controllable but its contents or directives are not.
|
|
142
|
+
- A Unicode character is accepted but no narrow/Best-Fit conversion occurs.
|
|
143
|
+
- The injected option exists on another release or platform but not the deployed target.
|
|
144
|
+
|
|
145
|
+
## Remediation
|
|
146
|
+
|
|
147
|
+
- Use argument-array process APIs and avoid shell/string construction.
|
|
148
|
+
- Insert `--` before untrusted operands where every relevant parser supports it.
|
|
149
|
+
- Validate operands against the target CLI's grammar, not a generic shell blacklist.
|
|
150
|
+
- Fix security-sensitive option names and configuration paths in trusted code.
|
|
151
|
+
- Generate configuration/auth files with a format-aware serializer that rejects control characters and ambiguous duplicates.
|
|
152
|
+
- On Windows, keep data in wide-character APIs and verify child-runtime parsing rules.
|
|
153
|
+
- Enforce authorization again at the privileged operation selected by the CLI.
|
|
154
|
+
|
|
155
|
+
## Summary
|
|
156
|
+
|
|
157
|
+
Argument injection is control of a trusted program's behavior through its argv or a parser reached from argv. Preserve parser boundaries in the model: list-form execution, command-string tokenization, Windows runtime conversion, option parsing, and response/config-file parsing are distinct stages with distinct exploit conditions.
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: authentication-jwt
|
|
3
|
+
description: JWT and OIDC security testing covering token forgery, algorithm confusion, and claim manipulation
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Authentication / JWT / OIDC
|
|
7
|
+
|
|
8
|
+
JWT/OIDC failures often enable token forgery, token confusion, cross-service acceptance, and durable account takeover. Do not trust headers, claims, or token opacity without strict validation bound to issuer, audience, key, and context.
|
|
9
|
+
|
|
10
|
+
## Attack Surface
|
|
11
|
+
|
|
12
|
+
- Web/mobile/API authentication using JWT (JWS/JWE) and OIDC/OAuth2
|
|
13
|
+
- Access vs ID tokens, refresh tokens, device/PKCE/Backchannel flows
|
|
14
|
+
- First-party and microservices verification, gateways, and JWKS distribution
|
|
15
|
+
|
|
16
|
+
## Reconnaissance
|
|
17
|
+
|
|
18
|
+
### Endpoints
|
|
19
|
+
|
|
20
|
+
- Well-known: `/.well-known/openid-configuration`, `/oauth2/.well-known/openid-configuration`
|
|
21
|
+
- Keys: `/jwks.json`, rotating key endpoints, tenant-specific JWKS
|
|
22
|
+
- Auth: `/authorize`, `/token`, `/introspect`, `/revoke`, `/logout`, device code endpoints
|
|
23
|
+
- App: `/login`, `/callback`, `/refresh`, `/me`, `/session`, `/impersonate`
|
|
24
|
+
|
|
25
|
+
### Token Features
|
|
26
|
+
|
|
27
|
+
- Headers: `{"alg":"RS256","kid":"...","typ":"JWT","jku":"...","x5u":"...","jwk":{...}}`
|
|
28
|
+
- Claims: `{"iss":"...","aud":"...","azp":"...","sub":"user","scope":"...","exp":...,"nbf":...,"iat":...}`
|
|
29
|
+
- Formats: JWS (signed), JWE (encrypted). Note unencoded payload option (`"b64":false`) and critical headers (`"crit"`)
|
|
30
|
+
|
|
31
|
+
## Key Vulnerabilities
|
|
32
|
+
|
|
33
|
+
### Signature Verification
|
|
34
|
+
|
|
35
|
+
- RS256→HS256 confusion: change alg to HS256 and use the RSA public key as HMAC secret if algorithm is not pinned
|
|
36
|
+
- "none" algorithm acceptance: set `"alg":"none"` and drop the signature if libraries accept it
|
|
37
|
+
- ECDSA malleability/misuse: weak verification settings accepting non-canonical signatures
|
|
38
|
+
|
|
39
|
+
### Header Manipulation
|
|
40
|
+
|
|
41
|
+
- **kid injection**: path traversal `../../../../keys/prod.key`, SQL/command/template injection in key lookup, or pointing to world-readable files
|
|
42
|
+
- **jku/x5u abuse**: host attacker-controlled JWKS/X509 chain; if not pinned/whitelisted, server fetches and trusts attacker keys
|
|
43
|
+
- **jwk header injection**: embed attacker JWK in header; some libraries prefer inline JWK over server-configured keys
|
|
44
|
+
- **SSRF via remote key fetch**: exploit JWKS URL fetching to reach internal hosts
|
|
45
|
+
|
|
46
|
+
### Key and Cache Issues
|
|
47
|
+
|
|
48
|
+
- JWKS caching TTL and key rollover: accept obsolete keys; race rotation windows; missing kid pinning → accept any matching kty/alg
|
|
49
|
+
- Mixed environments: same secrets across dev/stage/prod; key reuse across tenants or services
|
|
50
|
+
- Fallbacks: verification succeeds when kid not found by trying all keys or no keys (implementation bugs)
|
|
51
|
+
|
|
52
|
+
### Claims Validation Gaps
|
|
53
|
+
|
|
54
|
+
- iss/aud/azp not enforced: cross-service token reuse; accept tokens from any issuer or wrong audience
|
|
55
|
+
- scope/roles fully trusted from token: server does not re-derive authorization; privilege inflation via claim edits when signature checks are weak
|
|
56
|
+
- exp/nbf/iat not enforced or large clock skew tolerance; accept long-expired or not-yet-valid tokens
|
|
57
|
+
- typ/cty not enforced: accept ID token where access token required (token confusion)
|
|
58
|
+
|
|
59
|
+
### Token Confusion and OIDC
|
|
60
|
+
|
|
61
|
+
- Access vs ID token swap: use ID token against APIs when they only verify signature but not audience/typ
|
|
62
|
+
- OIDC mix-up: redirect_uri and client mix-ups causing tokens for Client A to be redeemed at Client B
|
|
63
|
+
- PKCE downgrades: missing S256 requirement; accept plain or absent code_verifier
|
|
64
|
+
- State/nonce weaknesses: predictable or missing → CSRF/logical interception of login
|
|
65
|
+
- Device/Backchannel flows: codes and tokens accepted by unintended clients or services
|
|
66
|
+
|
|
67
|
+
### Refresh and Session
|
|
68
|
+
|
|
69
|
+
- Refresh token rotation not enforced: reuse old refresh token indefinitely; no reuse detection
|
|
70
|
+
- Long-lived JWTs with no revocation: persistent access post-logout
|
|
71
|
+
- Session fixation: bind new tokens to attacker-controlled session identifiers or cookies
|
|
72
|
+
|
|
73
|
+
### Transport and Storage
|
|
74
|
+
|
|
75
|
+
- Token in localStorage/sessionStorage: susceptible to XSS exfiltration; cookie vs header trade-offs with SameSite/CSRF
|
|
76
|
+
- Insecure CORS: wildcard origins with credentialed requests expose tokens and protected responses
|
|
77
|
+
- TLS and cookie flags: missing Secure/HttpOnly; lack of mTLS or DPoP/"cnf" binding permits replay from another device
|
|
78
|
+
|
|
79
|
+
## Advanced Techniques
|
|
80
|
+
|
|
81
|
+
### Microservices and Gateways
|
|
82
|
+
|
|
83
|
+
- Audience mismatch: internal services verify signature but ignore aud → accept tokens for other services
|
|
84
|
+
- Header trust: edge or gateway injects X-User-Id; backend trusts it over token claims
|
|
85
|
+
- Asynchronous consumers: workers process messages with bearer tokens but skip verification on replay
|
|
86
|
+
|
|
87
|
+
### JWS Edge Cases
|
|
88
|
+
|
|
89
|
+
- Unencoded payload (b64=false) with crit header: libraries mishandle verification paths
|
|
90
|
+
- Nested JWT (JWT-in-JWT) verification order errors; outer token accepted while inner claims ignored
|
|
91
|
+
|
|
92
|
+
## Special Contexts
|
|
93
|
+
|
|
94
|
+
### Mobile
|
|
95
|
+
|
|
96
|
+
- Deep-link/redirect handling bugs leak codes/tokens; insecure WebView bridges exposing tokens
|
|
97
|
+
- Token storage in plaintext files/SQLite/Keychain/SharedPrefs; backup/adb accessible
|
|
98
|
+
|
|
99
|
+
### SSO Federation
|
|
100
|
+
|
|
101
|
+
- Misconfigured trust between multiple IdPs/SPs, mixed metadata, or stale keys lead to acceptance of foreign tokens
|
|
102
|
+
|
|
103
|
+
## Chaining Attacks
|
|
104
|
+
|
|
105
|
+
- XSS → token theft → replay across services with weak audience checks
|
|
106
|
+
- SSRF → fetch private JWKS → sign tokens accepted by internal services
|
|
107
|
+
- Host header poisoning → OIDC redirect_uri poisoning → code capture
|
|
108
|
+
- IDOR in sessions/impersonation endpoints → mint tokens for other users
|
|
109
|
+
|
|
110
|
+
## Testing Methodology
|
|
111
|
+
|
|
112
|
+
1. **Inventory issuers/consumers** - Identity providers, API gateways, services, mobile/web clients
|
|
113
|
+
2. **Capture tokens** - Access and ID tokens for multiple roles; note header, claims, signature
|
|
114
|
+
3. **Map verification endpoints** - `/.well-known`, `/jwks.json`
|
|
115
|
+
4. **Build matrix** - Token Type × Audience × Service; attempt cross-use
|
|
116
|
+
5. **Mutate components** - Headers (alg, kid, jku/x5u/jwk), claims (iss/aud/azp/sub/exp), signatures
|
|
117
|
+
6. **Verify enforcement** - What is actually checked vs assumed
|
|
118
|
+
|
|
119
|
+
## Validation
|
|
120
|
+
|
|
121
|
+
1. Show forged or cross-context token acceptance (wrong alg, wrong audience/issuer, or attacker-signed JWKS)
|
|
122
|
+
2. Demonstrate access token vs ID token confusion at an API
|
|
123
|
+
3. Prove refresh token reuse without rotation detection or revocation
|
|
124
|
+
4. Confirm header abuse (kid/jku/x5u/jwk) leading to key selection under attacker control
|
|
125
|
+
5. Provide owner vs non-owner evidence with identical requests differing only in token context
|
|
126
|
+
|
|
127
|
+
## False Positives
|
|
128
|
+
|
|
129
|
+
- Token rejected due to strict audience/issuer enforcement
|
|
130
|
+
- Key pinning with JWKS whitelist and TLS validation
|
|
131
|
+
- Short-lived tokens with rotation and revocation on logout
|
|
132
|
+
- ID token not accepted by APIs that require access tokens
|
|
133
|
+
|
|
134
|
+
## Impact
|
|
135
|
+
|
|
136
|
+
- Account takeover and durable session persistence
|
|
137
|
+
- Privilege escalation via claim manipulation or cross-service acceptance
|
|
138
|
+
- Cross-tenant or cross-application data access
|
|
139
|
+
- Token minting by attacker-controlled keys or endpoints
|
|
140
|
+
|
|
141
|
+
## Pro Tips
|
|
142
|
+
|
|
143
|
+
1. Pin verification to issuer and audience; log and diff claim sets across services
|
|
144
|
+
2. Attempt RS256→HS256 and "none" first only if algorithm pinning is unclear; otherwise focus on header key control (kid/jku/x5u/jwk)
|
|
145
|
+
3. Test token reuse across all services; many backends only check signature, not audience/typ
|
|
146
|
+
4. Exploit JWKS caching and rotation races; try retired keys and missing kid fallbacks
|
|
147
|
+
5. Exercise OIDC flows with PKCE/state/nonce variants and mixed clients; look for mix-up
|
|
148
|
+
6. Try DPoP/mTLS absence to replay tokens from different devices
|
|
149
|
+
7. Treat refresh as its own surface: rotation, reuse detection, and audience scoping
|
|
150
|
+
8. Validate every acceptance path: gateway, service, worker, WebSocket, and gRPC
|
|
151
|
+
9. Favor minimal PoCs that clearly show cross-context acceptance and durable access
|
|
152
|
+
10. When in doubt, assume verification differs per stack (mobile vs web vs gateway) and test each
|
|
153
|
+
|
|
154
|
+
## Tooling
|
|
155
|
+
|
|
156
|
+
- `jwt_tool -t <url> -rh "Authorization: Bearer <token>" -M at` runs the
|
|
157
|
+
full attack matrix (alg=none, RS→HS confusion, kid injection, claim
|
|
158
|
+
edits) and reports which mutations the server still accepts.
|
|
159
|
+
- `jwt_tool <token> -C -d <wordlist>` brute-forces HMAC secrets when an
|
|
160
|
+
HS-family signature is in use.
|
|
161
|
+
- Use `jwt_tool` to mint a token under a key you control once you find an
|
|
162
|
+
acceptance path (kid/jku/x5u/jwk), then replay via `repeat_request`.
|
|
163
|
+
|
|
164
|
+
## Summary
|
|
165
|
+
|
|
166
|
+
Verification must bind the token to the correct issuer, audience, key, and client context on every acceptance path. Any missing binding enables forgery or confusion.
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: broken-function-level-authorization
|
|
3
|
+
description: BFLA testing for action-level authorization failures across endpoints, admin functions, and API operations
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Broken Function Level Authorization (BFLA)
|
|
7
|
+
|
|
8
|
+
BFLA is action-level authorization failure: callers invoke functions (endpoints, mutations, admin tools) they are not entitled to. It appears when enforcement differs across transports, gateways, roles, or when services trust client hints. Bind subject × action at the service that performs the action.
|
|
9
|
+
|
|
10
|
+
## Attack Surface
|
|
11
|
+
|
|
12
|
+
- Vertical authz: privileged/admin/staff-only actions reachable by basic users
|
|
13
|
+
- Feature gates: toggles enforced at edge/UI, not at core services
|
|
14
|
+
- Transport drift: REST vs GraphQL vs gRPC vs WebSocket with inconsistent checks
|
|
15
|
+
- Gateway trust: backends trust X-User-Id/X-Role injected by proxies/edges
|
|
16
|
+
- Background workers/jobs performing actions without re-checking authz
|
|
17
|
+
|
|
18
|
+
## High-Value Actions
|
|
19
|
+
|
|
20
|
+
- Role/permission changes, impersonation/sudo, invite/accept into orgs
|
|
21
|
+
- Approve/void/refund/credit issuance, price/plan overrides
|
|
22
|
+
- Export/report generation, data deletion, account suspension/reactivation
|
|
23
|
+
- Feature flag toggles, quota/grant adjustments, license/seat changes
|
|
24
|
+
- Security settings: 2FA reset, email/phone verification overrides
|
|
25
|
+
|
|
26
|
+
## Reconnaissance
|
|
27
|
+
|
|
28
|
+
### Surface Enumeration
|
|
29
|
+
|
|
30
|
+
- Admin/staff consoles and APIs, support tools, internal-only endpoints exposed via gateway
|
|
31
|
+
- Hidden buttons and disabled UI paths (feature-flagged) mapped to still-live endpoints
|
|
32
|
+
- GraphQL schemas: mutations and admin-only fields/types; gRPC service descriptors (reflection)
|
|
33
|
+
- Mobile clients often reveal extra endpoints/roles in app bundles or network logs
|
|
34
|
+
|
|
35
|
+
### Signals
|
|
36
|
+
|
|
37
|
+
- 401/403 on UI but 200 via direct API call; differing status codes across transports
|
|
38
|
+
- Actions succeed via background jobs when direct call is denied
|
|
39
|
+
- Changing only headers (role/org) alters access without token change
|
|
40
|
+
|
|
41
|
+
## Key Vulnerabilities
|
|
42
|
+
|
|
43
|
+
### Verb Drift and Aliases
|
|
44
|
+
|
|
45
|
+
- Alternate methods: GET performing state change; POST vs PUT vs PATCH differences; X-HTTP-Method-Override/_method
|
|
46
|
+
- Alternate endpoints performing the same action with weaker checks (legacy vs v2, mobile vs web)
|
|
47
|
+
|
|
48
|
+
### Edge vs Core Mismatch
|
|
49
|
+
|
|
50
|
+
- Edge blocks an action but core service RPC accepts it directly; call internal service via exposed API route or SSRF
|
|
51
|
+
- Gateway-injected identity headers override token claims; supply conflicting headers to test precedence
|
|
52
|
+
|
|
53
|
+
### Feature Flag Bypass
|
|
54
|
+
|
|
55
|
+
- Client-checked feature gates; call backend endpoints directly
|
|
56
|
+
- Admin-only mutations exposed but hidden in UI; invoke via GraphQL or gRPC tools
|
|
57
|
+
|
|
58
|
+
### Batch Job Paths
|
|
59
|
+
|
|
60
|
+
- Create export/import jobs where creation is allowed but finalize/approve lacks authz; finalize others' jobs
|
|
61
|
+
- Replay webhooks/background tasks endpoints that perform privileged actions without verifying caller
|
|
62
|
+
|
|
63
|
+
### Content-Type Paths
|
|
64
|
+
|
|
65
|
+
- JSON vs form vs multipart handlers using different middleware: send the action via the most permissive parser
|
|
66
|
+
|
|
67
|
+
## Advanced Techniques
|
|
68
|
+
|
|
69
|
+
### GraphQL
|
|
70
|
+
|
|
71
|
+
- Resolver-level checks per mutation/field; do not assume top-level auth covers nested mutations or admin fields
|
|
72
|
+
- Abuse aliases/batching to sneak privileged fields; persisted queries sometimes bypass auth transforms
|
|
73
|
+
|
|
74
|
+
```graphql
|
|
75
|
+
mutation Promote($id:ID!){
|
|
76
|
+
a: updateUser(id:$id, role: ADMIN){ id role }
|
|
77
|
+
}
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### gRPC
|
|
81
|
+
|
|
82
|
+
- Method-level auth via interceptors must enforce audience/roles; probe direct gRPC with tokens of lower role
|
|
83
|
+
- Reflection lists services/methods; call admin methods that the gateway hid
|
|
84
|
+
|
|
85
|
+
### WebSocket
|
|
86
|
+
|
|
87
|
+
- Handshake-only auth: ensure per-message authorization on privileged events (e.g., admin:impersonate)
|
|
88
|
+
- Try emitting privileged actions after joining standard channels
|
|
89
|
+
|
|
90
|
+
### Multi-Tenant
|
|
91
|
+
|
|
92
|
+
- Actions requiring tenant admin enforced only by header/subdomain; attempt cross-tenant admin actions by switching selectors with same token
|
|
93
|
+
|
|
94
|
+
### Microservices
|
|
95
|
+
|
|
96
|
+
- Internal RPCs trust upstream checks; reach them through exposed endpoints or SSRF; verify each service re-enforces authz
|
|
97
|
+
|
|
98
|
+
## Bypass Techniques
|
|
99
|
+
|
|
100
|
+
### Header Trust
|
|
101
|
+
|
|
102
|
+
- Supply X-User-Id/X-Role/X-Organization headers; remove or contradict token claims; observe which source wins
|
|
103
|
+
|
|
104
|
+
### Route Shadowing
|
|
105
|
+
|
|
106
|
+
- Legacy/alternate routes (e.g., /admin/v1 vs /v2/admin) that skip new middleware chains
|
|
107
|
+
|
|
108
|
+
### Idempotency and Retries
|
|
109
|
+
|
|
110
|
+
- Retry or replay finalize/approve endpoints that apply state without checking actor on each call
|
|
111
|
+
|
|
112
|
+
### Cache Key Confusion
|
|
113
|
+
|
|
114
|
+
- Cached authorization decisions at edge leading to cross-user reuse; test with Vary and session swaps
|
|
115
|
+
|
|
116
|
+
## Testing Methodology
|
|
117
|
+
|
|
118
|
+
1. **Build Actor × Action matrix** - Unauth, basic, premium, staff/admin; enumerate actions per role
|
|
119
|
+
2. **Obtain tokens/sessions** - For each role
|
|
120
|
+
3. **Exercise every action** - Across all transports and encodings (JSON, form, multipart), including method overrides
|
|
121
|
+
4. **Vary headers and selectors** - Org/tenant/project; test behind gateway vs direct-to-service
|
|
122
|
+
5. **Include background flows** - Job creation/finalization, webhooks, queues; confirm re-validation
|
|
123
|
+
|
|
124
|
+
## Validation
|
|
125
|
+
|
|
126
|
+
1. Show a lower-privileged principal successfully invokes a restricted action (same inputs) while the proper role succeeds and another lower role fails
|
|
127
|
+
2. Provide evidence across at least two transports or encodings demonstrating inconsistent enforcement
|
|
128
|
+
3. Demonstrate that removing/altering client-side gates (buttons/flags) does not affect backend success
|
|
129
|
+
4. Include durable state change proof: before/after snapshots, audit logs, and authoritative sources
|
|
130
|
+
|
|
131
|
+
## False Positives
|
|
132
|
+
|
|
133
|
+
- Read-only endpoints mislabeled as admin but publicly documented
|
|
134
|
+
- Feature toggles intentionally open to all roles for preview/beta with clear policy
|
|
135
|
+
- Simulated environments where admin endpoints are stubbed with no side effects
|
|
136
|
+
|
|
137
|
+
## Impact
|
|
138
|
+
|
|
139
|
+
- Privilege escalation to admin/staff actions
|
|
140
|
+
- Monetary/state impact: refunds/credits/approvals without authorization
|
|
141
|
+
- Tenant-wide configuration changes, impersonation, or data deletion
|
|
142
|
+
- Compliance and audit violations due to bypassed approval workflows
|
|
143
|
+
|
|
144
|
+
## Pro Tips
|
|
145
|
+
|
|
146
|
+
1. Start from the role matrix; test every action with basic vs admin tokens across REST/GraphQL/gRPC
|
|
147
|
+
2. Diff middleware stacks between routes; weak chains often exist on legacy or alternate encodings
|
|
148
|
+
3. Inspect gateways for identity header injection; never trust client-provided identity
|
|
149
|
+
4. Treat jobs/webhooks as first-class: finalize/approve must re-check the actor
|
|
150
|
+
5. Prefer minimal PoCs: one request that flips a privileged field or invokes an admin method with a basic token
|
|
151
|
+
|
|
152
|
+
## Summary
|
|
153
|
+
|
|
154
|
+
Authorization must bind the actor to the specific action at the service boundary on every request and message. UI gates, gateways, or prior steps do not substitute for function-level checks.
|