Questions tagged [setuid]

The tag has no usage guidance.

8
votes
2answers
661 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
32 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 ...
0
votes
0answers
42 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
205 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?
0
votes
0answers
39 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 ...
1
vote
0answers
65 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 (...
2
votes
1answer
57 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
2answers
100 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 ...
2
votes
1answer
242 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 ...
0
votes
1answer
54 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. ...
7
votes
1answer
230 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
429 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 ...
3
votes
1answer
319 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 ...
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
80 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
345 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
342 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
232 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-...
1
vote
0answers
66 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
368 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
272 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
3k 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
81 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
177 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
110 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
123 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 ...
0
votes
1answer
8k 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
3answers
643 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 ...
1
vote
1answer
488 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
504 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
140 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
329 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
72 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 ...
1
vote
3answers
7k 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. ...
2
votes
1answer
214 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
300 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-...
0
votes
0answers
261 views

SETUID and SETGID Behavior

The setup: ~$ ls -l /etc/sudoers -r--r----- 1 root root 614 2017-09-10 20:29 /etc/sudoers ~$ ls -l /etc/shadow -rw-r----- 1 root shadow 794 2011-04-18 11:49 /etc/shadow $ ls -l $(which ht) -rwsr-sr-...
0
votes
2answers
2k views

Can bash run with uid 0 and different euid?

I was writing some bash code and I wanted to check if the script had root privileges. All of the code I see from other people only checks for $EUID == 0. It is perfectly possible to have other ...
1
vote
4answers
83 views

How to securely sanitize permissions for a subtree

On our server, there are multiple (currently two, expected three or four) users allowed to deploy a new version of our application. This process consists of downloading a few files from a trusted ...
7
votes
1answer
3k views

Why does ping need setuid permission? [duplicate]

I'm looking at a handful of files on my system with setuid permission on my system, by running: sudo find / -perm -4000 I noticed that /bin/ping shows up on the list. Can anyone explain why ping ...
6
votes
1answer
469 views

Does the noexec mount option imply nosuid?

Many guides on the internet recommend setting the nosuid and noexec options, for example on the /tmp mount point. But doesn't noexec imply nosuid? What cannot get executed cannot make use of the suid ...
3
votes
2answers
1k views

setuid root does not work

Objective : Run a program as root (C++ binary). The same as : SetUID bit not working in Ubuntu? And : Why setuid does not work on executable? ./a.out output: E: Could not open lock file /var/lib/...
2
votes
1answer
788 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 " $(...
2
votes
1answer
856 views

Debug a setuid binary as non-root

I have a CentOS 7 system. I need to attach my GDB to an already running application, but get the (apparently usual) "ptrace: Operation not permitted." error. Running GDB as root prevents the error, ...
3
votes
2answers
215 views

How to get users to set ACLs on directories they don't own?

I have a set of storage directories on Linux machines, all 770/root:root (perms/owner:group), for which I use ACLs to manage users access. (I am unable to use unix groups as the directories are shared ...
7
votes
3answers
4k views

SetUID bit not working in Ubuntu?

I suppose an executable file with SetUID bit set should be running as its owner but I cannot really reproduce it. I tried the following. $ cat prepare.sh cp /bin/bash . chown root.root bash chmod ...
1
vote
1answer
161 views

python program running as root to open urls via normal user

I have a python program that runs as root one if its functions at the click of a button is to open a webpage. It kept opening the webpage in firefox as root so I try to use setuid with no avail. Here'...
2
votes
1answer
54 views

How to let user A delete B's file on behalf of B?

A and B are both non-root users in a same group. Suppose there will be some B owned garbage files generated inside a directory(also generated and owned by B) after a regression run by B, but I need A ...
1
vote
0answers
1k views

Python process can't create a file in a directory, keeps getting `permission denied` IOError

I've a directory mnt with 777 permissions: drwxrwxrwx 2 root root 14336 Feb 5 15:52 mnt I've created a bunch of users in the group root from uid to 5204 to 5250. I've a python script that ...
3
votes
1answer
207 views

suid executibles work only when present in the system PATH

I have an executible which requires root privilages. But it seems to work only when it's present in the system path. When I execute it like this: $ ./prog The program complains of having no root ...