Questions tagged [setuid]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0
votes
1answer
17 views

Set-UID Capability Leak Attack

I have a C program to demonstrate the capability leak attack regarding set-uid. // cap_leak.c #include <unistd.h> #include <stdio.h> #include <stdlib.h> #include <fcntl.h> ...
4
votes
1answer
416 views

Why I can not drop sudo root privileges?

I am debugging a program and not quite sure why I can not drop privileges. I have root permissions via sudo and I can call setgid/setuid, but the operation [is] is not supported. Basic code to ...
8
votes
2answers
715 views

Why does the setuid bit work inconsistently?

I wrote the code: // a.c #include <stdlib.h> int main () { system("/bin/sh"); return 0; } compiled with command: gcc a.c -o a.out added setuid bit on it: sudo chown root.root a.out sudo ...
0
votes
1answer
33 views

How to Run the command or script through any user in linux? [closed]

I am having a C executable in AIX system by which I can run the command through any user like root or system users. script having below permissions. On AIX server lrwsrwxrwx 1 root system 24 ...
1
vote
3answers
8k views

What is required by a process to set its uid to 0 (root)?

I am completely new to *NIX based OSes. One of the things that baffles me is that a process or program may execute setuid(0) and then perform privileged operations and revert back to its normal uid. ...
183
votes
8answers
138k views

Allow setuid on shell scripts

The setuid permission bit tells Linux to run a program with the effective user id of the owner instead of the executor: > cat setuid-test.c #include <stdio.h> #include <unistd.h> int ...
6
votes
2answers
3k views

Why is mount.cifs not installed suid by default?

I am using Gentoo, and on my machine at least mount.cifs is not installed suid root by default. In particular, this means that I can't use the user mount option with CIFS shares. I noticed that mount....
2
votes
2answers
135 views

suid executable not elevating permissions but `sudo` does elevate

I'm trying to write a program that will quickly shut down a laptop without prompting for a password or confirmation. The laptop is running Linux, specifically Manjaro. To that end, I'm trying to make ...
0
votes
0answers
45 views

Difference between SUID and user namespace

I was reading up on rootless containers which have the possibility to have unprivileged non-root containers where the parent process or tool that starts the application container itself runs as "non-...
0
votes
2answers
267 views

How to resolve sudo error in RHEL7

I am not able to use sudo, how to resolve this ? $ sudo vi /etc/fstab sudo: effective uid is not 0, is sudo installed setuid root?
1
vote
0answers
76 views

seteuid fails even when all UIDs are 0

I have some C++ code on a Linux machine whose purpose is to run some code as an arbitrary user. #include <sys/capability.h> #include <unistd.h> void doAsUser(uid_t uid) { if (...
0
votes
0answers
52 views

Applying special permission suid & sgid

I was in the processs of learning a bit about the special permission in Linux. Where is find certain anomilies. suid - For executable/files where user subsume the UID/permission of the owner. With ...
2
votes
1answer
62 views

ID inheritance – Which IDs?

I'm learning UNIX file permissions / ID inheritance and would like to clarify something: I have this list of permissions, users, groups and files: -rwxr-xr-x userA A foo -rw-rwsr-x userB B bar ...
2
votes
1answer
308 views

Is it possible to apply setuid only for a specific user?

As I understand, the setuid bit means that any user who can execute a file executes it as the file's owner. Is it possible, using ACLs or something, so that only a select list of users execute the ...
4
votes
3answers
5k views

what is the purpose of setuid enabled with no executable bit?

I am trying to understand permissions in detail. I was reading about setuid and it's uses. However, this particular case confuses me. I have made a small script and now I have set the suid bit for ...
7
votes
1answer
270 views

Root privileges can be restored after setuid(1000) in musl libc

musl libc allows you to change uid to root even after supposedly dropping permissions with setuid(1000). I am not able to reproduce the problem with glibc. Code: #define _GNU_SOURCE #include <...
1
vote
2answers
6k views

How are setuid, suid, sudo, and su all related? [duplicate]

I have a feeling the setuid bit, the nosuid mount option, sudo, and su are all related given their names. But how do they relate to one another? Are some of them used in conjunction? If they are not, ...
12
votes
5answers
12k views

