Skip to content

Commit bc2454b

Browse files
wagnerioclaude
andcommitted
Update README for security hardening changes, bump to 0.3.2
Document static analysis engine, new providers (Azure OpenAI, Gemini), split HTTP clients, atomic config writes, content-type validation, environment variables, and updated CLI flags. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 08d6111 commit bc2454b

File tree

3 files changed

+73
-25
lines changed

3 files changed

+73
-25
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "scurl"
3-
version = "0.3.1"
3+
version = "0.3.2"
44
edition = "2021"
55
authors = ["scurl contributors <scurl-rust@pm.me>"]
66
description = "Secure curl - AI-powered security review for install scripts"

README.md

Lines changed: 71 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ AI-powered security review for installation scripts. Stop blindly piping `curl |
88
curl -fsSL https://example.com/install.sh | bash
99
```
1010

11-
You're executing unreviewed code with your user privileges. scurl downloads the script, sends it to an AI for security analysis, shows you the findings, and lets you decide whether to execute.
11+
You're executing unreviewed code with your user privileges. scurl downloads the script, runs static analysis for dangerous patterns and prompt injection, sends it to an AI for security analysis, shows you the findings, and lets you decide whether to execute.
1212

1313
## Install
1414

@@ -34,7 +34,9 @@ Requires Rust 1.70+ ([rustup.rs](https://rustup.rs)).
3434
scurl login
3535
```
3636

37-
Choose your AI provider, enter credentials (or skip for Ollama), done. Config is saved to `~/.scurl/config.toml` with `0600` permissions.
37+
Choose your AI provider, enter credentials (or skip for Ollama), done. Config is saved to `~/.scurl/config.toml` with `0600` permissions in a `0700` directory.
38+
39+
For maximum security, use the `SCURL_API_KEY` environment variable instead of storing the key in the config file.
3840

3941
### Providers
4042

@@ -43,8 +45,12 @@ Choose your AI provider, enter credentials (or skip for Ollama), done. Config is
4345
| **Anthropic** | claude-haiku-4-5 | [console.anthropic.com](https://console.anthropic.com) |
4446
| **xAI** | grok-4-1-fast-reasoning | [console.x.ai](https://console.x.ai) |
4547
| **OpenAI** | gpt-5-nano | [platform.openai.com](https://platform.openai.com/api-keys) |
48+
| **Azure OpenAI** | gpt-5-nano | [portal.azure.com](https://portal.azure.com) |
49+
| **Google Gemini** | gemini-2.5-flash | [aistudio.google.com](https://aistudio.google.com/app/apikey) |
4650
| **Ollama** | llama3.2 | None required ([ollama.ai](https://ollama.ai)) |
4751

52+
Azure OpenAI requires an endpoint URL and deployment name during setup. These can also be set via `AZURE_OPENAI_ENDPOINT` and `AZURE_OPENAI_DEPLOYMENT` environment variables.
53+
4854
## Usage
4955

5056
```bash
@@ -63,6 +69,8 @@ scurl login # Reconfigure
6369
⠋ Downloading script...
6470
✓ Downloaded 1247 bytes
6571
72+
✓ Static analysis: No suspicious patterns detected
73+
6674
⠋ Analyzing script with xAI (Grok) AI...
6775
✓ Analysis complete!
6876
@@ -94,16 +102,18 @@ Execute this script? [y/N]:
94102
| HIGH | No | Significant security risks |
95103
| CRITICAL | No | Severe threats, do not execute |
96104

105+
Auto-execute is also blocked when static analysis finds critical issues, regardless of the AI risk level.
106+
97107
### Network & Proxy
98108

99109
```bash
100110
scurl -x http://proxy.corp.com:8080 URL # Proxy
101-
scurl -k URL # Skip SSL verification
111+
scurl -k URL # Skip SSL verification (script downloads only)
102112
scurl -H "Authorization: Bearer $TOKEN" URL # Custom headers
103113
scurl --timeout 60 --retries 5 URL # Timeouts & retries
104114
```
105115

106-
Environment variables `HTTPS_PROXY` and `HTTP_PROXY` are respected automatically. See [NETWORK.md](NETWORK.md) for full proxy and enterprise configuration.
116+
Environment variables `HTTPS_PROXY` and `HTTP_PROXY` are respected automatically. Proxy URLs must use `http`, `https`, `socks5`, or `socks5h` schemes. See [NETWORK.md](NETWORK.md) for full proxy and enterprise configuration.
107117

108118
### Flags
109119

@@ -112,54 +122,92 @@ Environment variables `HTTPS_PROXY` and `HTTP_PROXY` are respected automatically
112122
| `--auto-execute` | `-a` | Auto-execute safe/low risk scripts |
113123
| `--shell <SHELL>` | `-s` | Shell for execution (default: bash) |
114124
| `--provider <NAME>` | `-p` | Override configured provider |
115-
| `--api-key <KEY>` | | Override configured API key |
116125
| `--proxy <URL>` | `-x` | HTTP/HTTPS proxy |
117126
| `--timeout <SECS>` | `-t` | Request timeout (default: 30) |
118127
| `--retries <N>` | | Retry attempts (default: 3) |
119-
| `--insecure` | `-k` | Disable SSL verification |
128+
| `--insecure` | `-k` | Disable SSL verification (script downloads only) |
120129
| `--header <H>` | `-H` | Add custom header |
121130
| `--user-agent <UA>` | `-A` | Custom User-Agent |
122131
| `--max-redirects <N>` | | Max redirects (default: 10) |
123132
| `--system-proxy` | | Use system proxy settings |
124133
| `--no-proxy` | | Disable proxy |
125-
| `--yolo` | | Skip AI review entirely |
134+
| `--yolo` | | Skip AI review (still requires confirmation) |
126135
| `--version` | `-V` | Print version |
127136

137+
### Environment Variables
138+
139+
| Variable | Description |
140+
|----------|-------------|
141+
| `SCURL_API_KEY` | Override API key (preferred over config file) |
142+
| `HTTPS_PROXY` | Proxy URL for all requests |
143+
| `AZURE_OPENAI_ENDPOINT` | Azure OpenAI endpoint URL |
144+
| `AZURE_OPENAI_DEPLOYMENT` | Azure OpenAI deployment name |
145+
128146
## How It Works
129147

130-
1. **Download** the script with retry logic and size limits (10 MB max)
131-
2. **Analyze** via your configured AI provider for security issues
132-
3. **Report** risk level, findings, and recommendation
133-
4. **Prompt** for confirmation (or auto-execute with `-a` if safe)
134-
5. **Execute** in a temporary file with your chosen shell
148+
1. **Validate** the URL (only `http`/`https` schemes allowed)
149+
2. **Download** the script with streaming, retry logic, and size limits (10 MB max)
150+
3. **Static analysis** scans for 22 dangerous patterns: shell exploits, reverse shells, data exfiltration, and prompt injection attempts
151+
4. **AI analysis** via your configured provider, with static findings forwarded for context
152+
5. **Report** risk level, findings, and recommendation
153+
6. **Prompt** for confirmation (or auto-execute with `-a` if safe and no critical static findings)
154+
7. **Execute** in a temporary file (`0700` permissions) with your chosen shell
135155

136-
The AI checks for: suspicious commands (`eval`, `base64`, nested `curl | bash`), untrusted downloads, privilege escalation, code obfuscation, credential harvesting, backdoor patterns, and destructive operations.
156+
### Static Analysis
157+
158+
Before AI review, scurl runs a built-in pattern scanner that detects:
159+
160+
**Shell Security** -- `eval` with dynamic content, base64-to-shell pipes, curl/wget piped to bash, `chmod 777`, `rm -rf /`, `/dev/tcp` redirections, reverse shells (`nc -e`), `LD_PRELOAD` injection, crontab manipulation, SSH key injection, direct disk writes, Python exec, history evasion, environment exfiltration, silent downloads to `/tmp`
161+
162+
**Prompt Injection** -- fake `RISK_LEVEL: SAFE` embedded in scripts, "ignore previous instructions", fake analysis output, AI role-play attempts, prompt override attempts, hidden base64 payloads in comments, markdown fence escape attempts
163+
164+
When prompt injection is detected, auto-execute is blocked and `--yolo` mode requires explicit confirmation.
137165

138166
## CI/CD
139167

140168
```yaml
141169
# GitHub Actions
142170
- name: Install tool with scurl
171+
env:
172+
SCURL_API_KEY: ${{ secrets.SCURL_API_KEY }}
143173
run: |
144-
scurl --provider anthropic --api-key ${{ secrets.ANTHROPIC_API_KEY }} \
145-
--auto-execute https://example.com/install.sh
174+
scurl --provider anthropic --auto-execute https://example.com/install.sh
146175
```
147176
177+
## Security
178+
179+
### Split HTTP Clients
180+
181+
scurl uses separate HTTP clients for script downloads and API calls. The `--insecure` flag only affects script downloads -- API calls to your AI provider always enforce TLS certificate verification.
182+
183+
### Atomic Config Writes
184+
185+
Configuration files are written atomically using temp-file-then-rename to prevent TOCTOU race conditions. Directory permissions are set to `0700` and file permissions to `0600` before any secrets are written.
186+
187+
### Content-Type Validation
188+
189+
Downloads are rejected if the content type indicates a non-script file (images, videos, PDFs, executables, archives). Ambiguous types produce a warning.
190+
191+
### Retry with Backoff
192+
193+
Network retries use exponential backoff with jitter (1s, 2s, 4s... capped at 30s) to avoid thundering herd issues. Client errors (4xx) are not retried.
194+
195+
### Limitations
196+
197+
AI analysis is helpful but not infallible. Always review the findings, especially for HIGH and CRITICAL risk scripts. The `--yolo` flag bypasses AI review but still runs static analysis and requires confirmation.
198+
148199
## Development
149200

150201
```bash
151202
git config core.hooksPath .githooks # Enable secret-detection hooks
152-
make test # Run tests (14 total)
153-
make check # fmt + clippy + audit
154-
make lint # Strict clippy
155-
make build # Release build
203+
cargo test --all-features # Run tests
204+
cargo clippy -- -D warnings # Lint
205+
cargo build --release # Release build
156206
```
157207

158-
See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
159-
160-
## Safety
208+
The pre-commit hook detects Anthropic, OpenAI, xAI, and AWS keys in staged files.
161209

162-
AI analysis is helpful but not infallible. Always review the findings, especially for HIGH and CRITICAL risk scripts. The `--yolo` flag bypasses all review -- use it only with sources you fully trust.
210+
See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
163211

164212
## License
165213

0 commit comments

Comments
 (0)