Skip to content

tanviet12/vbsec / skills/antigravity/vbs-scan-security

vbs-scan-security

Flagged

Use when scanning code for security vulnerabilities. Use when user says "scan security", "kiểm tra bảo mật", "security audit", "review security", or invokes `/vbs-scan-security`. For large scans (>20 main-language files OR >30 total OR >14 days) processes chunks sequentially. Outputs bilingual reports (vi/en). Optional `--auto-fix` (agentic patch + verify loop) and `--sca` (live CVE lookup via OSV.dev).

FileKindSize
SKILL.mdskill md28.2 KB
VERSIONother6 B
references/chunking-strategy.mdmarkdown7.2 KB
references/data-flow-classification.mdmarkdown9.5 KB
references/dependency-scan.mdmarkdown9.7 KB
references/i18n/en.mdmarkdown8.7 KB
references/i18n/vi.mdmarkdown9.4 KB
references/language-detection.mdmarkdown7.5 KB
references/load-rules.shexecutablescript5.2 KB
references/output-format.mdmarkdown26.1 KB
references/project-context.mdmarkdown2.7 KB
references/sub-agent-prompts.mdmarkdown16.5 KB
references/validate-report.pyexecutablescript8.7 KB
rules/generic/01-hardcoded-secret.mdmarkdown5.4 KB
rules/generic/02-sql-injection.mdmarkdown5.2 KB
rules/generic/03-xss.mdmarkdown4.9 KB
rules/generic/04-idor.mdmarkdown5.7 KB
rules/generic/05-slopsquatting.mdmarkdown6.1 KB
rules/generic/06-brute-force.mdmarkdown6.9 KB
rules/generic/07-mass-assignment.mdmarkdown6.3 KB
rules/generic/08-insecure-deserialization.mdmarkdown6.3 KB
rules/generic/09-ssrf.mdmarkdown6.7 KB
rules/generic/10-path-traversal.mdmarkdown6.3 KB
rules/generic/11-csrf.mdmarkdown7.8 KB
rules/generic/12-broken-access-control.mdmarkdown7.9 KB
rules/generic/13-weak-password-hashing.mdmarkdown5.2 KB
rules/generic/14-jwt-none-algorithm.mdmarkdown5.3 KB
rules/generic/15-cors-misconfig.mdmarkdown5.3 KB
rules/generic/16-unrestricted-file-upload.mdmarkdown5.9 KB
rules/generic/17-verbose-error-debug-mode.mdmarkdown5.8 KB
rules/generic/18-missing-rate-limit.mdmarkdown10.7 KB
rules/generic/19-race-condition.mdmarkdown11.5 KB
rules/generic/20-outdated-dependency.mdmarkdown7.2 KB
rules/generic/21-command-injection.mdmarkdown6.6 KB
rules/generic/22-vulnerable-dependency.mdmarkdown5.3 KB
rules/generic/23-llm-prompt-injection.mdmarkdown9.7 KB
rules/generic/24-excessive-agency.mdmarkdown10.1 KB
rules/generic/25-tenant-isolation.mdmarkdown10.1 KB
rules/generic/26-authz-path-parity.mdmarkdown10.9 KB
rules/generic/27-excessive-data-exposure.mdmarkdown10.4 KB
rules/generic/28-business-state-integrity.mdmarkdown9.5 KB
rules/generic/29-sensitive-data-in-logs.mdmarkdown9.1 KB
rules/generic/30-auth-session-lifecycle.mdmarkdown9.4 KB
rules/generic/31-resource-exhaustion.mdmarkdown9.0 KB
rules/languages/README.mdmarkdown8.5 KB
rules/languages/dart/01-hardcoded-secret.mdmarkdown7.9 KB
rules/languages/dart/03-xss.mdmarkdown5.2 KB
rules/languages/dart/05-slopsquatting.mdmarkdown4.6 KB
rules/languages/dart/10-path-traversal.mdmarkdown6.3 KB
rules/languages/dart/12-broken-access-control.mdmarkdown8.3 KB
rules/languages/dart/17-verbose-error-debug-mode.mdmarkdown6.7 KB
rules/languages/dart/20-outdated-dependency.mdmarkdown4.7 KB
rules/languages/dart/README.mdmarkdown3.7 KB
rules/languages/dotnet/02-sql-injection.mdmarkdown5.7 KB
rules/languages/dotnet/07-mass-assignment.mdmarkdown6.0 KB
rules/languages/dotnet/08-insecure-deserialization.mdmarkdown5.7 KB
rules/languages/dotnet/17-verbose-error-debug-mode.mdmarkdown5.0 KB
rules/languages/dotnet/21-command-injection.mdmarkdown5.3 KB
rules/languages/dotnet/README.mdmarkdown1.7 KB
rules/languages/go/02-sql-injection.mdmarkdown5.2 KB
rules/languages/go/08-insecure-deserialization.mdmarkdown5.0 KB
rules/languages/go/09-ssrf.mdmarkdown5.8 KB
rules/languages/go/17-verbose-error-debug-mode.mdmarkdown6.1 KB
rules/languages/go/21-command-injection.mdmarkdown5.2 KB
rules/languages/go/README.mdmarkdown2.7 KB
rules/languages/php/02-sql-injection.mdmarkdown5.8 KB
rules/languages/php/08-insecure-deserialization.mdmarkdown6.2 KB
rules/languages/php/11-csrf.mdmarkdown6.2 KB
rules/languages/php/17-verbose-error-debug-mode.mdmarkdown6.5 KB
rules/languages/php/21-command-injection.mdmarkdown6.7 KB
rules/languages/php/README.mdmarkdown2.9 KB
rules/languages/python/02-sql-injection.mdmarkdown7.2 KB
rules/languages/python/07-mass-assignment.mdmarkdown7.3 KB
rules/languages/python/08-insecure-deserialization.mdmarkdown7.3 KB
rules/languages/python/09-ssrf.mdmarkdown7.5 KB
rules/languages/python/11-csrf.mdmarkdown7.6 KB
rules/languages/python/14-jwt-none-algorithm.mdmarkdown7.5 KB
rules/languages/python/15-cors-misconfig.mdmarkdown8.0 KB
rules/languages/python/17-verbose-error-debug-mode.mdmarkdown8.4 KB
rules/languages/python/21-command-injection.mdmarkdown8.5 KB
rules/languages/python/README.mdmarkdown3.4 KB
rules/languages/typescript/02-sql-injection.mdmarkdown7.5 KB
rules/languages/typescript/03-xss.mdmarkdown6.7 KB
rules/languages/typescript/07-mass-assignment.mdmarkdown7.4 KB
rules/languages/typescript/08-insecure-deserialization.mdmarkdown7.0 KB
rules/languages/typescript/09-ssrf.mdmarkdown7.5 KB
rules/languages/typescript/11-csrf.mdmarkdown7.3 KB
rules/languages/typescript/14-jwt-none-algorithm.mdmarkdown7.0 KB
rules/languages/typescript/15-cors-misconfig.mdmarkdown7.2 KB
rules/languages/typescript/17-verbose-error-debug-mode.mdmarkdown7.2 KB
rules/languages/typescript/21-command-injection.mdmarkdown6.7 KB
rules/languages/typescript/README.mdmarkdown3.3 KB
workflows/auto-fix.mdmarkdown18.9 KB
workflows/large-review-sequential.mdmarkdown14.8 KB
workflows/small-review.mdmarkdown10.1 KB