How do I drop root privileges in shell scripts?

The "--up" option in OpenVPN is normally used for routing etc. And so it is processed before OpenVPN drops root privileges to run as nobody. However, I am invoking shell scripts that need to run as an ...
0
votes
1answer
64 views

How can I prevent a process to change its setuid bit back to RUID within the process itself

I set my SETUID bit to a non-root user so that the process should take the ownership of that executable file always. But I figured out setuid bit can be changed back to RUID within the script itself. ...
1
vote
2answers
521 views

why do we need the SUID permission? [closed]

Please read this long intro to understand my concern for why we need the SUID permission for executable binary file. A process in Linux uses its EUID to know the effective User ID of itself. This ...
11
votes
4answers
13k views

How do real and effective user IDs work?

When a normal user wants to make change to the passwd file, the user will by setuid be given the effective user access. User becomes root temporarily and can edit passwd. However you can only edit ...
0
votes
0answers
33 views

Always run script as root [duplicate]

I want to run a command automatically. The problem is that it may only be run after I logged in and that it requires superuser privileges. I've heard of suid before, so I thought I'd use it for this. ...
1
vote
1answer
102 views

Linux - why do the su and sudo binaries need to be set-UID root?

I am trying to find the correct reason for the stated question. My understanding is that: sudo needs to read the /etc/sudoers file which is only readable by root, which is why it needs to be set-UID ...
0
votes
1answer
401 views

Why can't unprivileged users nest FUSE mounts, but they can mount FUSE inside NFS with root_squash?

$ mkdir mnt $ bindfs /tmp mnt fusermount: option allow_other only allowed if 'user_allow_other' is set in /etc/fuse.conf $ bindfs --no-allow-other /tmp mnt $ mkdir /tmp/mnt2 $ bindfs --no-allow-...
2
votes
1answer
390 views

How does Magisk on Android work as su without setuid and capabilities?

I've read in another answer that on Android the su binaries avoid needing to be setuid by using filesystem capabilities like cap_setuid. But then I tried to check this, and to my surprise, I found no ...
0
votes
1answer
277 views

Adding suid to a binary file [duplicate]

My question is about suid! The logic behind that is to grant root permission when a privileged command is executed by a user. For example, passwd has such a feature. $ ls -l /usr/bin/passwd -rwsr-xr-...
24
votes
1answer
28k views

Difference between owner/root and RUID/EUID

I am relatively new to the concepts mentioned in the question and reading about them from different sources only makes them more confusing. So this is what I understood so far: When we are given ...
2
votes
2answers
2k views

kcheckpass error opening /var/log/faillog

I am seeing the following errors: $ journalctl -b -p3 -- Logs begin at Mon 2016-05-16 21:40:56 EDT, end at Wed 2016-07-27 22:30:13 EDT. -- Jul 27 22:22:26 x99 kcheckpass[5682]: pam_tally(kde:auth): ...
1
vote
0answers
69 views

Setuid program loses group memberships

I am upgrading an older SuSE-13.2 box to Leap-15. I have done a fresh Leap-15.0 install and ported over the source code that we ran on the 13.2 box. I builds fine but I am having an issue. The program ...
0
votes
1answer
395 views

Linux Setuid special permission flag with read/write

Does the setuid is only applicable for execute file(only applicable with executable flags) ? How it will affect other permission(read/write) of same file ! Eg:- If the the actual file permission is ...
2
votes
1answer
321 views

Does su always change ruid, euid and suid to the same user id?

Does su always change ruid, euid and suid to the same user id, or just some of them? I feel all of them, because the process which is executing su is always run with superuser privileges, and in ...
8
votes
4answers
4k views

Which user's password does `sudo` asks for?

$ ls -l /usr/bin/sudo -rwsr-xr-x 1 root root 136808 Jul 4 2017 /usr/bin/sudo so sudo is runnable by any user, and any user who runs sudo will have root as the effective user ID of the process ...
-2
votes
1answer
82 views

Is it ever meaningful that the owner of an executable file doesn't have the execution permission?

Assume an executable file has its set-user-id bit on. When a process executes the executable file, it changes its effective user ID to the owner user ID of the executable file, after the kernel ...
1
vote
0answers
185 views

