Bug 1373645

Summary: useradd allows '.' and '..' as an username which is problematic
Product: Red Hat Enterprise Linux 7 Reporter: Christopher Hailey <christopher.e.hailey>
Component: shadow-utilsAssignee: Tomas Mraz <tmraz>
Status: CLOSED ERRATA QA Contact: Jaroslav Aster <jaster>
Severity: low Docs Contact:
Priority: low    
Version: 7.0CC: jaster, nmavrogi
Target Milestone: pre-dev-freeze   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: shadow-utils-4.1.5.1-25.el7 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-10-30 08:04:11 UTC Type: Bug
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: 1563599    
Attachments:
Description Flags
Patch to chkname.c to disalow usernames starting with dot none

Description Christopher Hailey 2016-09-06 20:52:05 UTC
Created attachment 1198419 [details]
Patch to chkname.c to disalow usernames starting with dot

Description of problem: useradd allows usernames to start with a dot which is a problem since the user's home directory is the username.

This means that is a user is created like this, e.g. ".fred" then the user's home directory is also ".fred" which is a hidden directory.   The real trouble starts if the username is just dot or dot-dot which are current directory and current directory parent i.e. /home/. and /home/.. - very bad.  these to examples blow up, but the home directory is set to /home/. or /home/.. (!)


Version-Release number of selected component (if applicable): up to and including shadow-utils 4.1.5.1-18


How reproducible:  useradd .fred or useradd . or useradd .. 


Steps to Reproduce:
1.
2.
3.

Actual results:  Accounts are created with fubar home directories (nothing created with dot and dot-dot, fortunately, i.e. /etc/skel


Expected results:  useradd should complain


Additional info:  suggested patch included as attachment

Comment 2 Tomas Mraz 2016-09-07 07:20:38 UTC
I am sorry but I do not think this is particularly severe problem. No security issue is created by it and traditionally no unix utilities prevented you from shooting your own foot.

Also please use regular Red Hat support contact to report issues with Red Hat Enterprise Linux so we can properly prioritize the fixes.

Comment 3 Tomas Mraz 2016-09-07 07:22:28 UTC
Also it might be acceptable to prevent . or .. user to be created, however anything else starting with dot should be allowable, there might be legitimate cases where having such user is needed.

Comment 4 Christopher Hailey 2016-09-07 19:26:31 UTC
(In reply to Tomas Mraz from comment #3)
> Also it might be acceptable to prevent . or .. user to be created, however
> anything else starting with dot should be allowable, there might be
> legitimate cases where having such user is needed.

If the username is . then pam_mkhomedir will create all of the /etc/skel stuff in /home - that's bad.

If the username starts with dot then the home dir is hidden which is weird but probably not a huge problem.

I think disallowing "." and ".." is a good idea since it creates a broken state.

Comment 7 Tomas Mraz 2018-04-24 14:38:02 UTC
I will also prevent creating all-numeric user names to sync with current Fedora.

Comment 12 errata-xmlrpc 2018-10-30 08:04:11 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2018:3063