Skip to content
Open
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
38 changes: 38 additions & 0 deletions .github/workflows/droid.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Droid Tag

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2: Workflow lacks top-level permissions block to restrict default GITHUB_TOKEN scope

No top-level permissions block means default token permissions depend on repo settings.

Add permissions: {} at the workflow level for defense-in-depth.

AI prompt
Check if this security scanner issue is valid. If so, understand the root cause and fix it. If appropriate, update or add tests. Keep the change focused and preserve intended behavior.

<file name=".github/workflows/droid.yml">
<violation number="1" location=".github/workflows/droid.yml:1">
<priority>P2</priority>
<title>Workflow lacks top-level permissions block to restrict default GITHUB_TOKEN scope</title>
<evidence>The workflow does not declare a top-level permissions block, so any additional jobs added later would inherit the repository's default GITHUB_TOKEN permissions, which may be broader than intended. The single job in this workflow does have explicit job-level permissions, but adding permissions: {} at the workflow level is a defense-in-depth measure recommended by GitHub and the OpenSSF.</evidence>
<recommendation>Add permissions: {} at the top level of the workflow (before or after the on: block) so that the default token scope is empty and every job must explicitly declare its own permissions.</recommendation>
</violation>
</file>


on:
issue_comment:
types: [created]
pull_request_review_comment:
types: [created]
pull_request_review:
types: [submitted]

jobs:
droid:
if: |

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1: Workflow triggers on untrusted issue comments without author validation

Untrusted users can trigger third-party action runs by posting @droid in public issue comments.

Add author_association checks to the if condition to only run for trusted collaborators.

AI prompt
Check if this security scanner issue is valid. If so, understand the root cause and fix it. If appropriate, update or add tests. Keep the change focused and preserve intended behavior.

<file name=".github/workflows/droid.yml">
<violation number="1" location=".github/workflows/droid.yml:13">
<priority>P1</priority>
<title>Workflow triggers on untrusted issue comments without author validation</title>
<evidence>The workflow fires on `issue_comment` events without checking the comment author's trust level. Any GitHub user can create an issue comment on a public repository containing `@droid`, causing this workflow to run a third-party action with access to repository secrets (`FACTORY_API_KEY`) and write permissions (`issues: write`, `pull-requests: write`). The `if` block only checks for the `@droid` string but does not verify `github.event.comment.author_association`.</evidence>
<recommendation>Restrict the `issue_comment` trigger to trusted authors by checking `github.event.comment.author_association` (e.g., OWNER, MEMBER, COLLABORATOR) before running the third-party action.</recommendation>
</violation>
</file>

github.actor != 'dependabot[bot]' && (
(github.event_name == 'issue_comment' && contains(github.event.comment.body, '@droid') && contains(fromJson('["MEMBER", "OWNER", "COLLABORATOR"]'), github.event.comment.author_association)) ||
(github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@droid') && contains(fromJson('["MEMBER", "OWNER", "COLLABORATOR"]'), github.event.comment.author_association)) ||
(github.event_name == 'pull_request_review' && contains(github.event.review.body, '@droid') && contains(fromJson('["MEMBER", "OWNER", "COLLABORATOR"]'), github.event.review.author_association))
)
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
issues: write
actions: read
env:
FACTORY_API_KEY: ${{ secrets.FACTORY_API_KEY }}
steps:
- name: Checkout repository
if: env.FACTORY_API_KEY != ''
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5
with:
fetch-depth: 1
persist-credentials: false
- name: Run Droid Exec
if: env.FACTORY_API_KEY != ''
uses: Factory-AI/droid-action@7c7bfea2aa3bb7ea87579402cc1d89dbcf6b13b3 # main
with:
factory_api_key: ${{ env.FACTORY_API_KEY }}