rules/languages/dotnet/21-command-injection.md

View on GitHub
---
id: COMMAND-INJECTION
severity_max: CRITICAL
applies_to: dotnet
overrides: generic/21-command-injection.md
---

# Command Injection — .NET 10 Specialization

> Override cho rule chung `rules/generic/21-command-injection.md`. Áp dụng khi `primary_language: dotnet`.

## Intent (.NET-specific)

.NET code thường gọi tool hệ thống qua `System.Diagnostics.Process`: ImageMagick/ffmpeg/git/tar/powershell/cmd. Rủi ro xuất hiện khi input từ request được ghép vào `Arguments`, gọi `cmd.exe /c`, `powershell -Command`, hoặc dùng `ProcessStartInfo` với shell parsing. Kể cả khi `UseShellExecute = false`, một chuỗi `Arguments` tự ghép vẫn có thể bị option injection hoặc command injection nếu chạy shell.

## Khi nào CRITICAL

- `Process.Start("cmd.exe", "/c ... " + userInput)` hoặc `Process.Start("powershell", "-Command ...")`.
- `ProcessStartInfo.Arguments = $"... {input} ..."` với input L1 và gọi tool nguy hiểm.
- `UseShellExecute = true` với file/args từ request.
- `FileName` lấy từ request (`Process.Start(toolFromUser, ...)`).
- Chạy compiler/script/interpreter (`bash`, `sh`, `cmd`, `powershell`, `python`, `node`) với command string từ request.
- Upload filename/path đưa vào command mà không whitelist/canonicalize.

## Khi nào HIGH (giảm cấp)

- `ArgumentList.Add(input)` với `UseShellExecute = false` thường safe khỏi shell injection, nhưng vẫn kiểm tra path traversal/option injection.
- Input đã whitelist chặt (`^[a-zA-Z0-9._-]+$`) và không chạy qua shell.
- Endpoint admin/internal-only.
- Command chạy trong sandbox/container user thấp quyền.

## Cách reasoning

1. Grep process sinks: `Process.Start`, `ProcessStartInfo`, `Arguments`, `ArgumentList`, `UseShellExecute`, `cmd.exe`, `powershell`.
2. Read full method and trace file/argument source:
   - route/query/body/form/upload filename → L1.
   - DB field user-controlled → L2.
   - config constant → L3/L4.
