Skip to content

Commit 4015d0e

Browse files
Update puzzle and ARC links (step-security#153)
1 parent 1adb8fc commit 4015d0e

5 files changed

Lines changed: 57 additions & 17 deletions

File tree

README.md

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,17 @@ GitHub Actions Goat incorporates best practices from the [CISA/ NSA guidance on
1515

1616
## Puzzle Time
1717

18-
Lets kick things off with a challenge designed to get your analytical gears turning. Take a close look at the [publish.yml](.github/workflows/publish.yml) GitHub Actions workflow. This simple workflow builds and pushes a Docker image, and uses the [Harden-Runner GitHub Action](https://github.com/step-security/harden-runner), which provides Security Observability and Runtime Enforcement for GitHub Actions workflows. Now, we present you with the puzzle. Check out these [network events monitored during a workflow run](https://app.stepsecurity.io/github/step-security/github-actions-goat/actions/runs/5517140370) of this workflow. Notice anything odd? **Why is there an outbound call to `stepsecurity.io` during the workflow run?** Is this expected, or something more nefarious?
18+
Lets kick things off with a challenge designed to get your analytical gears turning:
1919

20-
<img src="./images/Puzzle2.png" alt="Enable Actions" >
20+
- Take a look at the [publish.yml](.github/workflows/publish.yml) GitHub Actions workflow.
21+
- This workflow uses the [Harden-Runner GitHub Action](https://github.com/step-security/harden-runner), which provides Security Observability and Runtime Enforcement for GitHub Actions workflows.
22+
- Now, we present you with the puzzle. Check out these [network events monitored during a workflow run](https://app.stepsecurity.io/github/step-security/github-actions-goat/actions/runs/6285441645) of this workflow. Notice anything odd?
23+
24+
**Why is there an outbound call to `pastebin.com` during the workflow run?** Is this expected, or something more nefarious?
25+
26+
> For the answer of the puzzle, check out the first hands-on tutorial on [Filtering Egress Network Traffic](./docs/Solutions/RestrictOutboundTraffic.md) from a GitHub Actions workflow run.
27+
28+
<img src="./images/Puzzle3.png" alt="Puzzle showing outbound call to pastebin.com" >
2129

2230
## Threat Scenarios
2331

@@ -53,7 +61,7 @@ If a workflow is compromised it can potentially be used to push changes to the r
5361

5462
> **Real-world incidents**: For examples of real-world incidents in which `GITHUB_TOKEN` was compromised, refer to [Compromise of the GITHUB_TOKEN](./docs/Vulnerabilities/OverprivilegedGITHUB_TOKEN.md)
5563
56-
## Getting Started
64+
## Hands-On Tutorials
5765

5866
To get started:
5967

@@ -63,15 +71,15 @@ To get started:
6371

6472
<img src="./images/EnableActions.png" alt="Enable Actions" width="800">
6573

66-
3. Click on a link in the `Countermeasure` column below and follow the tutorials.
74+
3. Click on a link in the `Countermeasure` column below and follow the hands-on tutorials.
6775

6876
## Vulnerabilities and Countermeasures
6977

7078
GitHub Actions Goat not only demonstrates vulnerabilities but also presents solutions and references to best practices for each issue. In each scenario, we demonstrate how a particular threat can be mitigated.
7179

72-
| No. | Vulnerability | Countermeasure | References |
80+
| No. | Vulnerability | Countermeasure (Hands-On Tutorial) | References |
7381
| --- | -------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
74-
| 1. | Lack of Network Traffic Filtering can lead to Exfiltration of source code and CI/CD Credentials | [GitHub Actions Runtime Security - Filter Network Traffic](docs/Solutions/RestrictOutboundTraffic.md) | ["Implement network segmentation and traffic filtering" in CISA/NSA guide](https://media.defense.gov/2023/Jun/28/2003249466/-1/-1/0/CSI_DEFENDING_CI_CD_ENVIRONMENTS.PDF) |
82+
| 1. | Lack of Network Traffic Filtering can lead to Exfiltration of source code and CI/CD Credentials | [GitHub Actions Runtime Security - Filter Egress Network Traffic](docs/Solutions/RestrictOutboundTraffic.md) | ["Implement network segmentation and traffic filtering" in CISA/NSA guide](https://media.defense.gov/2023/Jun/28/2003249466/-1/-1/0/CSI_DEFENDING_CI_CD_ENVIRONMENTS.PDF) |
7583
| 2. | Lack of CI/CD Runtime Security can lead to Tampering of Source Code or Artifacts during Build | [GitHub Actions Runtime Security - Detect File Tampering](docs/Solutions/MonitorSourceCode.md) | ["Implement endpoint detection and response (EDR) tools" in CISA/NSA guide](https://media.defense.gov/2023/Jun/28/2003249466/-1/-1/0/CSI_DEFENDING_CI_CD_ENVIRONMENTS.PDF) |
7684
| 3. | Lack of Detailed Audit Logs for CI/CD Activities | [Trace deployments to CI/CD pipeline and commit](docs/Solutions/Provenance.md) | ["Keep audit logs" section in CISA/NSA guide](https://media.defense.gov/2023/Jun/28/2003249466/-1/-1/0/CSI_DEFENDING_CI_CD_ENVIRONMENTS.PDF) |
7785
| 4. | Overprivileged GITHUB_TOKEN Permissions can lead to tampering of repository contents or container images | [Update workflows to use least privileged GITHUB_TOKEN permissions](docs/Solutions/FixGITHUB_TOKENPermissions.md) | ["Use credentials that are minimally scoped" in GitHub's Security Guide](https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions#using-secrets) |

docs/Solutions/MonitorSourceCode.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ For a demo of a workflow running on ARC with Harden Runner integrated, follow th
5454
Notice that `harden-runner` Action is not added to this workflow, and that this workflow runs on a `self-hosted` runner.
5555

5656
2. Check out an example run of this workflow here:
57-
https://github.com/step-security/github-actions-goat/actions/runs/5662626777/job/15342926660
57+
https://github.com/step-security/github-actions-goat/actions/runs/6285439163
5858

5959
3. Visit the workflow insights for this run here:
60-
https://app.stepsecurity.io/github/step-security/github-actions-goat/actions/runs/5662626777
60+
https://app.stepsecurity.io/github/step-security/github-actions-goat/actions/runs/6285439163
6161

6262
You can see that the file overwrite event is detected, without the need to add `harden-runner` to each job.

docs/Solutions/RestrictOutboundTraffic.md

Lines changed: 41 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,19 @@ As we will see next, one of these steps is making an unexpected outbound call, b
3535

3636
You can now see that the `npm install` step is making a call to `pastebin.com`, which is not expected.
3737

38+
### Answer to the puzzle
39+
40+
There is a [Puzzle in the README](../../README.md#puzzle-time) about a call to `pastebin.com`. To understand why this call is being made:
41+
42+
- Check out the `package.json` file of the [exfiltration-demo](../../src/exfiltration-demo/package.json) folder.
43+
- It has a dependency called `@step-security/malware-simulator`
44+
- This dependency simulates a malicious package. Its [package.json](../../src/malware-simulators/exfiltration-simulator/package.json) has a `pre-install` step that calls [compile.js](../../src/malware-simulators/exfiltration-simulator/compile.js)
45+
- The compile.js file makes an outbound call to `pastebin.com`
46+
- As a result, when `npm install` is run in the workflow, the `pre-install` step of the dependency is run, which makes the outbound call.
47+
3848
### Network Filtering with Harden-Runner
3949

40-
In the insights page, you will see a recommended policy to filter egress traffic to allowed destinations.
50+
Now lets see how to filter traffic to expected destinations and block everything else.
4151

4252
1. Go to the `Actions` tab and run the `Hosted: Network Filtering with Harden-Runner` workflow.
4353

@@ -71,28 +81,50 @@ For a demo of a workflow running on ARC with Harden Runner integrated, follow th
7181
Notice that `harden-runner` Action is not added to this workflow, and that this workflow runs on a `self-hosted` runner.
7282

7383
2. Check out an example run of this workflow here:
74-
https://github.com/step-security/github-actions-goat/actions/runs/6141448568
84+
https://github.com/step-security/github-actions-goat/actions/runs/6285442172
7585

7686
3. Visit the workflow insights for this run here:
77-
https://app.stepsecurity.io/github/step-security/github-actions-goat/actions/runs/6141448568
87+
https://app.stepsecurity.io/github/step-security/github-actions-goat/actions/runs/6285442172
7888
You can see the outbound traffic for each of the steps, without the need to add `harden-runner` to each job.
7989

8090
Even though you do not need to add Harden-Runner Action, the insights are exactly the same as with GitHub-Hosted runner.
8191

92+
### Secure-by-default ARC Cluster Level Network Policy
93+
94+
You can apply a secure-by-default ARC Cluster Level Network Policy that restricts outbound traffic for any job that is run on the ARC managed runners. This ensures that all workflows have a baseline restrictive policy applied.
95+
96+
To see this in action, follow these steps:
97+
98+
1. View this workflow file:
99+
https://github.com/step-security/github-actions-goat/blob/main/.github/workflows/arc-secure-by-default.yml
100+
101+
Notice that `harden-runner` Action is not added to this workflow. This workflow has two jobs. One runs on a `self-hosted` runner secured by ARC Harden-Runner and the other on a GitHub-Hosted runner. Both jobs make an outbound call to a direct IP address.
102+
103+
2. Check out an example run of this workflow here:
104+
https://github.com/step-security/github-actions-goat/actions/runs/6285441911
105+
106+
The call to the direct IP address succeeds for the GitHub-Hosted runner, but is blocked for the self-hosted runner.
107+
This is because ARC Harden-Runner does not allow calls to direct IP addresses in the secure-by-default policy.
108+
Typically workflows do not need to make calls to direct IP addresses, but compromised tools or dependencies sometimes make calls to direct IP addresses to avoid detection from DNS monitoring.
109+
110+
3. Visit the workflow insights for this run here:
111+
https://app.stepsecurity.io/github/step-security/github-actions-goat/actions/runs/6285441911
112+
113+
You will see that the call to the direct IP address has been blocked.
114+
82115
### Network Filtering with Harden Runner
83116

84-
To filter traffic in self-hosted ARC runner, you use the `harden-runner` GitHub Action in `block` mode.
117+
While there is a secure-by-default policy, to filter traffic to specific destinations in a job run in self-hosted ARC runner, you use the `harden-runner` GitHub Action in `block` mode.
85118

86119
1. View the workflow file:
87120
https://github.com/step-security/github-actions-goat/blob/main/.github/workflows/arc-codecov-simulation.yml
88121

89122
Notice that `harden-runner` Action is added and there is a list of allowed endpoints.
90123

91124
2. Check out an example run of this workflow here:
92-
https://github.com/step-security/github-actions-goat/actions/runs/5662626256/job/15342958122
125+
https://github.com/step-security/github-actions-goat/actions/runs/6285439406
93126

94-
Notice that the call to `pastebin.com` has been blocked.
95-
96-
3. Visit the workflow insights for this run here: https://app.stepsecurity.io/github/step-security/github-actions-goat/actions/runs/5662626256
127+
3. Visit the workflow insights for this run here:
128+
https://app.stepsecurity.io/github/step-security/github-actions-goat/actions/runs/6285439406
97129

98-
As you can observe, the outbound call that was not in the allowed list was successfully blocked.
130+
You will notice that the call to `pastebin.com` was blocked in this case.

images/Puzzle2.png

-141 KB
Binary file not shown.

images/Puzzle3.png

129 KB
Loading

0 commit comments

Comments
 (0)