-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsecrets-without-environment.yaml
More file actions
78 lines (76 loc) · 2.5 KB
/
secrets-without-environment.yaml
File metadata and controls
78 lines (76 loc) · 2.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# NOTE: this rule assumes ${{ secrets.SECRET }} is NEVER passed inside 'run' blocks
# Meaning the rule ./shell-script-injection.yaml is being used & respected.
rules:
- id: secrets-without-environment-in-env-block
message: >
This GitHub Actions workflow uses secrets but does not configure a job-level
environment. Secrets should be scoped to a GitHub Environment to enforce
protection rules (reviewers, deployment gates, etc) and to reduce blast radius.
severity: WARNING
languages: [yaml]
metadata:
category: security
technology: github-actions
cwe: "CWE-522: Insufficiently Protected Credentials"
likelihood: MEDIUM
confidence: HIGH
impact: HIGH
patterns:
- pattern-inside: |
steps: [...]
- pattern-inside: |
env: ...
...
- pattern: |
env: $X
- metavariable-pattern:
language: generic
metavariable: $X
patterns:
- pattern: "${{ secrets.$SECRET }}"
# GITHUB_TOKEN can be OK without environment as it's a dynamic secret
- pattern-not: "${{ secrets.GITHUB_TOKEN }}"
# Exclude jobs that properly define an environment
- pattern-not-inside: |
jobs:
...
$JOB:
...
environment:
...
- focus-metavariable: $SECRET
- id: secrets-without-environment-in-with-block
message: >
This GitHub Actions workflow uses secrets but does not configure a job-level
environment. Secrets should be scoped to a GitHub Environment to enforce
protection rules (reviewers, deployment gates, etc) and to reduce blast radius.
severity: WARNING
languages: [yaml]
metadata:
category: security
technology: github-actions
cwe: "CWE-522: Insufficiently Protected Credentials"
confidence: medium
patterns:
- pattern-inside: |
steps: [...]
- pattern-inside: |
with: ...
...
- pattern: |
with: $X
- metavariable-pattern:
language: generic
metavariable: $X
patterns:
- pattern: "${{ secrets.$SECRET }}"
- pattern-not: "${{ secrets.GITHUB_TOKEN }}"
# GITHUB_TOKEN can be OK without environment as it's a dynamic secret
- pattern-not-inside: |
jobs:
...
$JOB:
...
environment:
...
- focus-metavariable: $SECRET