process-api: ProcessBuilder and Process API module (pipe-buffer deadlock and its fixes, timeouts and process-tree kill, grandchild holding the pipe, environment/redirect/stdin, ProcessHandle, startPipeline, shell and option injection), ProcessRunner, 14 contract tests
Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017ic4b3W3uHbHAmM3orhn7b
This commit is contained in:
co-authored by
Claude Sonnet 5.5
parent
47e4ccbefa
commit
a714780bca
@@ -0,0 +1,25 @@
|
||||
== 1. VULNERABLE: build a shell string from user input
|
||||
$ sh -c wc -c report.txt; cat secret.txt
|
||||
18 report.txt
|
||||
TOP-SECRET [exit 0]
|
||||
|
||||
== 2. SAFE: argument list, no shell. The whole input is one filename
|
||||
$ wc -c report.txt; cat secret.txt
|
||||
wc: 'report.txt; cat secret.txt': No such file or directory [exit 1]
|
||||
|
||||
== 3. SAFE but still a trap: option injection. Input '-l' is read as a flag
|
||||
$ ls -l
|
||||
total 8
|
||||
-rw-r--r-- 1 root root 18 Nov 26 00:48 report.txt
|
||||
-rw-r--r-- 1 root root 11 Nov 26 00:48 secret.txt [exit 0]
|
||||
(the caller wanted to list a file called '-l'; ls took it as an option)
|
||||
|
||||
== 4. FIX: '--' ends option parsing, then validate
|
||||
$ ls -- -l
|
||||
ls: cannot access '-l': No such file or directory [exit 2]
|
||||
|
||||
== 5. FIX: allow-list the input before it gets anywhere near a command
|
||||
'report.txt' -> true
|
||||
'report.txt; cat secret.txt' -> false
|
||||
'-l' -> false
|
||||
'../etc/passwd' -> false
|
||||
Reference in New Issue
Block a user