Is sudo considered unsafe?
I am a somewhat experienced linux user. I know what the sudo command does and am aware that I can mess up the system myself or give any application the privilege to do so.
However, there are two scenarios that keep threatening me whenever I type sudo in a terminal:
If I issued a sudo command (e.g. sudo apt update), and run a different script from the same shell within 15 minutes, that script will effectively have root permissions. This is not a huge problem because I can change the timeout to 0, i.e. I'll have to enter my sudo password every time.
The more serious problem is that ~/.bashrc (or .zshrc etc.) is writable by me or, more specifically, every piece of code that is executed by my user. This means that every application I execute can append the following line to my .bashrc:
alias sudo="sudo maliciousscript.sh; sudo "
By default, sudo won't tell me what it is going to execute with root privileges. If I run sudo apt update and the malicious script doesn't write to stdout, I won't even notice that my system was compromised. And there are probably even more vectors an attacker could use.
I know that I can limit the use of sudo to specific applications, but is there a safe way to use sudo in general? If yes, why are popular distributions like ubuntu configured in such an unsafe way? Or am I completely mistaken?
security sudo alias malware
New contributor
danzel is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
I am a somewhat experienced linux user. I know what the sudo command does and am aware that I can mess up the system myself or give any application the privilege to do so.
However, there are two scenarios that keep threatening me whenever I type sudo in a terminal:
If I issued a sudo command (e.g. sudo apt update), and run a different script from the same shell within 15 minutes, that script will effectively have root permissions. This is not a huge problem because I can change the timeout to 0, i.e. I'll have to enter my sudo password every time.
The more serious problem is that ~/.bashrc (or .zshrc etc.) is writable by me or, more specifically, every piece of code that is executed by my user. This means that every application I execute can append the following line to my .bashrc:
alias sudo="sudo maliciousscript.sh; sudo "
By default, sudo won't tell me what it is going to execute with root privileges. If I run sudo apt update and the malicious script doesn't write to stdout, I won't even notice that my system was compromised. And there are probably even more vectors an attacker could use.
I know that I can limit the use of sudo to specific applications, but is there a safe way to use sudo in general? If yes, why are popular distributions like ubuntu configured in such an unsafe way? Or am I completely mistaken?
security sudo alias malware
New contributor
danzel is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
I am a somewhat experienced linux user. I know what the sudo command does and am aware that I can mess up the system myself or give any application the privilege to do so.
However, there are two scenarios that keep threatening me whenever I type sudo in a terminal:
If I issued a sudo command (e.g. sudo apt update), and run a different script from the same shell within 15 minutes, that script will effectively have root permissions. This is not a huge problem because I can change the timeout to 0, i.e. I'll have to enter my sudo password every time.
The more serious problem is that ~/.bashrc (or .zshrc etc.) is writable by me or, more specifically, every piece of code that is executed by my user. This means that every application I execute can append the following line to my .bashrc:
alias sudo="sudo maliciousscript.sh; sudo "
By default, sudo won't tell me what it is going to execute with root privileges. If I run sudo apt update and the malicious script doesn't write to stdout, I won't even notice that my system was compromised. And there are probably even more vectors an attacker could use.
I know that I can limit the use of sudo to specific applications, but is there a safe way to use sudo in general? If yes, why are popular distributions like ubuntu configured in such an unsafe way? Or am I completely mistaken?
security sudo alias malware
New contributor
danzel is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
I am a somewhat experienced linux user. I know what the sudo command does and am aware that I can mess up the system myself or give any application the privilege to do so.
However, there are two scenarios that keep threatening me whenever I type sudo in a terminal:
If I issued a sudo command (e.g. sudo apt update), and run a different script from the same shell within 15 minutes, that script will effectively have root permissions. This is not a huge problem because I can change the timeout to 0, i.e. I'll have to enter my sudo password every time.
The more serious problem is that ~/.bashrc (or .zshrc etc.) is writable by me or, more specifically, every piece of code that is executed by my user. This means that every application I execute can append the following line to my .bashrc:
alias sudo="sudo maliciousscript.sh; sudo "
By default, sudo won't tell me what it is going to execute with root privileges. If I run sudo apt update and the malicious script doesn't write to stdout, I won't even notice that my system was compromised. And there are probably even more vectors an attacker could use.
I know that I can limit the use of sudo to specific applications, but is there a safe way to use sudo in general? If yes, why are popular distributions like ubuntu configured in such an unsafe way? Or am I completely mistaken?
security sudo alias malware
security sudo alias malware
New contributor
danzel is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
danzel is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
danzel is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
asked 4 mins ago
danzeldanzel
1011
1011
New contributor
danzel is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
danzel is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
danzel is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "106"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
danzel is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f498241%2fis-sudo-considered-unsafe%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
danzel is a new contributor. Be nice, and check out our Code of Conduct.
danzel is a new contributor. Be nice, and check out our Code of Conduct.
danzel is a new contributor. Be nice, and check out our Code of Conduct.
danzel is a new contributor. Be nice, and check out our Code of Conduct.
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f498241%2fis-sudo-considered-unsafe%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown