3 ms·
> Escaping rules are well-defined Except when they aren't? I'm thinking of things like the bash exported function bug, an obscure feature nobody thought was th
by asveikau 9y ago
> Escaping rules are well-defined
Except when they aren't? I'm thinking of things like the bash exported function bug, an obscure feature nobody thought was there turns evaluating environment variables into RCE. Not to mention different shells may do things slightly differently and you may get caught doing something unexpected.
So why not leave the shell out of the picture entirely? I think execve and friends are much easier to get right than escaping. There are still possible security bugs to consider (eg., if using the -p family such as execvp, who controls PATH? Is anything on PATH writeable?), but the shell won't be among them.
- blindgeek 9y agoAs often as I've seen people get shell-escaping wrong, escaping rules probably aren't well-understood, regardless of how well-defined they are. Bourne shell's quoting rules are byzantine at best. There are ways to reliably and securely quote for the Bourne shell, but the best solution is not to pass untrusted input to the shell. Unrelated to the shell, I've seen people -- including myself -- fail at dot-stuffing. Experience has taught me to avoid hand-rolled escaping when I can; escaping is definitely a code smell.