3. Determine execution mode:
   - shell (`cmd /c`, `powershell -Command`, `UseShellExecute=true`) → CRITICAL with L1.
   - direct executable + `ArgumentList` → usually safe command-wise.
   - direct executable + single `Arguments` string → inspect quoting/whitelist.
4. Verify mitigations: allowlist command names, fixed executable path, `ArgumentList`, canonicalized file path, timeout, low-privilege execution.

## Search patterns

```
# Direct Process.Start with shell
Process\.Start\s*\(\s*["'](cmd\.exe|cmd|powershell|pwsh|bash|sh)["']
Process\.Start\s*\([^,]+,\s*\$
Process\.Start\s*\([^,]+,\s*["'][^"']*["']\s*\+

# ProcessStartInfo unsafe args
new\s+ProcessStartInfo\s*\(
\.Arguments\s*=\s*\$
\.Arguments\s*=\s*["'][^"']*["']\s*\+
UseShellExecute\s*=\s*true
\.FileName\s*=\s*(Request\.|.*Query|.*Form|.*Body)

# Dangerous interpreters/tools
(cmd\.exe|powershell|pwsh|bash|sh|python|node|ffmpeg|convert|magick|git|tar|zip)
```

## Examples

### CRITICAL — flag

```csharp
// cmd.exe /c with query input
app.MapPost("/convert", (string input) =>
{
    Process.Start("cmd.exe", $"/c magick convert {input} output.png");
});
// input = "a.png & type C:\\Windows\\win.ini"
```

```csharp
// ProcessStartInfo.Arguments concat from form
var file = Request.Form["file"].ToString();
var psi = new ProcessStartInfo
{
    FileName = "ffmpeg",
    Arguments = "-i " + file + " /tmp/out.mp4",
    UseShellExecute = true
};
Process.Start(psi);
```

```csharp
// User-controlled executable
var tool = Request.Query["tool"].ToString();
var arg = Request.Query["arg"].ToString();
Process.Start(tool, arg);
```

```csharp
// PowerShell command string
var name = request.FileName;
Process.Start("powershell", $"-Command Compress-Archive {name} out.zip");
```

### NOT critical — không flag

```csharp
// Fixed executable + ArgumentList + shell disabled
var psi = new ProcessStartInfo
{
    FileName = "/usr/bin/magick",
    UseShellExecute = false,
    RedirectStandardOutput = true
};
psi.ArgumentList.Add("convert");
psi.ArgumentList.Add(inputPath);
psi.ArgumentList.Add(outputPath);
Process.Start(psi);
```

```csharp
// Whitelist file name before passing as argument
if (!Regex.IsMatch(fileName, @"^[a-zA-Z0-9._-]+$"))
    return Results.BadRequest();

psi.ArgumentList.Add(Path.Combine(uploadRoot, fileName));
```

```csharp
// Fixed command selection
var tools = new Dictionary<string, string>
{
    ["thumbnail"] = "/usr/bin/magick",
    ["probe"] = "/usr/bin/ffprobe"
};
if (!tools.TryGetValue(kind, out var executable)) return Results.BadRequest();
```

## Fix recommendation

1. Avoid shell (`cmd.exe /c`, `powershell -Command`, `bash -c`) for user-controlled workflows.
2. Use fixed executable path and `ProcessStartInfo.ArgumentList` instead of one `Arguments` string.
3. Keep `UseShellExecute = false`.
4. Whitelist command mode, file extension, and file name; canonicalize paths under an allowed root.
5. Set timeout, clean environment, low-privilege user/container when running external tools.
6. Treat upload filenames as untrusted; generate server-side names before calling processing tools.

## Cross-references

- `10-path-traversal`: command may be safe but file path may still escape allowed directory.
- `16-unrestricted-file-upload`: uploaded file processing commonly reaches `ffmpeg`/ImageMagick.
- `08-insecure-deserialization`: both can become server-side RCE.
rea-analysis-optimizationmorluto/reaOptimize REA providers and shared analysis workflows for agent context, latency, CPU, and memory while preserving correctness and Evidence. Use for analysis bottlenecks and cache or query design; CI/test-suite optimization belongs to rea-ci-tests-audit.Stars: 471kUpdated Claude CodeCodexVerifiedInstall
rea-ci-tests-auditmorluto/reaAudit REA CI and test suites for correctness, fixture drift, false passes, and measured performance; use for suite or workflow investigations and efficiency changes, rather than ordinary feature testing or a single test failure.Stars: 471kUpdated Claude CodeCodexVerifiedInstall
rea-tool-designmorluto/reaAudit, investigate, design, or change REA investigation tools, CLI/MCP contracts, provider capabilities, and Evidence semantics.Stars: 471kUpdated Claude CodeCodexVerifiedInstall
ponytail-auditDietrichGebert/ponytailQuality audit of the whole repo: bugs, security, real load, missing tests, speed, and what to delete. Most important first.Stars: 194kUpdated Claude CodeCodexVerifiedInstall