-
Notifications
You must be signed in to change notification settings - Fork 100
fix: prevent command injection in release workflow #442
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Mitigate remote code execution in release-build.yml where unsanitized user input could execute arbitrary commands and expose secrets. - Add input validation for semantic versioning format - Use environment variables instead of direct interpolation
.github/workflows/release-build.yml
Outdated
| fi | ||
| - name: Build and test | ||
| run: ./gradlew build -Prelease.version=${{ github.event.inputs.version }} --stacktrace | ||
| run: ./gradlew build -Prelease.version="${RELEASE_VERSION}" --stacktrace |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sanity check: should this not be "$RELEASE_VERSION" - similar to https://github.com/aws-observability/aws-otel-go/pull/280/files
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please elaborate? "$RELEASE_VERSION" is an intermediate environment variable, similar to "$TARGET_SHA" in your PR. Why shouldn't it be used?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are doing "${RELEASE_VERSION}", does that work the same as "$RELEASE_VERSION"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No functional difference here, but "${RELEASE_VERSION}" is cleaner and safer in general.
3.5.3 Shell Parameter Expansion
https://www.gnu.org/software/bash/manual/bash.html#Shell-Parameter-Expansion-1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my opinion, we should keep the style consistent with our other repos. It looks we don't use braces for retrieving env var in other workflows, and I vote for the no-brace style - $RELEASE_VERSION here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's a minor point and reversible, just wanted to make sure it was functionally equivalent. Approved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Brace is removed now.
Mitigate remote code execution in release-build.yml where unsanitized user input could execute arbitrary commands and expose secrets.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.