Bug 619293 - sudo: reset $HOME by default
Summary: sudo: reset $HOME by default
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: sudo   
(Show other bugs)
Version: 6.0
Hardware: All Linux
Target Milestone: rc
: ---
Assignee: Daniel Kopeček
QA Contact: Eduard Benes
Depends On:
Blocks: 614877
TreeView+ depends on / blocked
Reported: 2010-07-29 07:57 UTC by Tomas Hoger
Modified: 2010-11-10 21:40 UTC (History)
5 users (show)

Fixed In Version: sudo-1.7.2p2-8.el6
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2010-11-10 21:40:40 UTC
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
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 09:38 UTC, Daniel Kopeček
no flags Details | Diff
proposed patch (955 bytes, patch)
2010-08-03 11:22 UTC, Daniel Kopeček
no flags Details | Diff

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):

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:

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.

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