Can someone explain the Shell Shock Bash code?
env x='() { :;}; echo vulnerable' bash -c "echo this is a test"
what env
does it do?
Documents env
run programs in a modified environment
env [OPTION]... [-] [NAME=VALUE]... [COMMAND [ARG]...]
it is clear that x
is the name / variable and () { :;}; echo vulnerable'
is the value of the variable
now what is it () { :;};
?
when the function is exported bash stores its defenition as the value of an environment variable
$ x() {echo hello world;}
$ export x
$ env | grep x
x=() {echo hello world};
now when x='() {:;}'
means similar spelling
$ x() {:;}
$ export x
$ env | grep x
We did this indirectly export x
on a new environment created env
here :
- this is the null statement in bash
Hope it helps
source to share