@gpzhang2001/sharpkit-skills 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +12 -0
  3. package/THIRD_PARTY_NOTICES.md +48 -0
  4. package/lib/index.d.ts +2027 -0
  5. package/lib/index.d.ts.map +1 -0
  6. package/lib/index.js +70 -0
  7. package/lib/index.js.map +1 -0
  8. package/package.json +46 -0
  9. package/skills/analysis/counterevidence.md +185 -0
  10. package/skills/analysis/fix_verification.md +129 -0
  11. package/skills/analysis/severity_calibration.md +130 -0
  12. package/skills/analysis/source_aware_discovery.md +211 -0
  13. package/skills/cloud/aws.md +231 -0
  14. package/skills/cloud/azure.md +262 -0
  15. package/skills/cloud/gcp.md +194 -0
  16. package/skills/cloud/kubernetes.md +223 -0
  17. package/skills/coordination/root_agent.md +105 -0
  18. package/skills/coordination/source_aware_whitebox.md +47 -0
  19. package/skills/custom/api_spec_testing.md +61 -0
  20. package/skills/custom/dependency_cve_scanning.md +341 -0
  21. package/skills/custom/npx_confusion.md +233 -0
  22. package/skills/custom/source_aware_sast.md +192 -0
  23. package/skills/frameworks/django.md +214 -0
  24. package/skills/frameworks/fastapi.md +191 -0
  25. package/skills/frameworks/nestjs.md +225 -0
  26. package/skills/frameworks/nextjs.md +228 -0
  27. package/skills/protocols/graphql.md +276 -0
  28. package/skills/protocols/oauth.md +185 -0
  29. package/skills/reconnaissance/asset_discovery.md +150 -0
  30. package/skills/reconnaissance/infrastructure_lifecycle.md +226 -0
  31. package/skills/scan_modes/deep.md +164 -0
  32. package/skills/scan_modes/diff.md +86 -0
  33. package/skills/scan_modes/quick.md +68 -0
  34. package/skills/scan_modes/standard.md +99 -0
  35. package/skills/technologies/active_directory.md +233 -0
  36. package/skills/technologies/auth0.md +188 -0
  37. package/skills/technologies/electron_desktop_apps.md +181 -0
  38. package/skills/technologies/firebase.md +263 -0
  39. package/skills/technologies/grafana_prometheus.md +189 -0
  40. package/skills/technologies/llm_applications.md +257 -0
  41. package/skills/technologies/supabase.md +268 -0
  42. package/skills/tooling/agent_browser.md +551 -0
  43. package/skills/tooling/ffuf.md +72 -0
  44. package/skills/tooling/httpx.md +82 -0
  45. package/skills/tooling/hurl.md +99 -0
  46. package/skills/tooling/hypothesis.md +100 -0
  47. package/skills/tooling/katana.md +102 -0
  48. package/skills/tooling/naabu.md +68 -0
  49. package/skills/tooling/nmap.md +66 -0
  50. package/skills/tooling/nuclei.md +67 -0
  51. package/skills/tooling/python.md +109 -0
  52. package/skills/tooling/semgrep.md +72 -0
  53. package/skills/tooling/sqlmap.md +67 -0
  54. package/skills/tooling/subfinder.md +66 -0
  55. package/skills/vulnerabilities/agentic_system_security.md +207 -0
  56. package/skills/vulnerabilities/argument_injection.md +157 -0
  57. package/skills/vulnerabilities/authentication_jwt.md +166 -0
  58. package/skills/vulnerabilities/broken_function_level_authorization.md +154 -0
  59. package/skills/vulnerabilities/browser_security.md +192 -0
  60. package/skills/vulnerabilities/business_logic.md +178 -0
  61. package/skills/vulnerabilities/csrf.md +198 -0
  62. package/skills/vulnerabilities/header_injection.md +216 -0
  63. package/skills/vulnerabilities/http_request_smuggling.md +255 -0
  64. package/skills/vulnerabilities/idor.md +217 -0
  65. package/skills/vulnerabilities/information_disclosure.md +187 -0
  66. package/skills/vulnerabilities/insecure_deserialization.md +210 -0
  67. package/skills/vulnerabilities/insecure_file_uploads.md +194 -0
  68. package/skills/vulnerabilities/llm_prompt_injection.md +187 -0
  69. package/skills/vulnerabilities/mass_assignment.md +153 -0
  70. package/skills/vulnerabilities/nosql_injection.md +288 -0
  71. package/skills/vulnerabilities/open_redirect.md +165 -0
  72. package/skills/vulnerabilities/path_traversal_lfi_rfi.md +218 -0
  73. package/skills/vulnerabilities/prototype_pollution.md +142 -0
  74. package/skills/vulnerabilities/race_conditions.md +181 -0
  75. package/skills/vulnerabilities/rce.md +250 -0
  76. package/skills/vulnerabilities/semantic_confusion.md +189 -0
  77. package/skills/vulnerabilities/sql_injection.md +190 -0
  78. package/skills/vulnerabilities/ssrf.md +186 -0
  79. package/skills/vulnerabilities/ssti.md +270 -0
  80. package/skills/vulnerabilities/subdomain_takeover.md +167 -0
  81. package/skills/vulnerabilities/weak_password_detection.md +200 -0
  82. package/skills/vulnerabilities/xss.md +206 -0
  83. package/skills/vulnerabilities/xxe.md +223 -0
  84. package/src/index.ts +89 -0
