Account Links: Cart | Your Account | Logout

Skip to content

Red Hat Knowledgebase

Red Hat Knowledgebase Search:

Updated Within the Last:

New Solutions within the last day New Solutions within the last week New Solutions within the last month

Browse by topics:


Click to View a Topic
Red Hat Enterprise Linux > AS/ES/WS v. 3 > Issue <<  455 of 594 >>

Solution Tools:


Email a Solution Postcard Printer version Submit a comment on this answer Update notifications Request an answer Back

Article Reference

Article ID: 4290
Last update: 10-26-07
Issue:
Why does the LD_LIBRARY_PATH variable get cleared for setuid/setgid binaries in Red Hat Enterprise Linux?
Resolution:

LD_LIBRARY_PATH is an environment variable to give the run-time shared library loader (ld.so) an extra set of directories to look for when searching for shared libraries. It is used in preference to any run time or default system linker path.

Multiple directories can be listed and separated with a colon [:] . This list is prepended to the existing list of compiled-in loader paths for a given executable and any system default loader paths.

So it is possible to override default system shared libraries for a given executable by using this path variable.

This can be a grave security risk for executables running with elevated privileges i.e. with setuid or setgid bit set. It could mean that the caller could override almost all of the functions called by the executable by custom and probably malicious code, which would then execute with elevated privileges.

For security reasons, LD_LIBRARY_PATH is ignored (unset) at runtime for executables that have their setuid or setgid bit set.

Here is an example:

The newgrp command is setuid to root, as explained above and LD_LIBRARY_PATH is unset when newgrp is executed by a non-root user.

 
# ls -l /usr/bin/newgrp
-rws--x--x 1 root root 6956 May 4 2004 /usr/bin/newgrp
      

Note: 's' listed in the permission field indicates that the command or file has the setuid / setgid bit set.

When newgrp is run by user root, it is not running with any elevated privileges and the restriction for LD_LIBRARY_PATH does not apply.

Other commands that are most frequently used and affects the LD_LIBRARY_PATH variable are passwd, su, crontab, and ping.


How well did this entry answer your question?


good wrong incomplete out of date
Red Hat Enterprise Linux > AS/ES/WS v. 3 > Issue <<   455  of  594  >>