Bug 1220586 - sudo wrapper inside $HOME/bin
Summary: sudo wrapper inside $HOME/bin
Status: NEW
Alias: None
Product: openSUSE Tumbleweed
Classification: openSUSE
Component: Security (show other bugs)
Version: Current
Hardware: Other openSUSE Tumbleweed
: P5 - None : Critical (vote)
Target Milestone: ---
Assignee: Security Team bot
QA Contact: E-mail List
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-02-28 18:20 UTC by Sławomir Lach
Modified: 2024-03-04 16:08 UTC (History)
1 user (show)

See Also:
Found By: ---
Services Priority:
Business Priority:
Blocker: ---
Marketing QA Status: ---
IT Deployment: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sławomir Lach 2024-02-28 18:20:37 UTC
Opensuse allows to ran executables from $HOME/bin. Placing malicious program (for example - bash script), called sudo, could execute code as root. Tbis program would call sudo with absolute path and own arguments. It could also call sudo with arguments passed to this program, but also call it after/before with own arguments.
Comment 1 Thorsten Kukuk 2024-02-29 08:22:51 UTC
If an attacker is able to place binaries in your home directory, he is also able to modify your path to prefer this binaries.
Removing ~/bin from PATH does not change anything.
Comment 2 Andreas Stieger 2024-02-29 10:11:01 UTC
Also the user would not be able to anything that they were not already allowed to do previously. If the user has the root passport, they are root.

If sudo is properly configured, this scenario does not cross security boundaries
Comment 3 Sławomir Lach 2024-02-29 10:16:04 UTC
I do not known much about shells and file privileges system, especially DAC, but changing owner of ~/.profile, ~/.bash_profile, ~/.bashrc will do nothing, cause attacker could replace these files. Simply remove and write new.
Comment 4 Sławomir Lach 2024-02-29 19:22:12 UTC
I think, solution could be:
let sudo check each parent executable. If it is named (file name, not invocation way) sudo, then real sudo will refuse to work.
We can think about what happens, if attacker wr9te own bash to handle sudo invocarion in different way or define sudo alias.
Comment 5 Andreas Stieger 2024-02-29 20:30:31 UTC
I think you are mistaken. In that case the user can only what we could already do: invoke sudo as per it's configuration. If the user has the root password they ARE ROOT.
Comment 6 Sławomir Lach 2024-03-04 15:38:31 UTC
Maybe I am mistaken, but on OpenSUSE, user could invoke any command as root by providing root password.

Attacker could place custom sudo (bash script) inside ~/bin, ~/.local/bin and told sudo (by providing full path) to invoke another command than user would like, for example:
 ~/bin/sudo file:
 #!/bin/bash
 /usr/bin/sudo rm -rf --no-reserve-root /

User would like to do: sudo zypper dup and system will invoke rm -rf --no-preserve-root / as root, because user happily provide root password.
Comment 7 Sławomir Lach 2024-03-04 15:38:58 UTC
So sudo on OpenSUSE was not configured good.
Comment 8 Andreas Stieger 2024-03-04 16:08:24 UTC
If an attacker has access to a user's account, and the user users the root password, then the attacker is already root and your example does cross a privilege boundary. You are describing a fundamental problem with probably a mis-unserstanding what sudo is and is not supposed to do.