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

[feature] Add new script injection input #345

Open
hugo-syn opened this issue Aug 20, 2023 · 0 comments
Open

[feature] Add new script injection input #345

hugo-syn opened this issue Aug 20, 2023 · 0 comments

Comments

@hugo-syn
Copy link
Contributor

Hi,

Using the syntax ${{ env.FOO }} for accessing environment variable can cause severe security issues, it's recommended to use the regular shell syntax $FOO or $Env:FOO for PowerShell.

Here is a vulnerable workflow example:

name: Test

on:
  issues:
    types: [opened]

jobs:
  dummyjob:
    runs-on: ubuntu-latest
    steps:
      - name: Injection step
        run: |
          ls -asl
          echo "${{ env.BODY }}" > body.log
          cat body.log
          ls -asl
        env:
          BODY: ${{ github.event.issue.body }}

An attacker could open the following issue to get arbitrary code execution inside the GitHub runner:

Closing first double quote"; echo "running code here" > pwned.txt ; echo "closing last double quote

As a result the file pwned.txt is created:

2023-08-20_14-44

Using this workflow would prevent the command injection vulnerability:

name: Test

on:
  issues:
    types: [opened]

jobs:
  dummyjob:
    runs-on: ubuntu-latest
    steps:
      - name: Injection step
        run: |
          ls -asl
          echo "$BODY" > body.log
          cat body.log
          ls -asl
        env:
          BODY: ${{ github.event.issue.body }}

2023-08-20_14-46

I already made a PR for this #332, but you asked for an issue where we can discuss this.

If you don't want to raise an alert for using ${{ env.FOO }} could we at least allow a wildcard character like in the PR to allow peoples to add new untrusted inputs ?

2023-08-20_15-03

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant