Giter Site home page Giter Site logo

oneway's Introduction

Oneway - a tool to drop privileges for docker entry-points

Introduction

If you want to drop privileges (as in Docker entry-points) but you don't want your process to be child process of su or sudo process.

Unlike su or sudo this tool would exec to replace the current process (so it would receive signals ..etc.)

This tool can also set special process flags so disallow any future privileges

This process simply calls

  • setgid to desired group
  • setgroups to set supplementary groups to only desired group
  • setuid to desired user
  • prctl with PR_SET_NO_NEW_PRIVS if -n is passed to disallow future privileges

Usage

oneway [-n|-N] USER COMMAND ARGUMENTS...
  • -n no new privileges by setting PR_SET_NO_NEW_PRIVS with prctl
  • -N allow new privileges ex. via su, sudo, setuid flag

we have a test.sh which display id then it pings google (which is a suid binary)

./oneway -n alsadi ./test.sh

typically this would give

setting uid=1000 (alsadi) gid=1000
uid=1000(alsadi) gid=1000(alsadi) groups=1000(alsadi),10(wheel),135(mock),973(wireshark) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
ping: socket: Operation not permitted
ping: socket: Operation not permitted

Installation

To build it you only need gcc

yum install gcc glibc-static
make

You can get binaries directly from our github releases

Docker usage

In your Dockerfile you might use Yelp's dumb-init

ENTRYPOINT [ "/usr/local/bin/dumb-init", "/start.sh" ]

and in your start.sh

# do things as root
chown ...
chmod ...
# run some daemons as root
nohup /usr/local/bin/confd -watch ... >> /data/logs/out.log
# run some daemons as user app
exec oneway -n app /app.sh

FAQ

  • Q: Why is the benitift of this?
    • drop priviligies in "oneway" manner.
  • Q: What is the advantage over su / sudo
    • they do not drop priviligies they change user.
    • oneway make use of kernel PR_SET_NO_NEW_PRIVS
    • with su / sudo one might be able to escelate (ex. using setuid binaries)

oneway's People

Contributors

bardurarantsson avatar muayyad-alsadi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

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.