Repository navigation
ci: add Query Shield (DB query checks) - #100
banking-devops-app[bot] wants to merge 1 commit into
Conversation
| 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) |
There was a problem hiding this comment.
🟠 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:
- An attacker compromises the
razorpay/query-shieldrepository, or a change merged into itsmasterbranch introduces a malicious step. - This workflow runs for a pull request or a push to
master/main. - The called
query-shieldworkflow can read inherited values such as the runner App ID and key, then send them to an attacker-controlled endpoint (for example, withcurlfrom a workflow step). - 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, andpull-requests: writepermissions. Because the workflow is pinned to the mutablemasterbranch, a compromised upstream workflow can receive these secrets on its next run.
To resolve this comment:
✨ Commit fix suggestion
| 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
- Remove
secrets: inheritfrom.github/workflows/query-shield.yml; do not pass every repository secret to the reusable workflow. - Check
razorpay/query-shield/.github/workflows/query-shield.yml@masterfor the declared secret names and identify the runner App ID and private key it requires. - Pass only those two secrets explicitly, using the names declared by the reusable workflow. For example:
Replace
secrets: RUNNER_APP_ID: ${{ secrets.RUNNER_APP_ID }} RUNNER_APP_PRIVATE_KEY: ${{ secrets.RUNNER_APP_PRIVATE_KEY }}
RUNNER_APP_IDandRUNNER_APP_PRIVATE_KEYwith the exact secret names used by the reusable workflow and configured as organization or repository secrets. - Update the reusable workflow's
on.workflow_call.secretsdeclaration 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.
|
Closing: this Query Shield onboarding PR was opened while testing the flow. The repo will be onboarded again through the Datastores Agent when it is ready (onboard queryshield for ). |
Adds Query Shield, the DBA team's check for database queries: one workflow file, no secrets.
What it does
EXPLAINed live on the production read replica and scored 1–10. You get a commit statusquery-shield(red only on BLOCKED), a PR comment with the report, and a Slack alert to the owning team on BLOCKED/WARNING. A PR that touches no query-bearing file costs nothing.On a PR later
skip query shield for <repo> PR <n>, with a reason).EXPLAINis live, no new commit needed.query-shielda required status.Requested by kartik.verma@razorpay.com via the Datastores Agent · onboarding run. Questions: #dba-internal.