Script injection through user controlled values

이 페이지는 아직 한국어로 제공되지 않으며 번역 작업 중입니다. 번역에 관한 질문이나 의견이 있으시면 언제든지 저희에게 연락해 주십시오.

Metadata

ID: github-actions/script-injection

Language: YAML

Severity: Warning

Category: Security

Description

As detailed in Security hardening for GitHub Actions - GitHub Docs, it is possible for an attacker to inject scripts through PR, branch, commit names, and more.

Avoid using user input in your actions shell scripts, and if you must, consider storing them first in an environment variable to escape them properly.

Read Cycode Discovers a Supply Chain Vulnerability in Bazel - Cycode if you wanna see a concrete exploitation of such mechanism.

Non-Compliant Code Examples

jobs:
  build-and-publish:
    runs-on: ubuntu-latest
    steps:
      - name: Echo PR title
        run: |
          title="${{ github.event.pull_request.title }}"
          echo $title          

Compliant Code Examples

permissions:
  contents: read
jobs:
  build-and-publish:
    runs-on: ubuntu-latest
    steps:
      - name: Echo PR title
        env:
          TITLE: ${{ github.event.pull_request.title }}
        run: |
          echo $TITLE          
      - name: Echo runner tytle
        run: |
          echo "${{ runner.name }}"          
https://static.datadoghq.com/static/images/logos/github_avatar.svg https://static.datadoghq.com/static/images/logos/vscode_avatar.svg jetbrains

Seamless integrations. Try Datadog Code Analysis