Skip to content

Commit 9791f6e

Browse files
committed
Add scanner
1 parent 2d4fc66 commit 9791f6e

File tree

11 files changed

+2362
-1
lines changed

11 files changed

+2362
-1
lines changed

.github/workflows/sample.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Sample workflow to run the action
2+
name: Sample workflow
3+
4+
permissions:
5+
contents: read
6+
7+
on:
8+
workflow_dispatch:
9+
inputs:
10+
owner:
11+
description: 'Org or user name'
12+
required: true
13+
type: string
14+
repo:
15+
description: 'Repository name'
16+
required: true
17+
type: string
18+
19+
jobs:
20+
scan:
21+
runs-on: ubuntu-latest
22+
steps:
23+
- uses: GitHubSecurityLab/pwn-request-scanner@main
24+
with:
25+
owner: ${{ inputs.owner }}
26+
repo: ${{ inputs.repo }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules

README.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,14 @@
1-
# PWN-request-scanner
1+
# pwn request scanner
2+
3+
Workflows triggered on `pull_request_target` event potentially have access to secrets, privileged GITHUB_TOKEN permissions and access to cache token. Because of that under certain conditions it may lead to [pwn request vulnerabilities](https://securitylab.github.com/resources/github-actions-preventing-pwn-requests/).
4+
5+
Most GitHub Actions workflows run from the default repository branch. However workflows triggered on `pull_request_target` event run from the target branch of the pull request. It means that a repository may have multiple versions of the same workflow in different branches and attackers may choose which version to run by creating a pull request to a specific branch. To reduce the number of triggerable `pull_request_target` workflows it is recommended to use [branch filters](https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax#onpull_requestpull_request_targetbranchesbranches-ignore).
6+
7+
The `pwn request scanner` is a simple tool that doesn't go into depths of analyzing if the workflow with `pull_request_target` trigger is vulnerable or not, but it scans all repository branches for `pull_request_target` workflows that do not follow the best practice of using branch filters.
8+
9+
## Usage
10+
11+
You can run the scanner as:
12+
13+
* GitHub Action in your repository. Just copy the [sample workflow](.github/workflows/sample.yml).
14+
* Locally running the [index.js](dist/index.js) script from the dist folder.

action.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: 'pwn request scanner'
2+
description: 'An action to search for the usage of pull_request_target trigger in non default branches'
3+
inputs:
4+
token:
5+
description: 'GitHub token to call REST API'
6+
required: false
7+
default: ${{ github.token }}
8+
owner:
9+
description: 'Org or user name'
10+
required: true
11+
type: string
12+
repo:
13+
description: 'Repository name'
14+
required: true
15+
type: string
16+
17+
runs:
18+
using: 'node20'
19+
main: 'dist/index.js'

dist/index.js

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.LICENSE.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/*! formdata-polyfill. MIT License. Jimmy Wärting <https://jimmy.warting.se/opensource> */
2+
3+
/*! ws. MIT License. Einar Otto Stangvik <[email protected]> */

dist/index.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)