3 ms·
I know the shell injection thing is bad, but would it be so bad to spawn a /bin/mkdir subprocess without a shell?
by nerdponx 5y ago
I know the shell injection thing is bad, but would it be so bad to spawn a /bin/mkdir subprocess without a shell?
- tyingq 5y agoThere's not much context in the story, but I would guess you might want some sanitizing for stuff like ../../../<whatever>/
- scwoodal 5y agoI prefer the code do any generating of file/directory names. Too many edge cases with user input when working at the OS level for me to sleep at night. Leverage a lookup that says user input “../../../root” == code generated directory path.
- infotogivenm 5y agoNo, not really. You might need some additional checks, like for ../ and symlinks, but you need these regardless whether you execve or write your own mkdirp().
- gsliepen 5y agoLess bad but still bad. Consider that /bin/mkdir is still interpreting whatever you pass to it. What if you provide it a "filename" that starts with a dash? Then /bin/mkdir will interpret that as an option. What if I give it "--version" as the name? It will return 0 (success), even though no directory was created. While it is rather harmless for /bin/mkdir, this might be a bigger problem for other programs.