Bug 619293 - sudo: reset $HOME by default
sudo: reset $HOME by default
Status: CLOSED CURRENTRELEASE
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: sudo (Show other bugs)
6.0
All Linux
high Severity medium
: rc
: ---
Assigned To: Daniel Kopeček
Eduard Benes
:
Depends On:
Blocks: 614877
  Show dependency treegraph
 
Reported: 2010-07-29 03:57 EDT by Tomas Hoger
Modified: 2010-11-10 16:40 EST (History)
5 users (show)

See Also:
Fixed In Version: sudo-1.7.2p2-8.el6
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2010-11-10 16:40:40 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
proposed patch (952 bytes, patch)
2010-08-03 05:38 EDT, Daniel Kopeček
no flags Details | Diff
proposed patch (955 bytes, patch)
2010-08-03 07:22 EDT, Daniel Kopeček
no flags Details | Diff

  None (edit)
Description Tomas Hoger 2010-07-29 03:57:37 EDT
Description of problem:
In the default configuration, sudo does not reset $HOME environment variable when switching to other user.  Commands run via sudo may use $HOME to search for configuration files or additional modules to load and can have security implications in setups where users are only allowed to run certain specific commands via sudo, but are not granted full shell access to the target user.

This issue has re-surfaced recently for python scripts.  Python 2.6 adds a "Per user site-packages directory" feature (PEP 370):
  http://www.python.org/dev/peps/pep-0370/

Python interpreter searches user home directories for additional modules to load.  When python script is run via sudo and $HOME is not reset to point to target user's home directory, modules can be loaded form source user's home directory, possibly bypassing intended restrictions.

Note: $PYTHONPATH is reset by sudo by default.

We should use safer default, users that prefer to keep $HOME unchanged can adjust sudoers configuration accordingly.  We can either default to always_set_home, or use the upstream change slated for the next upstream version 1.7.4, which no longer preserves $HOME by default during env_reset (env_reset is used by default in RHEL/Fedora sudo packages).

Related upstream commits:
  http://www.sudo.ws/repos/sudo/rev/18223dfd1ac3
  http://www.sudo.ws/repos/sudo/rev/0f7e08f09b9f
Comment 3 Daniel Kopeček 2010-08-03 05:38:14 EDT
Created attachment 436226 [details]
proposed patch
Comment 4 Daniel Kopeček 2010-08-03 07:22:13 EDT
Created attachment 436250 [details]
proposed patch

"use" -> "use it"
Comment 7 releng-rhel@redhat.com 2010-11-10 16:40:40 EST
Red Hat Enterprise Linux 6.0 is now available and should resolve
the problem described in this bug report. This report is therefore being closed
with a resolution of CURRENTRELEASE. You may reopen this bug report if the
solution does not work for you.

Note You need to log in before you can comment on or make changes to this bug.