【问题标题】:GitHub Workflow with 'pull_request_target' as trigger event (security risk)GitHub Workflow 以 \'pull_request_target\' 作为触发事件(安全风险)
【发布时间】:2023-02-14 16:00:18
【问题描述】:

目前我尝试实施一个 github 操作(工作流程)以向新的拉取请求添加评论。

我检查了一些关于事件触发器 pull_request_target 的博客文章 (https://securitylab.github.com/research/github-actions-preventing-pwn-requests/),它导致工作流在我的存储库中运行。

我的要点是不要使用 - uses: actions/checkout@v2,这会导致不受信任的代码执行。 我的想法是从我的回购(主要分支)下载我想添加为评论的降价文件。

您认为这仍然是安全风险吗?

这是我的工作流程:

name: Checklist
on:
  pull_request_target:
    types:
      - opened

jobs:
  welcome:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/github-script@v6
        with:
          script: |
            curl https://raw.githubusercontent.com/org/repo/main/markdown-file.md -o markdown-file.md
            const fs = require('fs');
            const body = fs.readFileSync('markdown-file.md')
            await github.rest.issues.createComment({
              issue_number: context.issue.number,
              owner: context.repo.owner,
              repo: context.repo.repo,
              body: body.toString()
            })

【问题讨论】:

    标签: github github-actions


    【解决方案1】:

    这不是安全风险。您是从已知的经过审查的来源获取文件而不是执行它(只是读取它),因此它不容易受到博客文章中问题的影响。

    此外,如果您仔细阅读,使用 checkout 操作也没有问题。例如,您可以签出代码,然后对它进行 grep 以获取某些值或对其运行 linter。

    只有当您使用 npm install 或其他构建脚本执行检出代码时,它才会成为安全风险。

    请参阅https://securitylab.github.com/research/github-actions-preventing-pwn-requests/#:~:text=of%20the%20PR.-,Having%20said%20that,-%2C%20mixing%20pull_request_target%20with,了解您文章中讨论此问题的特定部分。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-06-25
      • 1970-01-01
      • 2011-09-14
      • 1970-01-01
      • 2010-11-24
      • 2013-07-07
      • 2012-08-17
      相关资源
      最近更新 更多