Bug 619293

Summary: sudo: reset $HOME by default
Product: Red Hat Enterprise Linux 6 Reporter: Tomas Hoger <thoger>
Component: sudoAssignee: Daniel Kopeček <dkopecek>
Status: CLOSED CURRENTRELEASE QA Contact: Eduard Benes <ebenes>
Severity: medium Docs Contact:
Priority: high    
Version: 6.0CC: dmalcolm, ebenes, jpazdziora, sgrubb, syeghiay
Target Milestone: rc   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
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 21:40:40 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 614877    
Attachments:
Description Flags
proposed patch
none
proposed patch none

Description Tomas Hoger 2010-07-29 07:57:37 UTC
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 09:38:14 UTC
Created attachment 436226 [details]
proposed patch

Comment 4 Daniel Kopeček 2010-08-03 11:22:13 UTC
Created attachment 436250 [details]
proposed patch

"use" -> "use it"

Comment 7 releng-rhel@redhat.com 2010-11-10 21:40:40 UTC
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.