It's observed that when running a program having setuid bit set, it won't receive some environment variables set on the shell (bash etc.). Several environment variables which get removed this way are LD_PRELOAD, LD_LIBRARY_PATH, LD_ORIGIN_PATH, LD_DEBUG_OUTPUT, LD_PROFILE, LD_USE_LOAD_BIAS, GCONV_PATH
.
As mentioned in here and in this question, this is the intended behavior. Reason for this is to reduce attack vector.
Manual page of ld.so (8)
also states this.
The question is, which component of a Linux OS removes environment variables like this?
- Is it the shell?
- Is it a function like
fork()
orexecve()
etc. a shell calls internally when executing a command? - Is it the
ld.so
?
Note: any answer will be helpful. However, if you can direct me to which resources contain information on this matter, like which manual pages should I read, it would be more helpful.