Questions tagged [setuid]
The setuid tag has no usage guidance.
183
questions
-1
votes
1
answer
39
views
passwd source code
I am trying to look at the source code of the passwd and gpasswd programs. These tools check the effective UID set to zero to complete execution successfully. But I am a noob to C and couldn't find ...
10
votes
2
answers
1k
views
Source of passwd error messages
I am testing if the passwd command could run if the setuid bit is disabled. I disabled the setuid by running the following command:
chmod 0554 /bin/passwd
After doing so, I tested if the passwd ...
1
vote
1
answer
42
views
Is appropriate to use setuid() over setresuid()/setreuid()/seteuid()?
I have an executable binary which was compiled from a C source file
The executable has the setuid permission on
I noticed that, if the owner of the executable is root, I can use
setuid(geteuid());
...
0
votes
0
answers
29
views
debugger as a tool to get to root shell
according to the answer in the reference:
Can gdb debug suid root programs?
Claims that:
"You can only debug a setuid or setgid program if the debugger is running as root. The kernel won't let ...
0
votes
0
answers
19
views
Minimal "setuid" demo not working as documented? [duplicate]
Context
The setuid utility, according to both Unix and FreeBSD documentation, allows a process to run with an effective permission level of the executable file, instead of the real permission of the ...
1
vote
2
answers
80
views
Why I can't set the setuid for "others"?
I can't set other's setuid bit. Why? Is there some security lock?
$ ls -l
-rwxrwxr-x 1 allexj allexj 16784 Mar 11 17:30 a....
2
votes
1
answer
83
views
Why "permission denied" when running `less` with chmod 6110?
Assume you are user x, so running id gives
uid=1001(x) gid=1001(x) groups=1001(x)
And there is also a user y with
uid=1002(y) gid=1002(y) groups=1002(y)
Now as root we create a file readme in user's ...
0
votes
1
answer
28
views
What are the effective permissions if a setuid program is executed via sudo?
I have read many questions and answers about how the setuid bit works and about how sudo works, and I think I have understood that stuff.
However, I couldn't find out what should happen when a program ...
0
votes
1
answer
50
views
Not able to assign root privilege to my process again by using setuid(0) in the same boot cycle
I have added the capability by using following cmd on terminal (alternative of setting CAP_SETUID in drop-in file). Verified that setuid/seteuid is working.
setcap cap_sys_admin,cap_setuid+ep /...
0
votes
1
answer
77
views
Why don't I find ping process in ps list?
Why can't I see the 'ping' process in my 'ps' listing when I started it as a regular user?
The ping binary has setuid bit,
ls -l /bin/ping
-rwsr-xr-x 1 root root 64424 jun 28 2019 /bin/ping
Running ...
0
votes
2
answers
260
views
How to explain all details with 'ls' command on freebsd and what color means?
I am trying to clone directory with cp command and meeting some attributes lost. For example, when I am trying to run sudo command from copied tree, it gives error.
sudo: /usr/bin/sudo must be owned ...
0
votes
1
answer
40
views
Why is a find process getting started by checksecurity in Debian and how to disable it if it's not useful?
With sudo lsof | grep mounted-drive-name I found that a find process is running on one of my hard drives which I'd like to spare.
With KDE's system monitor it shows me that it was started by anacron-&...
2
votes
2
answers
180
views
What does `ln /path/to/file -i` do in a setuid'ed script?
I was making a Bash script with the setuid permission on, but it didn't work. So I found my solution here:
Why does setuid not work? and
Allow setuid on shell scripts
Now my script works fine and ...
0
votes
0
answers
35
views
setuid not allowing me to run script as root? [duplicate]
I wrote this tiny script:
#!/usr/bin/env -S bash -xeuo pipefail
whoami
cd /repo && git fetch origin master && git merge -s recursive -X theirs origin/master
And set the u+s bit which ...
0
votes
0
answers
25
views
setuid doesn't work in /tmp [duplicate]
I wrote a C program, expecting to see the difference between uid and euid with setuid bit enabled:
#include <unistd.h>
#include <stdio.h>
int
main(void) {
printf("euid: %d\n"...
1
vote
1
answer
137
views
Allow file read only through application
I have a file with a secret and a generator application that reads it and generates something similar to a license.
There are users on that Linux machine who are allow to use that application.
Because ...
2
votes
1
answer
1k
views
Why ping works without capability and setuid [duplicate]
I learned from here that there's 2 ways to control privileged activities: setuid and capability.
But when I'm playing around with ping on my machine, it seems that it can bypass these 2 mechanism.
...
-3
votes
2
answers
250
views
How to access/set other user's environment variables after setregid() and setreuid() in C
I have a privileged C program that is executed by a standard user (say stduser) and on execution switches to a system user (say sysuser) as follows. Basically, I am trying to do something similar to ...
2
votes
1
answer
2k
views
what is utempter, and why does xterm want to use it?
when I start xterm, it tries to start a binary:
/usr/lib/x86_64-linux-gnu/utempter/utempter
I could not find any info as to what this binary is for.
man utempter has no entry, and searching the web ...
0
votes
1
answer
61
views
How can I tell if a SRPM package will have components which will run as root?
Some packages install software which needs to run with root privileges, such as the sudo package. Others, such as vim, do not inherently need to run with root privileges.
Is there a generic way to ...
1
vote
0
answers
90
views
setuid not working as expected in Pop!_OS
So I was trying to experiment with setuid. As per my understanding it allows users to run the binary with context of the owner.
So I wrote a program in C which does write operation in /root directory ...
15
votes
2
answers
2k
views
How does ping work on Fedora without setuid and capabilities?
As far as I know, ping needs to create a raw socket (which needs either root access or cap_net_raw capabilities).
From my understanding the trend these last years has been to remove setuid binaries ...
0
votes
1
answer
243
views
script with suid set but not working! [duplicate]
I have a simple script that runs fine under an app ID (just touches a new file), which I am trying to get to call via my personal ID. Note the target file location is in an area that my personal ID ...
-1
votes
2
answers
483
views
Which one is safer? sudo dnf update OR su - ; dnf update
Is it safer to do:
$ sudo dnf update [enter user password]
or
$ su - [enter root password]
# dnf update
I always assumed they are the exact same thing, because sudo utilizes setuid-root, so the ...
1
vote
1
answer
208
views
Common binaries with support for command execution, like `awk` and `vim`, not respecting setuid bit?
I'm hardening a Linux system and wanted to test (setuid-based) shell escapes using common binaries, like awk, vim, etc., supporting command executing.
However, all binaries I've tested except sh and ...
0
votes
1
answer
200
views
How do I make sure sudo is setuid in repackaged squashfs?
I'm trying to manipulate a squashfs file, containing a yocto build and an application payload, but everytime I do so, sudo fails to execute afterwards. root user is disabled, so I have no real ...
0
votes
0
answers
93
views
How can a malicious seccomp filter cause an attempt to use `setuid(2)` to return 0, without actually making the system call?
I was reading the documentation on seccomp(2) on my Debian system, and stumbled upon the following sentence from the paragraph below:
Such a malicious filter might, for example, cause an ...
0
votes
0
answers
49
views
Can the process read the file? SetUID privilege collision
User A executes a setuid program owned by user B. the program wants to read a file in /etc/data, that is only readable by A and no one else. Can the program read the file?
And then I have another ...
1
vote
1
answer
417
views
setuid not working [duplicate]
I was trying to learn how setuid works.
So I made a dummy program which just prints the current user:
#include<bits/stdc++.h>
using namespace std;
int main(){
cout << system("id -...
0
votes
1
answer
447
views
Normal user run Qt C++ program as root without sudo?
I am writing a robotics program in C++, using Qt for the GUI, where each thread needs access to hardware. The library which accesses the hardware is called pigpio, and it modifies /dev/mem, so it ...
8
votes
1
answer
1k
views
Nano able to read on write-only access file
User has write-only permissions on a file, unable to cat or vi but is able to nano normally. How is this possible?
I was wondering what happens if you only have write-access on a file and this was ...
0
votes
1
answer
153
views
Why can't I setuid binaries like apt?
During all my education I've been taught that the setuid would allow anyone that has the execution privilege on a file to run it as the owner. However it seems that I'm not able to setuid a binary and ...
5
votes
2
answers
2k
views
Questions about the saved user ID
As far as I understood the different user IDs are as follows (from the perspective of a process):
real user ID: the user ID that owns the process
effective user ID: the user ID which determines what ...
2
votes
1
answer
2k
views
Why doesn't setuid() work with non-root users?
I'm experiencing a weird behavior regarding setuid() and the setuid bit.
It seems like the suid bit and setuid() do not work as expected. I am expecting for a binary with +s and owned by uid 1001 ...
1
vote
1
answer
445
views
How to implement setuid bit? [duplicate]
I created a small script as the root user...
#!/bin/bash
cat /etc/shadow
and set the setuid bit and placed it within the guest folder. When I ran the script as guest, it showed permission denied. ...
0
votes
1
answer
2k
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>
...
9
votes
2
answers
2k
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
1
answer
47
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
2
answers
931
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
0
answers
159
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
0
answers
317
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
1
answer
170
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
2
answers
559
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 ...
4
votes
1
answer
2k
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
1
answer
353
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
1
answer
571
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 <...
2
votes
2
answers
2k
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 ...
6
votes
3
answers
2k
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
0
answers
202
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
1
answer
496
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 ...