-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Summary
The VERSION value extracted from pyproject.toml in .github/workflows/monorepo-release.yml is written directly to $GITHUB_OUTPUT without any format validation. A version string containing a newline character (e.g., version = "1.0.0\nGH_TOKEN=leaked") could inject arbitrary key-value pairs into GITHUB_OUTPUT, potentially poisoning subsequent workflow steps.
File & Location
- File:
.github/workflows/monorepo-release.yml - Line: 48
Original Review Comment
Category: CI/CD and GitHub Actions Security
Severity: MediumThe
VERSIONvalue extracted frompyproject.tomlis written directly to$GITHUB_OUTPUTwithout any format validation. A version string that contains a newline character (e.g.,version = "1.0.0\nGH_TOKEN=leaked") could inject arbitrary key-value pairs intoGITHUB_OUTPUT, potentially poisoning subsequent steps.By contrast,
python-release.ymlcorrectly validates wheel-derived values before using them:if [[ ! "$NAME" =~ ^[a-zA-Z0-9_-]+$ ]] || [[ ! "$VERSION" =~ ^[0-9a-zA-Z._-]+$ ]]; then echo "::error::Unexpected wheel name/version format …" >&2 exit 1 fiRecommendation: Add an equivalent validation step immediately after extracting
VERSION:VERSION=$(grep -m1 '^version' pyproject.toml \ | sed 's/version *= *"\(.*\)"/\1/') # Validate format before writing to GITHUB_OUTPUT if [[ ! "$VERSION" =~ ^[0-9a-zA-Z._-]+$ ]]; then echo "::error::Unexpected version format: '${VERSION}'" >&2 exit 1 fi echo "version=${VERSION}" >> "$GITHUB_OUTPUT" echo "tag=v${VERSION}" >> "$GITHUB_OUTPUT"This also protects against an empty
VERSION(if the grep/sed pattern fails to match), which would otherwise silently create a tag namedv.
Proposed Fix
Add a format validation step immediately after extracting VERSION and before writing to GITHUB_OUTPUT, mirroring the pattern already used in python-release.yml:
if [[ ! "$VERSION" =~ ^[0-9a-zA-Z._-]+$ ]]; then
echo "::error::Unexpected version format: '${VERSION}'" >&2
exit 1
fiRelated PR: #51
Review comment: #51 (comment)
Generated by PR Review Comment — Create Issue for PR #51
Generated by PR Review Comment — Create Issue for issue #51