Skip to content

Commit

Permalink
ci: Read build matrix JSON explicitly (shaka-project#219)
Browse files Browse the repository at this point in the history
Because we used require() to read build-matrix.json, the file could be
replaced with build-matrix.json.js, allowing code injection into our CI
pipelines. This fixes this vulnerability by reading the JSON text with
the fs module, then explicitly parsing it, rather than relying on
require().

This exploit was discovered by a researcher, and the researcher's
activity was spotted within hours. Workflows were immediately suspended.
No evidence has been found of any tampering in this repository or its
releases.

Issue shaka-project#216
  • Loading branch information
joeyparrish authored Dec 16, 2024
1 parent 5a6cbb6 commit a71cade
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build-and-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ jobs:
steps:
- uses: actions/checkout@v4
with:
path: repo-src
ref: ${{ inputs.ref || (github.event.number && format('refs/pull/{0}/merge', github.event.number)) }}

- name: Configure Build Matrix
Expand All @@ -55,7 +54,8 @@ jobs:
// Use ENABLE_SELF_HOSTED to decide what the build matrix below
// should include.
const {hosted, selfHosted, pythonVersions} = require("${{ github.workspace }}/repo-src/build-matrix.json");
const buildMatrix = JSON.parse(fs.readFileSync("${{ github.workspace }}/build-matrix.json"));
const {hosted, selfHosted, pythonVersions} = buildMatrix;
const devices = enableSelfHosted ? hosted.concat(selfHosted) : hosted;
const matrix = [];
Expand Down

0 comments on commit a71cade

Please sign in to comment.