@@ -0,0 +1,262 @@
1
+ ---
2
+ name: azure
3
+ description: Microsoft Azure and Entra security testing covering RBAC, Privileged Identity Management, Conditional Access, service principals, managed identities, Storage SAS, Key Vault, workload escalation, and cross-plane privilege paths
4
+ ---
5
+
6
+ # Azure and Microsoft Entra Security
7
+
8
+ Azure security spans two related but distinct control planes:
9
+
10
+ - **Microsoft Entra ID** (formerly Azure AD): tenant identity, users, groups, applications, service principals, directory roles, authentication, and Conditional Access.
11
+ - **Azure Resource Manager (ARM):** management groups, subscriptions, resource groups, resources, Azure RBAC, managed identities, and service-specific control/data planes.
12
+
13
+ Do not equate an Entra directory role with an Azure resource role. A principal can be weak in one plane and privileged in the other, and many escalation paths cross between them.
14
+
15
+ ## Scope and Identity Baseline
16
+
17
+ Record before testing:
18
+
19
+ - tenant ID, cloud environment, management groups, subscriptions, and directories in scope
20
+ - current user/service principal/managed identity object ID and home tenant
21
+ - direct and group-derived Entra directory roles
22
+ - Azure role assignments, scope, inheritance, conditions, and deny assignments
23
+ - authentication method, token audience, Conditional Access result, and PIM activation state
24
+ - test versus production subscriptions and any cross-tenant/B2B context
25
+
26
+ Start with native CLI context:
27
+
28
+ ```bash
29
+ az cloud show --output json
30
+ az account show --output json
31
+ az account list --all --refresh --output json
32
+ az account management-group list --no-register --output json
33
+ az ad signed-in-user show --output json
34
+ az role assignment list --subscription <subscription-id> --all --include-inherited --output json
35
+ az role assignment list --subscription <subscription-id> --assignee <user-object-id> --all --include-inherited --include-groups --output json
36
+ az role definition list --subscription <subscription-id> --output json
37
+ ```
38
+
39
+ For a service principal, `az ad signed-in-user show` does not apply; resolve the current client/service-principal object explicitly from the reviewed credential context. `--all` remains scoped to the selected subscription, and `--include-groups` depends on Microsoft Graph and can still miss nested or workload-derived paths. Repeat the inventory per tenant, management-group root, and in-scope subscription. Never infer identity only from a display name.
40
+
41
+ ## Azure RBAC
42
+
43
+ An Azure role assignment joins three elements: a security principal, a role definition, and a scope. Scope inheritance runs from management group to subscription to resource group to resource.
44
+
45
+ ### Review
46
+
47
+ - Enumerate direct, group-derived, inherited, eligible, and active assignments separately.
48
+ - Expand custom role `Actions`, `NotActions`, `DataActions`, and `NotDataActions`; the role name is not a reliable summary.
49
+ - Inspect assignment conditions/ABAC, deny assignments, management-group inheritance, and cross-tenant principals.
50
+ - Identify broad scopes for Owner, Contributor, User Access Administrator, Role Based Access Control Administrator, and custom equivalents.
51
+ - Check who can write role assignments, role definitions, policies, locks, deployments, managed identities, credentials, or compute configuration.
52
+ - Distinguish ARM control-plane permission from service data-plane permission. Contributor over a resource may still gain its data through code/configuration or a managed identity even without direct data actions.
53
+
54
+ ### High-Value Cross-Plane Paths
55
+
56
+ - Active Microsoft Entra Global Administrator can elevate into Azure by using `Microsoft.Authorization/elevateAccess/action` to grant User Access Administrator at the root `/` scope. That root assignment can persist after PIM deactivation until it is explicitly removed.
57
+ - `Microsoft.Authorization/roleAssignments/write` or equivalent role-management authority → grant a stronger role at an allowed scope.
58
+ - Ability to modify a VM, VM extension, Function App, App Service, Container App, Automation runbook, deployment script, Logic App, or similar workload → execute in that workload's identity and network context.
59
+ - Ability to attach or replace a user-assigned managed identity, together with the host resource write path and `Microsoft.ManagedIdentity/userAssignedIdentities/assign/action` → inherit its downstream Azure permissions.
60
+ - Ability to modify federated identity credentials, app credentials, certificates, or owners → impersonate a service principal/application.
61
+ - Ability to read deployment outputs, app settings, runbook variables, storage, snapshots, disks, backups, or diagnostic settings → recover credentials or sensitive data.
62
+ - Broad policy/deployment rights at a parent scope → affect many child resources even when individual resource assignments appear narrow.
63
+
64
+ Model each path using exact principal, action, resource, scope, condition, and resulting effective permission. Check Azure Policy and deny assignments before declaring a theoretical path exploitable.
65
+
66
+ ## Privileged Identity Management (PIM)
67
+
68
+ [Microsoft Entra Privileged Identity Management](https://learn.microsoft.com/en-us/entra/id-governance/privileged-identity-management/pim-configure) provides time-based and approval-based activation for privileged access. It can govern Microsoft Entra roles, Azure resource roles, and PIM for Groups.
69
+
70
+ PIM terminology:
71
+
72
+ - **eligible:** the principal must activate before using the role
73
+ - **active:** the principal can use the role without activation
74
+ - **permanent/time-bound:** duration of eligibility or assignment
75
+ - **activated:** a currently active, time-limited instance created from eligibility
76
+
77
+ ### What to Test
78
+
79
+ - Permanent active assignments where eligible/JIT access is expected.
80
+ - Permanent eligibility without access reviews, expiration, or a business need.
81
+ - Roles that activate without MFA, approval, justification, notification, or a short duration.
82
+ - Approvers who can approve themselves indirectly, lack separation of duties, or no longer own the system.
83
+ - Group-based eligibility where group ownership/membership can be changed by a lower-privileged principal.
84
+ - PIM for Groups on role-bearing groups where a lower-privileged principal can alter ownership, membership, or activation controls.
85
+ - PIM settings applied to one privileged role but omitted from a custom/equivalent role.
86
+ - Directory-role PIM configured while equivalent Azure resource roles remain permanently active, or vice versa.
87
+ - Standing service-principal/workload access. Eligible Azure RBAC via PIM is a user-centric control; service principals and managed identities remain standing or time-bounded active assignments, not user-style eligible activations.
88
+ - Activation sessions that remain useful through cached tokens, active sessions, delegated jobs, or downstream credentials after the intended window.
89
+ - Audit/alert coverage for assignment, activation, approval, renewal, extension, and role-setting changes.
90
+
91
+ With sufficient Microsoft Graph read permissions, compare current schedule instances:
92
+
93
+ ```bash
94
+ az rest --method GET \
95
+ --url 'https://graph.microsoft.com/v1.0/roleManagement/directory/roleEligibilityScheduleInstances?$expand=principal,roleDefinition'
96
+
97
+ az rest --method GET \
98
+ --url 'https://graph.microsoft.com/v1.0/roleManagement/directory/roleAssignmentScheduleInstances?$expand=principal,roleDefinition'
99
+ ```
100
+
101
+ Those endpoints cover Microsoft Entra role schedules. Follow `@odata.nextLink`, and record the exact Graph permissions or delegated role used because weak tokens silently under-enumerate. Azure resource-role PIM is exposed through ARM's `Microsoft.Authorization` role eligibility/assignment schedule resources; keep the two inventories separate:
102
+
103
+ ```bash
104
+ az rest --method GET \
105
+ --url "https://management.azure.com/subscriptions/<subscription-id>/providers/Microsoft.Authorization/roleEligibilityScheduleInstances?api-version=2020-10-01&\$filter=atScope()"
106
+
107
+ az rest --method GET \
108
+ --url "https://management.azure.com/subscriptions/<subscription-id>/providers/Microsoft.Authorization/roleAssignmentScheduleInstances?api-version=2020-10-01&\$filter=atScope()"
109
+ ```
110
+
111
+ Follow `nextLink` there as well. For Entra directory-role inventory, reviewed readers commonly need `RoleEligibilitySchedule.Read.Directory` and `RoleAssignmentSchedule.Read.Directory` or an equivalent delegated role/application permission set.
112
+
113
+ ## Conditional Access and Authentication
114
+
115
+ [Conditional Access](https://learn.microsoft.com/en-us/entra/identity/conditional-access/overview) is Entra's identity-driven policy engine and is evaluated after first-factor authentication.
116
+
117
+ Review:
118
+
119
+ - policies in on/off/report-only state and coverage of users, groups, roles, applications, authentication contexts, and workload identities
120
+ - exclusions for break-glass accounts, admins, service accounts, guest users, locations, devices, or applications
121
+ - admin and management surfaces not covered by phishing-resistant MFA or appropriate authentication strength
122
+ - legacy authentication and non-interactive flows that do not receive the intended policy
123
+ - device compliance/join trust, named locations, sign-in/user risk, session lifetime, continuous access evaluation, and token protection where used
124
+ - policy gaps caused by nested groups, guest/home tenant behavior, service principals, managed identities, or application-specific grant paths
125
+ - whether emergency access exclusions are narrowly scoped, monitored, credential-protected, and exercised
126
+
127
+ For workload identities, Conditional Access applies only in limited cases: directly targeted tenant-owned single-tenant service principals can be controlled, but managed identities, Microsoft-owned service principals, most third-party SaaS service principals, and multitenant app registrations do not inherit human MFA semantics. Target the enterprise application service-principal object, not just the app registration, and verify the control at token issuance.
128
+
129
+ Use sign-in logs and the Conditional Access result to distinguish policy non-application from policy failure. Report-only evaluation is evidence of intended future control, not enforcement.
130
+
131
+ ## Applications, Service Principals, and Workload Identity
132
+
133
+ An app registration is the tenant-level application definition; a service principal is the local security principal representing an application instance in a tenant.
134
+
135
+ Inventory:
136
+
137
+ - owners of application and service-principal objects, separately
138
+ - delegated versus application permissions and admin consent
139
+ - client secrets/certificates, expiry, unused/stale credentials, and credential-add rights
140
+ - federated identity credentials: issuer, subject, audience, repository/branch/environment claims
141
+ - multitenant applications, publisher verification, consent grants, and cross-tenant access settings
142
+ - service-principal role assignments in both Entra and Azure
143
+ - automation/CI connections and whether test identities can reach production
144
+
145
+ Keep application-object authority separate from service-principal authority. Application ownership and `Application.ReadWrite.*` can add owners, client secrets, certificates, or federated credentials on the app object; service-principal ownership and `ServicePrincipal.ReadWrite.*` govern the enterprise application instance. Admin consent is a separate control plane from credential management. Also trace group ownership/membership where a role-bearing group grants app, vault, Azure RBAC, or Entra role access. A secret's metadata proves age/expiry but not that its value is retrievable.
146
+
147
+ ### Managed Identities
148
+
149
+ Managed identities remove stored credentials but still carry authority:
150
+
151
+ - **system-assigned:** lifecycle is tied to one Azure resource
152
+ - **user-assigned:** independent resource assignable to multiple workloads
153
+
154
+ Enumerate identity attachments and downstream role assignments. Check who can attach/detach the identity, execute or deploy code in the host workload, access its metadata/token endpoint, or reuse a user-assigned identity across environments. Treat workload control as potential identity control.
155
+
156
+ ## Storage and SAS
157
+
158
+ A Shared Access Signature (SAS) delegates access to Azure Storage through a signed URI. Review:
159
+
160
+ - SAS type: user delegation, service, or account SAS
161
+ - services/resource types, permissions, start/expiry, protocol, IP restriction, and stored access policy
162
+ - long-lived tokens in source, CI logs, tickets, browser history, application settings, or public URLs
163
+ - account-key use, `listKeys` authority, and key-rotation feasibility
164
+ - public container/blob access, anonymous listing, network rules, private endpoints, and trusted-service exceptions
165
+ - storage RBAC and whether principals can generate user-delegation keys or list account keys
166
+
167
+ Microsoft recommends a user delegation SAS where supported because it is secured with Entra credentials rather than the account key. User delegation keys and SAS values are time-limited and user-scoped; service/account SAS values derive from account keys, and only service SAS can bind to stored access policies. User delegation SAS is limited to Blob/Data Lake and has a maximum seven-day validity per delegation key. A SAS is a bearer credential; possession can be sufficient even when the holder has no visible Azure role assignment.
168
+
169
+ Validate each token against its signed permission/resource/time restrictions. Do not treat a redacted or expired SAS found in code as current unauthorized access.
170
+
171
+ ## Key Vault, Secrets, and Certificates
172
+
173
+ - Determine whether the vault uses Azure RBAC or legacy access policies. The active model is controlled by `enableRbacAuthorization`; RBAC mode invalidates access-policy evaluation for data-plane access.
174
+ - Enumerate who can read secrets, keys, and certificates; who can change access; and who controls workloads with vault-reading identities.
175
+ - Review public network access, firewall/private endpoints, soft delete, purge protection, logging, secret expiry, and rotation.
176
+ - Distinguish key operations (sign/decrypt/wrap) from key export and secret-value read.
177
+ - Look for vault references copied into app settings without corresponding identity isolation.
178
+ - Test backup/restore and cross-subscription permissions where in scope.
179
+
180
+ Legacy access-policy write authority on the vault resource can still become self-granting in access-policy mode. In RBAC mode, the equivalent finding depends on `DataActions` or role-assignment control, not on legacy access-policy mutation.
181
+
182
+ ## Credential-Equivalent Actions
183
+
184
+ Treat the following as credential-equivalent or near-equivalent authority when the downstream scope matches:
185
+
186
+ | Surface | Action or state | Why it matters |
187
+ |---|---|---|
188
+ | Azure RBAC | `Microsoft.Authorization/roleAssignments/write` | grants new authority directly |
189
+ | Root scope | `Microsoft.Authorization/elevateAccess/action` | bridges Entra Global Administrator into Azure root access |
190
+ | Managed identity | host config write plus `.../userAssignedIdentities/assign/action` | attaches a stronger identity to attacker-controlled code |
191
+ | App object | add secret/cert/federated credential or owner | permits application impersonation |
192
+ | Service principal | add credential/owner or modify federation | permits enterprise-app impersonation |
193
+ | Storage | `listKeys` or account-key disclosure | enables service/account SAS and broad account access |
194
+ | Storage | `generateUserDelegationKey` with matching data rights | enables user delegation SAS issuance |
195
+ | Key Vault | secret-value read, key sign/decrypt/wrap, or self-grant path | grants equivalent access even without export |
196
+
197
+ ## Compute, Network, and Data Services
198
+
199
+ - VM extensions, Run Command, serial console, disks/snapshots, images, custom script, and boot diagnostics
200
+ - App Service/Functions deployment slots, publishing credentials, SCM/Kudu, app settings, storage mounts, and managed identities
201
+ - AKS control plane/RBAC, workload identity federation, kubeconfig retrieval, node/resource-group rights, and private API reachability
202
+ - Container Apps/ACI environment variables, registries, identities, revisions, and exec surfaces
203
+ - Automation accounts/runbooks, Logic Apps/connectors, Data Factory linked services, deployment scripts, and DevOps/service connections
204
+ - NSGs, route tables, public IPs, load balancers, private endpoints, DNS, peering, Bastion, firewalls, and JIT VM access
205
+ - SQL, Cosmos DB, Storage, Service Bus, Event Hubs, and other service-specific data-plane authorization
206
+
207
+ Map whether a principal that lacks direct data access can reconfigure networking, identity, code, diagnostics, export, backup, or deployment to gain an equivalent capability.
208
+
209
+ ## Testing Methodology
210
+
211
+ 1. **Establish context** — tenant, subscription, cloud, principal, token audience, and active PIM state.
212
+ 2. **Inventory both role planes** — Entra directory roles and Azure resource roles with groups, scope, inheritance, conditions, eligible/active state, and custom definitions.
213
+ 3. **Map identity objects** — applications, service principals, managed identities, owners, credentials, federation, and consent.
214
+ 4. **Review policy gates** — Conditional Access, authentication methods, PIM settings, Azure Policy, deny assignments, and network restrictions.
215
+ 5. **Enumerate workloads/data** — identify where control-plane modification yields code execution, identity use, secrets, backups, or data-plane access.
216
+ 6. **Build effective-access paths** — principal → permission → resource change/identity → downstream privilege or data.
217
+ 7. **Cross-check logs** — Entra sign-in/audit, PIM, Azure Activity, resource logs, and Defender/Sentinel alerts where available.
218
+ 8. **Re-evaluate boundaries** — guest/home tenant, management-group inheritance, test/production, group ownership, and workload identities.
219
+
220
+ ## Validation
221
+
222
+ For each finding, include:
223
+
224
+ 1. tenant/subscription and exact principal/object IDs
225
+ 2. assignment source, role definition, scope, inheritance, condition, and PIM state
226
+ 3. relevant Conditional Access/authentication result
227
+ 4. exact Azure/Graph action and target resource
228
+ 5. effective permission or cross-plane path demonstrated
229
+ 6. policy, deny, network, licensing, or configuration prerequisites
230
+ 7. audit/sign-in/activity evidence and remediation at the correct control plane
231
+
232
+ ## Common False Positives
233
+
234
+ - Role name appears privileged but custom `Actions`/`DataActions`, conditions, scope, or deny assignments block the claimed action.
235
+ - Contributor is reported as able to assign roles without `roleAssignments/write` or an alternate workload/identity path.
236
+ - An eligible PIM assignment is described as standing active access.
237
+ - A Conditional Access policy exists but is report-only, excluded, or does not apply to the tested principal/application.
238
+ - An app registration is confused with its service principal in another tenant.
239
+ - A managed identity is present but the tester cannot control its host or obtain a token in the relevant context.
240
+ - An expired/revoked SAS or credential metadata is reported as usable access.
241
+ - ARM access is assumed to grant service data-plane access automatically.
242
+
243
+ ## Tooling
244
+
245
+ ### Azure CLI and Microsoft Graph
246
+
247
+ Use the official Azure CLI for resource context and `az rest` for reviewed ARM/Graph queries not exposed cleanly by a command group. Record CLI/API versions and requested permissions. Broad directory inventory often requires Microsoft Graph application permissions and admin consent; absence of results under a weak token is not proof that objects do not exist.
248
+
249
+ ### Prowler (Conditional)
250
+
251
+ [Prowler](https://github.com/prowler-cloud/prowler) provides maintained Azure configuration/compliance checks. Install a reviewed pinned release in an isolated environment:
252
+
253
+ ```bash
254
+ python -m pip install 'prowler==<reviewed-version>'
255
+ prowler azure --az-cli-auth --subscription-ids <subscription-id>
256
+ ```
257
+
258
+ Other documented modes include service-principal, browser, and managed-identity authentication. Use a dedicated read-only audit principal with only the documented tenant/subscription permissions. Scope subscription IDs explicitly, protect reports as sensitive asset/identity inventories, account for API volume/throttling, and do not enable cloud upload for assessment data unless approved. Prowler findings are configuration leads; trace effective principal/action/resource paths before treating them as exploitable.
259
+
260
+ ## Summary
261
+
262
+ Azure security is an identity-and-scope graph across Entra and ARM. Test directory roles, Azure RBAC, PIM, Conditional Access, service principals, managed identities, delegated storage access, workload control, and service data planes as one system while preserving the distinction between each control plane.
@@ -0,0 +1,194 @@
1
+ ---
2
+ name: gcp
3
+ description: GCP cloud security testing covering IAM misconfigurations, public storage buckets, metadata abuse, and service account privilege escalation
4
+ ---
5
+
6
+ # Google Cloud Platform (GCP)
7
+
8
+ GCP misconfigurations expose project data, service account keys, and lateral movement paths across Compute, Cloud Storage, Cloud Functions, and GKE. This skill covers direct GCP API testing and post-compromise enumeration from VMs/containers. For SSRF-mediated metadata access, combine with the `ssrf` skill.
9
+
10
+ ## Attack Surface
11
+
12
+ **Identity**
13
+ - IAM policies: project/folder/org level bindings
14
+ - Service accounts, keys (JSON), Workload Identity, impersonation
15
+ - OAuth scopes on compute instances and Cloud Functions
16
+
17
+ **Storage & Data**
18
+ - Cloud Storage (GCS) buckets and objects
19
+ - BigQuery datasets, Cloud SQL instances, Firestore (see `firebase` skill)
20
+ - Secret Manager, Cloud KMS keys
21
+
22
+ **Compute**
23
+ - Compute Engine VMs, Cloud Run, Cloud Functions, GKE clusters
24
+ - Metadata server at `http://metadata.google.internal/computeMetadata/v1/`
25
+ - Startup scripts, instance templates, custom images
26
+
27
+ **Management**
28
+ - Cloud Console, gcloud CLI, Deployment Manager, Terraform state buckets
29
+ - Cloud Logging, Error Reporting, Cloud Build triggers
30
+
31
+ ## Reconnaissance
32
+
33
+ **Credential Discovery**
34
+ - Service account JSON keys in repos, CI/CD, `.env`, backup buckets
35
+ - `GOOGLE_APPLICATION_CREDENTIALS` environment variable
36
+ - Default Compute Engine service account on VMs (often overprivileged)
37
+ - OAuth tokens in browser/local `gcloud` config (`~/.config/gcloud/`)
38
+
39
+ **Unauthenticated Enumeration**
40
+
41
+ Avoid `gsutil` for anonymous checks — it can use ambient `gcloud` or application-default credentials and produce false public-bucket findings. Unset `GOOGLE_APPLICATION_CREDENTIALS` and use unauthenticated HTTP instead.
42
+
43
+ ```
44
+ # GCS bucket existence (403 = exists but private, 404 = not found/wrong region)
45
+ curl -I https://storage.googleapis.com/target-bucket/
46
+
47
+ # Anonymous listing (no Authorization header; confirms allUsers/allAuthenticatedUsers List)
48
+ curl https://storage.googleapis.com/target-bucket/
49
+
50
+ # Alternate URL forms
51
+ curl -I https://target-bucket.storage.googleapis.com/
52
+ ```
53
+
54
+ **Authenticated Enumeration**
55
+ ```
56
+ gcloud auth list
57
+ gcloud config get-value project
58
+ gcloud projects get-iam-policy PROJECT_ID
59
+ gcloud iam service-accounts list
60
+ gcloud storage ls
61
+ gcloud compute instances list
62
+ gcloud container clusters list
63
+ ```
64
+
65
+ ## Key Vulnerabilities
66
+
67
+ ### Cloud Storage Misconfigurations
68
+
69
+ - Public buckets: `allUsers` or `allAuthenticatedUsers` with `roles/storage.objectViewer` or `objectAdmin`
70
+ - Listable buckets revealing object keys: backups, `.env`, `terraform.tfstate`, SA keys
71
+ - Uniform bucket-level access disabled with legacy ACL public-read
72
+ - Signed URL with excessive TTL or overly broad object prefix
73
+
74
+ **Test:**
75
+ ```
76
+ gsutil iam get gs://BUCKET # requires credentials
77
+ curl https://storage.googleapis.com/BUCKET/ # anonymous listing check
78
+ curl -I https://storage.googleapis.com/BUCKET/sensitive.sql
79
+ ```
80
+
81
+ ### IAM Privilege Escalation
82
+
83
+ Common escalation paths (verify with `gcloud iam` / policy simulator):
84
+
85
+ | Permission | Escalation |
86
+ |------------|------------|
87
+ | `iam.serviceAccounts.actAs` + `compute.instances.create` | VM with privileged SA |
88
+ | `iam.serviceAccountKeys.create` | Export key for higher-priv SA |
89
+ | `iam.serviceAccounts.setIamPolicy` | Grant yourself roles on SA |
90
+ | `cloudfunctions.functions.create` + `actAs` | Deploy function as privileged SA |
91
+ | `run.services.create` (Cloud Run) + `actAs` | Deploy service with admin SA |
92
+ | `storage.buckets.update` + `setIamPolicy` | Open bucket to public or self |
93
+
94
+ **Test:**
95
+ ```
96
+ gcloud projects get-iam-policy PROJECT --flatten="bindings[].members" --filter="bindings.members:user:YOU"
97
+ gcloud iam roles list --project=PROJECT
98
+ ```
99
+
100
+ ### Metadata Server Abuse
101
+
102
+ From any code execution on a GCP VM, Cloud Run (if metadata accessible), or compromised pod:
103
+
104
+ ```
105
+ curl -H "Metadata-Flavor: Google" \
106
+ http://metadata.google.internal/computeMetadata/v1/instance/service-accounts/default/token
107
+
108
+ curl -H "Metadata-Flavor: Google" \
109
+ http://metadata.google.internal/computeMetadata/v1/instance/service-accounts/default/email
110
+ ```
111
+
112
+ - Default compute SA may have `editor` role on project (legacy projects)
113
+ - Requested OAuth scopes may allow `cloud-platform` full access
114
+ - Workload Identity misconfiguration in GKE → cross-namespace SA token theft
115
+
116
+ ### GKE Misconfigurations
117
+
118
+ - Dashboard/UI exposed, anonymous RBAC (see `kubernetes` skill for K8s layer)
119
+ - Workload Identity not enforced; pods use node SA with broad GCP permissions
120
+ - `kubectl` proxy or `kubelet` read-only port exposed
121
+ - Secrets in ConfigMaps; GCR/Artifact Registry images pulling without auth
122
+
123
+ ### Cloud Functions / Cloud Run
124
+
125
+ - HTTP-triggered functions without authentication (`--allow-unauthenticated`)
126
+ - Environment variables containing API keys (`gcloud functions describe`)
127
+ - Overprivileged runtime service account (`roles/editor`)
128
+ - Event triggers accepting attacker-controlled Pub/Sub messages
129
+
130
+ ### BigQuery & Cloud SQL
131
+
132
+ - Public datasets (`allUsers` on dataset IAM)
133
+ - Cloud SQL public IP with weak/no password
134
+ - Exported snapshots in public GCS buckets
135
+
136
+ ### Secret Manager & KMS
137
+
138
+ - `secretmanager.versions.access` granted to unintended principals
139
+ - Secrets replicated to logs via misconfigured Cloud Functions env vars
140
+ - KMS cryptoKey IAM with `allAuthenticatedUsers`
141
+
142
+ ## Advanced Techniques
143
+
144
+ **Terraform State in GCS**
145
+ - `terraform.tfstate` in listable bucket → all resource addresses, sometimes secrets in plain text
146
+
147
+ **Service Account Impersonation Chain**
148
+ - `roles/iam.serviceAccountTokenCreator` on target SA → short-lived access tokens
149
+
150
+ **Org/Fold Policy Gaps**
151
+ - Project-level deny policies not applied; child project inherits permissive folder IAM
152
+
153
+ ## Testing Methodology
154
+
155
+ 1. **Discover credentials** — Keys in code, metadata, SSRF, public buckets
156
+ 2. **Identify principal** — `gcloud auth list`, effective project IAM
157
+ 3. **Enumerate storage** — Public/listable buckets, sensitive object names
158
+ 4. **Escalation paths** — Map `actAs`, key creation, function deploy permissions
159
+ 5. **Metadata** — From any shell in GCP workload, fetch SA token and scopes
160
+ 6. **GKE layer** — Pivot from GCP IAM to cluster (combine with `kubernetes` skill)
161
+
162
+ ## Validation
163
+
164
+ 1. Demonstrate unauthorized GCS object read/list with bucket URL and object key
165
+ 2. Show IAM escalation path with exact role/member binding and resulting access
166
+ 3. Prove metadata token theft from compute context with redacted token scope
167
+ 4. Document project ID, resource name, and IAM binding root cause
168
+ 5. Confirm fix blocks the specific principal/permission/resource combination
169
+
170
+ ## False Positives
171
+
172
+ - Intentionally public static asset bucket with no sensitive objects
173
+ - Metadata server unreachable from tested context (no RCE/SSRF)
174
+ - SA token from metadata has only `devstorage.read_only` on single bucket (note scope, not full breach)
175
+ - `403` on bucket HEAD indicating existence but not readable content
176
+
177
+ ## Impact
178
+
179
+ - Mass data exfiltration from GCS/BigQuery/Cloud SQL backups
180
+ - Project or org compromise via SA key theft or IAM escalation
181
+ - Lateral movement from GKE pod to cloud control plane
182
+ - Regulatory exposure (PII in public buckets or exports)
183
+
184
+ ## Pro Tips
185
+
186
+ 1. Always check both `gsutil iam get` and anonymous `curl` — IAM and ACL layers differ
187
+ 2. Search public buckets for `*.json` service account keys and `terraform.tfstate`
188
+ 3. Default compute SA email: `PROJECT_NUMBER-compute@developer.gserviceaccount.com`
189
+ 4. Combine with `kubernetes` skill when target runs on GKE
190
+ 5. Firebase-hosted apps often use GCP project underneath — pivot from web to GCP project ID in configs
191
+
192
+ ## Summary
193
+
194
+ GCP security requires least-privilege IAM, no public data paths, tight metadata/scopes on compute, and protected service account keys. Enumerate from any credential or shell — even read-only GCS access often reveals escalation artifacts.