Skip to content

Fix unsafe curl-pipe-bash pattern in PHP install scripts#2

Draft
semgrep-code-badoo[bot] wants to merge 1 commit intomasterfrom
semgrep-autofix/1774436238
Draft

Fix unsafe curl-pipe-bash pattern in PHP install scripts#2
semgrep-code-badoo[bot] wants to merge 1 commit intomasterfrom
semgrep-autofix/1774436238

Conversation

@semgrep-code-badoo
Copy link
Copy Markdown

Fix security issue where remote scripts are fetched and piped directly to bash, enabling potential remote code execution.

Changes

  • Modified build_php7.0_mac function to download install script before executing
  • Modified build_php7.3_mac function with the same fix
  • Added cleanup to remove temporary script files after execution

Why

Piping curl output directly to bash (curl ... | bash) is a security anti-pattern because:

  1. The script executes before you can inspect its contents
  2. A compromised or malicious server could serve arbitrary code
  3. Network issues could cause partial script execution

The fix downloads the script to a temporary file first, then executes it separately. This allows for inspection and prevents direct remote code execution from untrusted sources.

Semgrep Finding Details

Remote script is fetched and piped directly to a shell interpreter. In Claude Code and Cursor hooks, this enables remote code execution from untrusted sources. Download the script first, inspect it, then execute it separately.

@9071412 requested Semgrep Assistant generate this pull request to fix a finding.


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

Fix security issue where remote scripts are fetched and piped directly to bash, enabling potential remote code execution.

## Changes
- Modified `build_php7.0_mac` function to download install script before executing
- Modified `build_php7.3_mac` function with the same fix
- Added cleanup to remove temporary script files after execution

## Why
Piping `curl` output directly to `bash` (`curl ... | bash`) is a security anti-pattern because:
1. The script executes before you can inspect its contents
2. A compromised or malicious server could serve arbitrary code
3. Network issues could cause partial script execution

The fix downloads the script to a temporary file first, then executes it separately. This allows for inspection and prevents direct remote code execution from untrusted sources.

## Semgrep Finding Details
Remote script is fetched and piped directly to a shell interpreter. In Claude Code and Cursor hooks, this enables remote code execution from untrusted sources. Download the script first, inspect it, then execute it separately.

@9071412 requested Semgrep Assistant generate this pull request to fix [a finding](https://semgrep.dev/orgs/bmbl/findings/727472701).
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.

0 participants