Confused about using `setuid` on a FreeBSD mounted dataset to ensure all files/dirs have a fixed owner?

Initially I thought that what I'm trying to do was simple. But the more I look at FreeBSD man pages, the more confused I'm getting about whether it's even possible. I have a zfs pool that is used for ...
1
vote
0answers
122 views

setuid confusion, change owner of files created to particular user:group

I am trying to setup a directory /opt/www in such a way that when a user who belongs to the group django creates/modifies files and directorys within, they are set to owner django and group django. I ...
-1
votes
1answer
131 views

What tasks still require the suid bit on modern systems? [closed]

The setuid concept appears to become gradually obsolete, being replaced by proper permissions and authentication models in the few cases it is still in use. Examples: ping has been converted to use ...
6
votes
3answers
1k views

What exactly differentiates the root user from every other user?

What are the fundamental differences between some arbitrary account and root? Is it just the UID being something other than zero? So, what exactly does the su binary do and how does it elevate a user ...
1
vote
1answer
207 views

Why won't this example of setUID work? [duplicate]

I am learning about setuid and setgid where the user executing the script will inherit the owner's permission while running the script. To test this, I created a bash as user fiverr in /home/fiverr/...
1
vote
1answer
892 views

suid script not working correctly [duplicate]

My os is Fedora 24 and I tried to test the suid bit functionality. I wrote below bash as Setuid.bash: #!/bin/bash if [ $USER = 'root' ] then echo "Like Root Run" echo "Root User Add in " $(...
1
vote
3answers
699 views

why setuid is set instead of giving privileges to others

Assuming the normal user wants to update his password at /etc/passwd. Why it is preferable to set Setuid in a way such as -rws------ . I am assuming it works the same as if the other users will be ...
0
votes
1answer
9k views

sudo must be owned by uid 0 and have the setuid bit set

I have changed my ubuntu super password by recovery mode after that i can't run my sudo command in normal user i have attempted to crack my previous password in Recovery mode i followed this ...
1
vote
1answer
576 views

How does android implement run-as without setuid

Earlier versions of Android have at run-as executable with the setuid flag set so it runs as root, but more recent versions do away with that. What changed? How can the shell user effect a user change?...
3
votes
1answer
565 views

Do I need to set SUID when I run a script as `sudo`?

I need to run a script as root. The instructions given in the link say that I ought to: Set the SETUID bit on the script (i.e. chmod 4755). Run the script as sudo (i.e. sudo /path/to/thescript.sh) ...
0
votes
1answer
174 views

How to drop privilege of root user initiated process?

I would like to start JBoss process with root user, because I have to bind ports (<1024). But after initiating the process, I have to drop privilege of the initiated process. Is it possible? If ...
1
vote
1answer
352 views

Linux open() syscall and folder permissions

I have a process P which is spawned by a process owned by root. After P is created setguid() and setuid() are called and it runs as user U. The process P attempts to create a file f on a folder F (in ...
2
votes
0answers
78 views

modprobe in setuid contextmodprobe in setuid context

In CVE-2017-0358, author notes that The issue is that /sbin/modprobe is not designed to run in a setuid context. As the manpage of modprobe explicitly points out The MODPROBE_OPTIONS environment ...
3
votes
2answers
2k views

How to start (or find) a process with RUID different from EUID?

Inspired by one of the previously answered questions, I tried executing a program by a user who was not its owner -- and the process's RUID and EUID remained the same. (Unless I read the answer wrong ...
2
votes
1answer
224 views

how to run setuid task properly?

Assuming there is a php website and I want to block an ip at the firewall level based on the site code execution. The site is run under non-root user. I was going to pass IP from the site code to a ...
1
vote
1answer
329 views

How is PAM checking the user password in unprivileged processes?

PAM manages to check the user password, when called from unprivileged screen-lockers. E.g.: Password for GNU screen lockscreen command? https://github.com/google/xsecurelock I can't find any SUID-...
2
votes
3answers
3k views

SUID permissions - Which is correct?

Trying to secure a Linux server and have little experience with SUID. After executing find / -perm +4000 many programs were discovered. I have seen conflicting advice here and here on what should ...