Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
D

dive

> 安全
Open source

Start programs inside unshare/lxc namespaces easily using UNIX sockets + easy access to capabilities, namespaces, chroot and others.

54.6K stars0 likes6 views
WebsiteGitHub

About

Start programs inside unshare/lxc namespaces easily using UNIX sockets + easy access to capabilities, namespaces, chroot and others.

Start processes in other network/mount/whatever namespace, as created by unshare or lxc-start (as long as there is a shared filesytem between the host and container and you use recent enough Linux kernel). Also allow users execute programs in other user account or in chroot in controlled way (like sudo, but without setuid-bit in filesystem).

Works by sending file descriptors over UNIX socket.

See various usage examples and pre-built dive[d] versions at the github page.

Usage

…

Features

  • Absence of any filesystem permission tricks (no "chmod +s" required)
  • Secure preserving of user id and groups (requires root access)
  • Preserving of current directory
  • Preserving of all file descriptors (not only stdin/stdout/stderr)
  • Setting session ID and controlling terminal, for clean bash without "no job control" (requires root access)
  • Preserving of environment variables
  • Preserving of exit code
  • Selective disabling of "preserving" parts above
  • Chroot / CLONE_NEW... / forced command line
  • Setting of DIVE_USER and other variables according to client credentials
  • Allowing clients to set it's own root directory ("-r" option)
  • Setting of PR_SET_NO_NEW_PRIVS to turn off filesystem-based permission elevations. If you want just this without the rest dive features, use this: https://gist.github.com/vi/f977cc3097d47b07c3ad
  • Setting Linux capabilities, including ambient.
  • "Just execute" feature to use capabilities, chroot, PR_SET_NO_NEW_PRIVS setup; "authenticate", pidfile and so on without any "remote startup" thought socket at all
  • Joining namespaces with setns(2)
  • Setting resource limits with setrlimit(2)

For less feature-creep version see "nocreep" branch

Notes

  • For clean interactive shell access dived need to be started as root (for setsid/TIOCSCTTY)
    • Without TIOCSCTTY, use socat -,raw,echo=0 exec:bash,pty,setsid,stderr (there's a hint in dive's usage message) as the program to start to have nicer bash
    • With TIOCSCTTY it steams controlling terminal from the previous process (leaving it "homeless"), so "exec dive socket bash" is preferred (or workaround with reptyr >= v0.4 is needed).
  • Current directory can be "smuggled" into the chroot or unshare where that part of filesystem is not mounted (can be prevented using -W or -H options)
  • dived sets up groups for user, but it does not provide fully fledged PAM-like login. For example, resource limits are just inherited, not set up using /etc/security/limits.conf.

For pre-build versions of dive and dived see "Releases". Note that some of pre-built versions may lack features.

Process attributes

A table of what happens to various process attributes when process is started "remotely" over dive/dived compared to just execing directly. "not preserved" means "like in dived" or "whatever", "preserved" means "like in dive" or "like if we executed the program directly".

AttributeWhat happens

PIDnot preserved

parent PIDnot preserved

file descriptors preserved (unless -O)

resource limits not preserved

uid preserved if possible (unless -P or -u)

group list initialized by initgroups (unless -P or -u)

controlling terminal hopefully preserved (unless -T)

session id/process group not preserved, new session leader (unless -S)

namespaces memberships not preserved

cgroup membership not preserved

coredump_filter not preserved

current working directory preserved (unless -H)

/proc/.../exe not preserved

oom_score_adj not preserved

root directory not preserved (unless -r)

nice value/priority not preserved

CPU affinity not preserved

capabilities not preserved

umask preserved (unless -M)

Issues· 1 open

View all issuesOpen on GitHub
  • #6

    > duplicate the socket over the file descriptor when passing over Unix Socket

    Updated Sep 9, 2024

> Tags

Ccapabilitieschrootlinuxnamespaces

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 29, 2026
Category安全
PricingOpen source

> Related tools

O
OWASP ZAP
开源 Web 应用安全扫描器
O
owasp-wstg-tracker
Simple web app to track OWASP WSTG security testing progress
H
homebridge-mi-gateway-security
XiaoMi Gateway Security plugin for HomeBridge.