Skip to content

Commit 73fbd23

Browse files
author
Alvaro Muñoz
committed
Improper access check queries and tests
1 parent 7c295e0 commit 73fbd23

File tree

5 files changed

+73
-0
lines changed

5 files changed

+73
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/**
2+
* @name Improper Access Control
3+
* @description The access control mechanism is not properly implemented, allowing untrusted code to be executed in a privileged context.
4+
* @kind problem
5+
* @problem.severity error
6+
* @precision high
7+
* @security-severity 9.3
8+
* @id actions/improper-access-control
9+
* @tags actions
10+
* security
11+
* external/cwe/cwe-285
12+
*/
13+
14+
import codeql.actions.security.UntrustedCheckoutQuery
15+
16+
from LocalJob job, LabelControlCheck check, MutableRefCheckoutStep checkout, Event event
17+
where
18+
job = checkout.getEnclosingJob() and
19+
job.isPrivileged() and
20+
job.getATriggerEvent() = event and
21+
event.getName() = "pull_request_target" and
22+
event.getAnActivityType() = "synchronize" and
23+
job.getAStep() = checkout and
24+
(
25+
checkout.getIf() = check
26+
or
27+
checkout.getEnclosingJob().getIf() = check
28+
)
29+
select checkout, "The checked-out code can be changed after the authorization check o step $@.",
30+
check, check.toString()
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: Pull request feedback
2+
3+
on:
4+
pull_request_target:
5+
types: [ opened, synchronize ]
6+
7+
permissions: {}
8+
jobs:
9+
test:
10+
permissions:
11+
contents: write
12+
pull-requests: write
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout repo for OWNER TEST
16+
uses: actions/checkout@v3
17+
if: contains(github.event.pull_request.labels.*.name, 'safe to test')
18+
with:
19+
ref: ${{ github.event.pull_request.head.ref }}
20+
- run: ./cmd
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: Pull request feedback
2+
3+
on:
4+
pull_request_target:
5+
types: [ labeled ]
6+
7+
permissions: {}
8+
jobs:
9+
test:
10+
permissions:
11+
contents: write
12+
pull-requests: write
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout repo for OWNER TEST
16+
uses: actions/checkout@v3
17+
if: contains(github.event.pull_request.labels.*.name, 'safe to test')
18+
with:
19+
ref: ${{ github.event.pull_request.head.ref }}
20+
- run: ./cmd
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
| .github/workflows/test1.yml:15:7:20:4 | Uses Step | The checked-out code can be changed after the authorization check o step $@. | .github/workflows/test1.yml:17:11:17:75 | contain ... test') | contain ... test') |
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Security/CWE-285/ImproperAccessControl.ql
2+

0 commit comments

Comments
 (0)