Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .jules/sentinel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
## 2024-05-24 - Secure Process Execution for docker system prune
**Vulnerability:** Use of shell wrapper `/bin/bash -c "docker system prune -f 2>&1"` for external command execution. While no dynamic input is passed in this specific case, using a shell wrapper for fixed commands is an anti-pattern that violates defense-in-depth principles and increases the attack surface (e.g., if PATH or environment was manipulated).
**Learning:** Shell redirections like `2>&1` can be implemented securely in Foundation.Process without needing a shell by assigning the same `Pipe()` object to both `standardOutput` and `standardError`.
**Prevention:** Always execute binary commands directly via `Process` (e.g., `/usr/bin/env docker`) using the `.arguments` array rather than wrapping them in a shell command string.
4 changes: 2 additions & 2 deletions Sources/Cacheout/ViewModels/CacheoutViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,8 @@ class CacheoutViewModel: ObservableObject {

let process = Process()
let pipe = Pipe()
process.executableURL = URL(fileURLWithPath: "/bin/bash")
process.arguments = ["-c", "docker system prune -f 2>&1"]
process.executableURL = URL(fileURLWithPath: "/usr/bin/env")
process.arguments = ["docker", "system", "prune", "-f"]
process.standardOutput = pipe
process.standardError = pipe
process.environment = [
Expand Down