Skip to content

ci: Avoid curl-pipe-shell pattern in dotnet install step - #2803

Closed
semgrep-code-getsentry[bot] wants to merge 1 commit into
mainfrom
semgrep-autofix/1786017477
Closed

ci: Avoid curl-pipe-shell pattern in dotnet install step#2803
semgrep-code-getsentry[bot] wants to merge 1 commit into
mainfrom
semgrep-autofix/1786017477

Conversation

@semgrep-code-getsentry

Copy link
Copy Markdown

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 from the detection rule yaml.github-actions.security.gha-curl-pipe-shell.gha-curl-pipe-shell.


⚠️ Review carefully before merging. This PR was generated by AI and may cause breaking changes or introduce new vulnerabilities.

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).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant