Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add pull_request_target event to GitHub workflows #941

Merged
merged 3 commits into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/deploy-test-buffered.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ on:
branches: main
pull_request:
branches: main
pull_request_target:
branches: main
Comment on lines +8 to +9
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

⚠️ Potential issue

Critical Security Issue: Unsafe pull_request_target implementation detected

The workflows are using pull_request_target trigger while checking out code and accessing sensitive repository secrets (AWS credentials) without explicitly specifying the base ref. This creates a security vulnerability where malicious PR code could potentially access production AWS credentials.

Current security issues:

  • Both workflows use actions/checkout@v4 without specifying ref
  • AWS credentials and certificate ARNs are exposed to PR code
  • Build and test steps run untrusted PR code with access to secrets

Required fixes:

  1. Remove pull_request_target trigger as it's unnecessary (workflows already have pull_request trigger)
  2. If pull_request_target must be kept, add ref: ${{ github.event.pull_request.base.ref }} to checkout action
  3. Split the workflow into two parts:
    • One with pull_request trigger for building/testing PR code
    • Another with pull_request_target for tasks requiring secrets
🔗 Analysis chain

Security Warning: Carefully review pull_request_target implementation

Adding pull_request_target trigger requires careful consideration as it runs with repository context and has access to secrets, even from fork PRs. This can be dangerous if the workflow checks out and runs untrusted PR code with access to secrets.

To ensure security:

  1. Always use the base ref for checkout (ref: ${{ github.event.pull_request.base.ref }})
  2. Never checkout PR code when using repository secrets
  3. Implement proper input validation

Let's verify the checkout configuration:


Let me check the complete workflow file content to verify the checkout configuration and job permissions:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if any workflow files use pull_request_target without explicit ref
rg -l 'pull_request_target' .github/workflows/ | xargs rg 'uses: actions/checkout@' -A 2

Length of output: 983


Script:

#!/bin/bash
# Get full content of the workflow files using pull_request_target
cat .github/workflows/deploy-test-buffered.yml .github/workflows/deploy-test.yml

Length of output: 5790


concurrency: deploy-test-buffered${{ (github.event_name == 'pull_request' && '-dev') || '' }}

Expand All @@ -14,7 +16,6 @@ jobs:
matrix:
architecture: [lambda-mono, lambda-s3, edge-unbundled]
runs-on: ubuntu-latest
environment: dev
steps:
- name: Checkout
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
Expand Down Expand Up @@ -52,7 +53,6 @@ jobs:
matrix:
architecture: [lambda-mono, lambda-s3, edge-unbundled]
runs-on: ubuntu-latest
environment: dev
steps:
- name: Checkout
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/deploy-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ on:
branches: main
pull_request:
branches: main
pull_request_target:
branches: main

concurrency: deploy-test${{ (github.event_name == 'pull_request' && '-dev') || '' }}

Expand All @@ -14,7 +16,6 @@ jobs:
matrix:
architecture: [lambda-mono, lambda-s3, edge-bundled, edge-unbundled]
runs-on: ubuntu-latest
environment: dev
steps:
- name: Checkout
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
Expand Down Expand Up @@ -51,7 +52,6 @@ jobs:
matrix:
architecture: [lambda-mono, lambda-s3, edge-bundled, edge-unbundled]
runs-on: ubuntu-latest
environment: dev
steps:
- name: Checkout
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"repository": {
"type": "git",
"url": "git+https://github.com/jill64/sveltekit-adapter-aws.git",
"image": "https://opengraph.githubassets.com/4120f79490bffbe7a154224116677366b5f3cd37e11f5f711bbcb1d5bf130806/jill64/sveltekit-adapter-aws"
"image": "https://opengraph.githubassets.com/253d2596764f78f09128d4733176688fe72246f27016db80c7e0a2e706beae1c/jill64/sveltekit-adapter-aws"
},
"publishConfig": {
"access": "public"
Expand Down
Loading