-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
84 additions
and
0 deletions.
There are no files selected for viewing
59 changes: 59 additions & 0 deletions
59
.github/linters/semgrep/pull-request-target-code-checkout.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
rules: | ||
- id: pull-request-target-code-checkout | ||
languages: | ||
- yaml | ||
message: This GitHub Actions workflow file uses `pull_request_target` and checks | ||
out code from the incoming pull request. When using `pull_request_target`, | ||
the Action runs in the context of the target repository, which includes | ||
access to all repository secrets. Please ensure you have `permission-check` | ||
enabled for the jobs that check out code. Please see | ||
https://securitylab.github.com/research/github-actions-preventing-pwn-requests/ | ||
for additional mitigations. | ||
metadata: | ||
category: security | ||
owasp: | ||
- A01:2021 - Broken Access Control | ||
cwe: | ||
- "CWE-913: Improper Control of Dynamically-Managed Code Resources" | ||
references: | ||
- https://securitylab.github.com/research/github-actions-preventing-pwn-requests/ | ||
- https://github.com/justinsteven/advisories/blob/master/2021_github_actions_checkspelling_token_leak_via_advice_symlink.md | ||
technology: | ||
- github-actions | ||
subcategory: | ||
- audit | ||
likelihood: MEDIUM | ||
impact: LOW | ||
confidence: MEDIUM | ||
license: Commons Clause License Condition v1.0[LGPL-2.1-only] | ||
vulnerability_class: | ||
- Code Injection | ||
patterns: | ||
- pattern-either: | ||
- pattern-inside: | | ||
on: | ||
... | ||
pull_request_target: ... | ||
... | ||
... | ||
- pattern-inside: | | ||
on: [..., pull_request_target, ...] | ||
... | ||
- pattern-inside: | | ||
on: pull_request_target | ||
... | ||
- pattern-inside: | | ||
jobs: | ||
... | ||
$JOBNAME: | ||
... | ||
- pattern-not-inside: | | ||
needs: [permission-check] | ||
... | ||
- pattern: | | ||
... | ||
uses: "$ACTION" | ||
- metavariable-regex: | ||
metavariable: $ACTION | ||
regex: actions/checkout@.* | ||
severity: WARNING |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
name: Semgrep | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
paths: | ||
- '.github/**' | ||
|
||
jobs: | ||
semgrep: | ||
name: semgrep/ci | ||
runs-on: ubuntu-latest | ||
|
||
container: | ||
image: returntocorp/semgrep | ||
|
||
# Skip any PR created by dependabot to avoid permission issues: | ||
if: (github.actor != 'dependabot[bot]') | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- run: semgrep ci | ||
env: | ||
SEMGREP_RULES: >- | ||
./.github/linters/semgrep/pull-request-target-code-checkout.yaml |