Skip to content
Closed
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
18 changes: 18 additions & 0 deletions .github/workflows/query-shield.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# .github/workflows/query-shield.yml
name: Query Shield
'on':
pull_request:
types: [opened, synchronize, reopened, ready_for_review, closed]
push:
branches: [master, main]
paths: ['.github/workflows/query-shield.yml'] # the onboarding merge → baseline (runs it if none is on record)
workflow_dispatch: {}
jobs:
query-shield:
permissions: # a called workflow only gets what its caller grants
contents: read
statuses: write
issues: write
pull-requests: write
uses: razorpay/query-shield/.github/workflows/query-shield.yml@master
secrets: inherit # the runner App's ID and key (org secrets)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟠 High severity issue identified in your code:

The reusable Query Shield workflow inherits all repository and organization secrets, including the runner App ID and key. A compromised or malicious change to the external workflow could exfiltrate those credentials and use them outside the intended job.

More details about this

query-shield calls razorpay/query-shield/.github/workflows/query-shield.yml@master and passes it every secret available to this repository through secrets: inherit, including the organization-level runner App ID and key mentioned in the comment—not only secrets required by Query Shield.

A plausible attack is:

  1. An attacker compromises the razorpay/query-shield repository, or a change merged into its master branch introduces a malicious step.
  2. This workflow runs for a pull request or a push to master/main.
  3. The called query-shield workflow can read inherited values such as the runner App ID and key, then send them to an attacker-controlled endpoint (for example, with curl from a workflow step).
  4. The attacker uses those credentials to impersonate the runner App or access other organization resources, even though this job only declares contents: read, statuses: write, issues: write, and pull-requests: write permissions. Because the workflow is pinned to the mutable master branch, a compromised upstream workflow can receive these secrets on its next run.

To resolve this comment:

✨ Commit fix suggestion

Suggested change
secrets: inherit # the runner App's ID and key (org secrets)
secrets:
RUNNER_APP_ID: ${{ secrets.RUNNER_APP_ID }}
RUNNER_APP_PRIVATE_KEY: ${{ secrets.RUNNER_APP_PRIVATE_KEY }}
View step-by-step instructions
  1. Remove secrets: inherit from .github/workflows/query-shield.yml; do not pass every repository secret to the reusable workflow.
  2. Check razorpay/query-shield/.github/workflows/query-shield.yml@master for the declared secret names and identify the runner App ID and private key it requires.
  3. Pass only those two secrets explicitly, using the names declared by the reusable workflow. For example:
    secrets:
      RUNNER_APP_ID: ${{ secrets.RUNNER_APP_ID }}
      RUNNER_APP_PRIVATE_KEY: ${{ secrets.RUNNER_APP_PRIVATE_KEY }}
    Replace RUNNER_APP_ID and RUNNER_APP_PRIVATE_KEY with the exact secret names used by the reusable workflow and configured as organization or repository secrets.
  4. Update the reusable workflow's on.workflow_call.secrets declaration if those secrets are not already defined there. A called workflow can only receive explicitly declared secrets, so the names in the caller and reusable workflow must match.
💬 Ignore this finding

Leave a nosemgrep comment directly above or at the end of line 18 like so // nosemgrep: yaml.github-actions.security.secrets-inherit.secrets-inherit

Take care to validate that this is not a true positive finding before ignoring it.
Learn more about ignoring code, files and folders here.

You can view more details about this finding in the Semgrep AppSec Platform.