visudo will open existing sudoers.tmp
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
sudo (Ubuntu) |
Confirmed
|
Low
|
Unassigned |
Bug Description
By code inspection (I haven't tried to make this happen in case I screw up and open my system to the world), visudo in current dapper will open sudoers.tmp without O_EXCL.
This is clearly done for a reason, ie to prevent DoS on visudo if a machine is misconfigured to allow somebody to only create new files in /etc (which is not actually terribly unreasonable - although it is a bit stupid - for a multiadmin machine using sudo).
The upshot is that if somebody could do just that (create /etc/sudoers.tmp), they could make it permissive and visudo would only truncate it - enabling the configuration to be altered if the timing is right - ie before visudo changes the mode - or if an fd is already open. Through this means a restricted admin could theoretically gain additional privileges.
Is there a good argument against using mkstemp here (ie having a /etc/sudoers.d/ directory - setting its permissions and ownership to the same as /etc/ and making a temporary file securely in there)?
This is related to, but distinct from: https:/ /launchpad. net/distros/ ubuntu/ +source/ sudo/+bug/ 16700
as it is not the location that is the problem, but the means by which the file is opened/truncated.