ci: Avoid curl-pipe-shell pattern in dotnet install step - #2803
Closed
semgrep-code-getsentry[bot] wants to merge 1 commit into
Closed
ci: Avoid curl-pipe-shell pattern in dotnet install step#2803semgrep-code-getsentry[bot] wants to merge 1 commit into
semgrep-code-getsentry[bot] wants to merge 1 commit into
Conversation
Replace the `curl | bash` pattern with a download-then-execute approach for installing .NET SDK in the Linux build step. ## Changes - Download `dotnet-install.sh` to a temporary file instead of piping directly to bash - Make the downloaded script executable - Execute the script directly with its arguments ## Why Piping `curl` output directly into a shell interpreter is a security risk: if the remote server is compromised or the URL is hijacked, arbitrary code could execute in the CI runner. Downloading the file first and then executing it separately is a safer pattern that also makes the step easier to debug. ## Semgrep Finding Details A `run:` step pipes the output of `curl` or `wget` directly into a shell interpreter. This is the "curl | bash" install pattern — if the remote server is compromised or the URL is hijacked, an attacker can execute arbitrary code in your CI runner. Consider downloading the file first, verifying its checksum or signature, and then executing it. alex.tarasov@sentry.io requested this Autofix PR for [this finding](https://semgrep.dev/orgs/sentry/findings/876643034) from the detection rule [yaml.github-actions.security.gha-curl-pipe-shell.gha-curl-pipe-shell](https://semgrep.dev/r/yaml.github-actions.security.gha-curl-pipe-shell.gha-curl-pipe-shell).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Replace the
curl | bashpattern with a download-then-execute approach for installing .NET SDK in the Linux build step.Changes
dotnet-install.shto a temporary file instead of piping directly to bashWhy
Piping
curloutput directly into a shell interpreter is a security risk: if the remote server is compromised or the URL is hijacked, arbitrary code could execute in the CI runner. Downloading the file first and then executing it separately is a safer pattern that also makes the step easier to debug.Semgrep Finding Details
A
run:step pipes the output ofcurlorwgetdirectly into a shell interpreter. This is the "curl | bash" install pattern — if the remote server is compromised or the URL is hijacked, an attacker can execute arbitrary code in your CI runner. Consider downloading the file first, verifying its checksum or signature, and then executing it.alex.tarasov@sentry.io requested this Autofix PR for this finding from the detection rule yaml.github-actions.security.gha-curl-pipe-shell.gha-curl-pipe-shell.