이 페이지는 아직 영어로 제공되지 않습니다. 번역 작업 중입니다.
현재 번역 프로젝트에 대한 질문이나 피드백이 있으신 경우 언제든지 연락주시기 바랍니다.

Metadata

ID: github-actions/dangerous-trigger

Language: YAML

Severity: Warning

Category: Security

Description

Workflows triggered by the pull_request_target trigger can read secrets and edit code in the repository that the PR is targeting. This is a dangerous trigger that must be used with caution. For security reasons, GitHub runs these workflows using the code from the base branch, rather than the code from the PR.

If you use this trigger you must not checkout the code of the PR, otherwise anyone can simply write malicious code and get it to run in a context that has access to your secrets, in addition to write access to the repository.

This type of attack is sometimes referred to as “pwn request”.

Note that if you use the “workflow_call” trigger, your workflow is callable by other workflows, so possibly by a workflow using the pull_request_target trigger.

Learn More

Non-Compliant Code Examples

name: PR

on:
  pull_request_target:
    paths-ignore:
    - datadog_checks_base/datadog_checks/**
    - datadog_checks_dev/datadog_checks/dev/*.py

concurrency:
  group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.head_ref }}
  cancel-in-progress: true

jobs:
  test:
    uses: ./.github/workflows/pr-test.yml
    with:
      repo: core
    secrets: inherit

Compliant Code Examples

name: PR

on:
  pull_request:
    paths-ignore:
    - datadog_checks_base/datadog_checks/**
    - datadog_checks_dev/datadog_checks/dev/*.py

concurrency:
  group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.head_ref }}
  cancel-in-progress: true

jobs:
  test:
    uses: ./.github/workflows/pr-test.yml
    with:
      repo: core
    secrets: inherit
PREVIEWING: dgreen15/github-error-fix