Skip to content

Commit 7f593bd

Browse files
authored
ci: Read build matrix JSON explicitly (#59)
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 #57
1 parent 7319390 commit 7f593bd

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

.github/workflows/build.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@ jobs:
7474
7575
// Use ENABLE_SELF_HOSTED to decide what the build matrix below
7676
// should include.
77-
const {hosted, selfHosted} = require("${{ github.workspace }}/repo-src/build-matrix.json");
77+
const buildMatrix = JSON.parse(fs.readFileSync("${{ github.workspace }}/repo-src/build-matrix.json"));
78+
const {hosted, selfHosted} = buildMatrix;
7879
const matrix = enableSelfHosted ? hosted.concat(selfHosted) : hosted;
7980
8081
// Output a JSON object consumed by the build matrix below.

0 commit comments

Comments
 (0)