3 ms·
Is there a way of preventing functions from being imported from the environment, but still allowing some variables in? My experiments with #!/usr/bin/env -i s
by thyrsus 12y ago
Is there a way of preventing functions from being imported from the environment, but still allowing some variables in?
My experiments with
#!/usr/bin/env -i sh
and
#!/usr/bin/env - sh
...have not obtained what I'm after.
The problem being that functions take precedence over names in the file system, so
bash-4.2$ env '/bin/cp=() { echo oops;}' /bin/sh -c '/bin/cp /tmp/foo /tmp/bar'
oops
- AgentME 12y agoIf an attacker can fully control the name of an injected environment variable, then you've lost already. The attacker can override LD_PRELOAD, which is an environment variable honored by the Linux kernel itself.
- thyrsus 12y agoLD_PRELOAD is not honored for setuid executables, but you're right, we don't want to go there.