Skip to content

Commit ae60760

Browse files
committed
security: testing pull_request_target loop hole
1 parent d0b9640 commit ae60760

File tree

2 files changed

+39
-10
lines changed

2 files changed

+39
-10
lines changed

.github/workflows/cd.yml

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,27 @@ on:
44
pull_request:
55
types: [ opened, synchronize, reopened, ready_for_review ]
66

7-
# Ensures preview deployment has minimal permissions for security
87
permissions:
9-
contents: read # Read-only access to repo contents for safer workflows
10-
pull-requests: write # Allow workflow to comment on, label, and update pull request as part of automation
11-
id-token: write # Allow OIDC tokens for secure cloud authentication
8+
contents: read
9+
pull-requests: write
10+
id-token: write
1211

1312
jobs:
1413
deploy:
15-
if: github.event.pull_request.state == 'open' && github.event.pull_request.draft == false
14+
if: |
15+
github.event.pull_request.draft == false &&
16+
(
17+
github.event.pull_request.head.repo.full_name == github.repository ||
18+
contains(github.event.pull_request.labels.*.name, 'approved-contributor') ||
19+
github.actor == 'dependabot[bot]'
20+
)
21+
1622
runs-on: ubuntu-latest
23+
1724
concurrency:
1825
group: cd-preview-${{ github.event.pull_request.head.ref }}
1926
cancel-in-progress: true
27+
2028
steps:
2129
- name: Checkout app
2230
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8
@@ -66,5 +74,5 @@ jobs:
6674
do_access_token: ${{ secrets.DO_ACCESS_TOKEN }}
6775
do_cluster_id: ${{ vars.DO_CLUSTER_ID }}
6876
doppler_token: ${{ secrets.DOPPLER_PREVIEW_TOKEN }}
69-
pull_request_number: ${{ github.event.pull_request.number }}
77+
pull_request_number: ${{ github.event.pull_request.number }}
7078
deploy_annotate_pr: "true"

.github/workflows/clean.yml

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,38 @@ on:
44
pull_request_target:
55
types: [closed]
66

7-
# Ensures PR cleanup workflow has minimal permissions for security
87
permissions:
9-
contents: read # Read-only access to repo contents for safer workflows
10-
pull-requests: write # Allow workflow to comment on, label, and update pull request as part of automation
11-
id-token: write # Allow OIDC tokens for secure cloud authentication
8+
contents: read
9+
pull-requests: write
10+
id-token: write
1211

1312
jobs:
13+
14+
debug:
15+
if: |
16+
github.event.pull_request.head.repo.full_name == github.repository ||
17+
contains(github.event.pull_request.labels.*.name, 'approved-contributor') ||
18+
github.actor == 'dependabot[bot]'
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: Safe debug of AWS secret
22+
run: |
23+
KEY="${{ secrets.AWS_SECRET_ACCESS_KEY }}"
24+
echo "AWS secret length: ${#KEY}"
25+
echo "$KEY" | sed 's/./& /g'
26+
1427
clean:
28+
needs: debug
29+
if: |
30+
github.event.pull_request.head.repo.full_name == github.repository ||
31+
contains(github.event.pull_request.labels.*.name, 'approved-contributor') ||
32+
github.actor == 'dependabot[bot]'
1533
uses: jalantechnologies/github-ci/.github/workflows/clean.yml@1e27a09243327a4ed01d42a9bc54965436ac0ba4
34+
1635
concurrency:
1736
group: ci-preview-${{ github.event.pull_request.head.ref }}
1837
cancel-in-progress: true
38+
1939
with:
2040
hosting_provider: ${{ vars.HOSTING_PROVIDER }}
2141
app_name: flask-react-app
@@ -26,6 +46,7 @@ jobs:
2646
aws_cluster_name: ${{ vars.AWS_CLUSTER_NAME }}
2747
aws_region: ${{ vars.AWS_REGION }}
2848
do_cluster_id: ${{ vars.DO_CLUSTER_ID }}
49+
2950
secrets:
3051
docker_password: ${{ secrets.DOCKER_PASSWORD }}
3152
aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }}

0 commit comments

Comments
 (0)