ci: harden cross-repo build workflow against workflow injection - #463
Conversation
c695aad to
9579b3e
Compare
|
Job is started, see https://github.com/vivoblueos/kernel/actions/runs/32966137588. |
44934cd to
be5a227
Compare
|
❌ Job failed. Failed jobs: check_format (failure), build_and_check_boards (failure), see https://github.com/vivoblueos/kernel/actions/runs/32966137588. |
|
build_prs |
|
Job is started, see https://github.com/vivoblueos/kernel/actions/runs/32968279881. |
|
❌ Job failed. Failed jobs: build_and_check_boards (failure), see https://github.com/vivoblueos/kernel/actions/runs/32968279881. |
|
build_prs |
|
Job is started, see https://github.com/vivoblueos/kernel/actions/runs/32977874406. |
|
❌ Job failed. Failed jobs: build_and_check_boards (failure), see https://github.com/vivoblueos/kernel/actions/runs/32977874406. |
|
build_prs |
|
Job is started, see https://github.com/vivoblueos/kernel/actions/runs/33030126518. |
|
❌ Job failed. Failed jobs: build_and_check_boards (failure), see https://github.com/vivoblueos/kernel/actions/runs/33030126518. |
|
build_prs |
|
Job is started, see https://github.com/vivoblueos/kernel/actions/runs/33033612990. |
|
✅ All jobs completed successfully, see https://github.com/vivoblueos/kernel/actions/runs/33033612990. |
Fixes the command-injection RCE reported in vivoblueos/kernel#458, where attacker-controlled PR content was interpolated into
execSyncshell strings and could execute arbitrary commands in CI.Changes
execFileSyncargument arrays instead ofexecSyncstring concatenation, so filenames/repo names are never interpreted by a shell (poc$(id).rsno longer expands).permissions: {}and a placeholdergithub-token: unused, so injected code cannot obtain the job'sGITHUB_TOKEN. Container GHCR login credentials andpackages: readwere removed because the image is public.setupjob is split intoresolve_prs, which keeps a token to comment and resolve PRs, andapply_prs, which runs repo init, sync, merge, and upload without one. This wayrepo synchas noGITHUB_TOKEN, so a<repo-hooks>hook injected via an attacker-controlled manifests PR cannot execute untrusted code.build_prslinks must belong to this org; PR metadata is passed to shell steps viaenvrather than${{ }}interpolation intorun:, so a value containing shell metacharacters is treated as data and never evaluated as commands.concurrencyis grouped per PR, so a newbuild_prscomment cancels the in-progress run instead of launching another set of matrix build jobs.