Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions .github/workflows/packages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,12 @@ jobs:
contents: read
outputs:
tag: ${{ steps.plan.outputs.tag }}
commit: ${{ steps.plan.outputs.commit }}
fedora: ${{ steps.plan.outputs.fedora }}
build: ${{ steps.plan.outputs.build }}
publish: ${{ steps.plan.outputs.publish }}
steps:
# All history: plan.sh checks that the tag is on origin/main.
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
Expand All @@ -89,8 +91,9 @@ jobs:
runs-on: ubuntu-latest
permissions:
contents: read
# Its output is signed as built, so it runs in publish's image.
container:
image: registry.fedoraproject.org/fedora:44
image: quay.io/fedora/fedora:44@sha256:6ad1739ac6fb30f72ecc7b62a7ca94871d1cab215e4f5174113941047e0b4ed4
steps:
- name: Install tools
run: dnf -y install git-core rpm-build
Expand All @@ -102,9 +105,12 @@ jobs:
- name: Build source RPMs
env:
TAG: ${{ needs.plan.outputs.tag }}
COMMIT: ${{ needs.plan.outputs.commit }}
run: |
git config --global --add safe.directory "$GITHUB_WORKSPACE"
packaging/make-srpm.sh out ${TAG:+"$TAG"}
# The plan job checked that COMMIT is on main; make-srpm.sh
# refuses a tag moved since then.
packaging/make-srpm.sh out ${TAG:+"$TAG" "$COMMIT"}
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: srpm-nm-sshuttle
Expand Down Expand Up @@ -166,8 +172,9 @@ jobs:
runs-on: ubuntu-latest
permissions:
contents: read
# Its output is signed as built, so it runs in publish's image.
container:
image: registry.fedoraproject.org/fedora:44
image: quay.io/fedora/fedora:44@sha256:6ad1739ac6fb30f72ecc7b62a7ca94871d1cab215e4f5174113941047e0b4ed4
steps:
- run: dnf -y install rpm-build
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
Expand Down Expand Up @@ -197,8 +204,10 @@ jobs:
environment: rpm-signing
permissions:
contents: read
# This job holds the signing key, so its image is pinned by digest.
# Refresh it as "Container images" in packaging/README.md says.
container:
image: registry.fedoraproject.org/fedora:44
image: quay.io/fedora/fedora:44@sha256:6ad1739ac6fb30f72ecc7b62a7ca94871d1cab215e4f5174113941047e0b4ed4
steps:
- run: dnf -y install createrepo_c findutils gnupg2 jq python3-rpm rpm-sign
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
Expand Down Expand Up @@ -255,8 +264,9 @@ jobs:
runs-on: ubuntu-latest
permissions:
contents: read
# publish's image, so that a pull request with a new digest tries it.
container:
image: registry.fedoraproject.org/fedora:44
image: quay.io/fedora/fedora:44@sha256:6ad1739ac6fb30f72ecc7b62a7ca94871d1cab215e4f5174113941047e0b4ed4
steps:
- run: dnf -y install createrepo_c findutils gnupg2 jq python3-rpm rpm-build rpm-sign
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ name: release
# Puts a tagged release into the package repository. The repository is
# published from main, the only branch that may use the signing key, so this
# workflow starts the packages workflow there instead of publishing itself.
# Pre-releases (a tag with a hyphen, such as v1.0.0-rc.1) are not packaged.
# That workflow packages the tag only if it names a commit on main
# (packaging/plan.sh). Pre-releases (a tag with a hyphen, such as
# v1.0.0-rc.1) are not packaged.

on:
push:
Expand Down
95 changes: 95 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,100 @@ All notable changes to nm-sshuttle are listed here. The format follows
[Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and the project
uses [semantic versioning](https://semver.org/).

## [Unreleased]

### Security

- The packages workflow packages and signs a release tag only if it names
a commit on `main`, and the source RPM job refuses a tag moved after that
check. Before, any `vX.Y.Z` tag, pushed or given to a hand-started run,
was built from whatever commit it named and signed with the project's
key. `scripts/signing-key.sh` now restricts the `github-pages`
environment to `main` too, and `--restrict` restricts both environments
again (packaging/README.md).
- The install steps download the signing key file and show its keys with
`gpg --show-keys`, to compare with the fingerprints in the README on
GitHub before `rpm --import`, and install the repository package with
`localpkg_gpgcheck=1`, so that dnf checks its signature against that key.
The key, the repository package and the fingerprint on the site all come
from the same site, so the site alone proved nothing, and dnf did not
check the repository package at all. The README and the site show
fingerprints as gpg prints them.
- The packages workflow's `publish` job, which holds the signing key, runs
in a Fedora image pinned by digest instead of the `fedora:44` tag, and so
do the `srpm` and `release-rpm` jobs, whose output it signs as built.
- A profile address or network with an IPv6 scope id (`fe80::%eth0/64`) is
refused. The scope is free text that `ipaddress` keeps, and a crafted one in
`subnets`, `exclude` or `gateway` reached the root `nft` script, where an
`include` made root read a file in `/etc` and log its first lines. The guard's set
elements are now written from each network's number, and a failed guard
logs only nft's error line.
- The `remote` destination is checked as sshuttle splits it, in the plugin and
in the GNOME editor: an empty user or host (`@`, `@corp`), a host that starts
with `-` (`@-gD1080`), a password (`user:password@host`, which ended up in
sshuttle's command line and the journal) and a bad port are refused.
- The sweep and the health check count only root's listeners on `127.0.0.1`
or `::1` (or the wildcard address). Any user's listener on the port of a
table that a killed sshuttle left behind kept the table, and with it the
redirect of the tunnelled traffic and DNS to that user's socket, past the
guard; such a table is now removed at the next sweep, with a warning
that names the user. A user's listener still counts while sshuttle's
root firewall helper runs below it, as for an sshuttle the user runs in
the foreground; one run with `--daemon`, or a root one listening on a
LAN address, now loses its tables at the plugin's sweeps. The health
check no longer falls back to every listener when it cannot find the
tunnel unit's cgroup; it now also finds it on hybrid and legacy cgroup
hosts, and gives up once, instead of reconnecting every 10 s, where
there is none. `check` warns about that.
- sshuttle listens on an IPv4 port from 225 to 240, which only root may
bind: its slot's own two first, then a free one of the others. Any user
could hold sshuttle's ports from 12300 down and stop every tunnel from
starting. The IPv6 and DNS ports are still sshuttle's choice, so a user
can still block those, or bind them in the moment between sshuttle's
exit and the sweep: this is only partly fixed for profiles with DNS or
IPv6. The plugin now says when sshuttle found no free DNS or IPv6 port.
`check` warns when `ip_unprivileged_port_start` lets users bind the new
ports.
- The plugin answers `VPN.Plugin` calls only from NetworkManager.
- A profile with `dns split` or `all` is refused unless NetworkManager uses
systemd-resolved and `/etc/resolv.conf` sends every lookup to its stub;
otherwise lookups fell back to the local network's resolver during
reconnects. `check` reports it.
- A guard removed during a reconnect is put back within 10 s, and before
each attempt; before, only the health check while up did.
- A claim counts only for the process with the start time it recorded,
not any process that has the PID and `nm-sshuttle-service` in its command
line. A claim from the previous version needs that process to run with
every user ID 0.
- The first hop's addresses from a lookup on the local network no longer
decide alone what bypasses the tunnel and the guard. One that lies in the
profile's networks or DNS servers is ignored, with a warning, unless
`exclude` covers it, and at most 8 are used; with none left the
activation fails. A forged DNS answer could take any internal address
out of the tunnel while the VPN showed connected. A jump host reached by
name inside the tunnelled networks now needs `gateway` or `exclude`; this
includes every profile that tunnels `0.0.0.0/0` or `::/0`, where a jump
host with a changing address, such as a dynamic DNS name, no longer
works. A `HostName` or remote that is an address is not looked up and
works as before. While addresses are ignored, ssh is pinned to a kept
one, and a failed start names the ignored ones. `check` reports it.
- sshuttle gets `127.0.0.1` as its remote, and the ssh bridge gives ssh
the profile's remote. sshuttle 2.0.0 looked the remote up itself, as
root and on the local network, also with `gateway` set, and excluded
every address it got.
- The tunnel unit has `/etc` read-only, so sshuttle's root firewall helper
cannot write `/etc/hosts`; nm-sshuttle never passes `--auto-hosts`.
`cleanup` removes the lines a stopped sshuttle left in `/etc/hosts`.
- The systemd units have a sandbox (design §4.7). All three keep the kernel
tunables and cgroups read-only, lock the personality, and refuse realtime
scheduling and new setuid files. The tunnel unit adds a read-only
`/usr` and `/etc` and a capability bounding set; the plugin unit and the
dispatcher a read-only `/usr`, and the dispatcher also a read-only
`/home`, a private `/tmp` and fewer socket families and namespaces.
- The user's `ssh -G` for the first hop, and anything their ssh config runs
from it, no longer inherit the plugin unit's `OOMScoreAdjust=-500`: the
bridge sets 0, which also resets the floor, before it drops to the user.

## [0.1.0] - 2026-10-11

The first release.
Expand Down Expand Up @@ -45,4 +139,5 @@ The first release.
- There is no Debian or Ubuntu package repository; take the `.deb` files
from a CI run.

[Unreleased]: https://github.com/dennisklein/nm-sshuttle/compare/v0.1.0...HEAD
[0.1.0]: https://github.com/dennisklein/nm-sshuttle/releases/tag/v0.1.0
36 changes: 26 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,28 @@ hosts where WireGuard is not an option.
## Install

Fedora 43 and 44 can install from the signed package repository, which also
brings updates:
brings updates. Packages and repository metadata are signed with a key from
[`RPM-GPG-KEY-nm-sshuttle`](packaging/nm-sshuttle-release/RPM-GPG-KEY-nm-sshuttle),
which holds the keys with these fingerprints:

```console
$ sudo rpm --import https://dennisklein.github.io/nm-sshuttle/RPM-GPG-KEY-nm-sshuttle
$ sudo dnf install https://dennisklein.github.io/nm-sshuttle/nm-sshuttle-release.noarch.rpm
$ sudo dnf install nm-sshuttle nm-sshuttle-gnome
```
62D450232396EDB49BFF8E71109A2C1BD34D4A1C
```

Packages and repository metadata are signed with this key
([`RPM-GPG-KEY-nm-sshuttle`](packaging/nm-sshuttle-release/RPM-GPG-KEY-nm-sshuttle)),
fingerprint:
Download the key file, and import it only if `gpg --show-keys` shows each
fingerprint listed here and no other key, and reports no error (install
`gnupg2` if `gpg` is missing). The site serves the key file and the
repository package together, so compare with this page on GitHub, not with
the site. Then install the repository package with its
signature checked, which dnf skips for a package named on the command line
unless told otherwise:

```
62D4 5023 2396 EDB4 9BFF 8E71 109A 2C1B D34D 4A1C
```console
$ curl -fsSLO https://dennisklein.github.io/nm-sshuttle/RPM-GPG-KEY-nm-sshuttle
$ gpg --show-keys RPM-GPG-KEY-nm-sshuttle
$ sudo rpm --import RPM-GPG-KEY-nm-sshuttle
$ sudo dnf install --setopt=localpkg_gpgcheck=1 https://dennisklein.github.io/nm-sshuttle/nm-sshuttle-release.noarch.rpm
$ sudo dnf install nm-sshuttle nm-sshuttle-gnome
```

`nm-sshuttle-gnome` adds sshuttle to GNOME Settings' VPN list; leave it out
Expand Down Expand Up @@ -129,6 +137,14 @@ $ nm-sshuttle add lab --remote lab --subnets 10.50.0.0/16
connects to first, so name it, and the tunnel will not swallow it:
`--gateway 203.0.113.7`.

**A jump host inside the tunnelled networks.** The plugin ignores an
address of the jump host that it looked up and that lies in `--subnets`,
since a forged DNS answer could otherwise take internal addresses out of
the tunnel. Name it: `--gateway 10.0.0.5`, `--exclude 10.0.0.5`, or
`HostName 10.0.0.5` in `~/.ssh/config`. A jump host with a changing
address, such as a dynamic DNS name, therefore does not work with a
profile that tunnels `0.0.0.0/0` or `::/0`.

**Notice a stuck tunnel.** `--probe 10.1.0.10:22` makes the plugin connect
to a server on the far side that speaks first, such as an ssh server, every
10 seconds, and restart the tunnel after two failures.
Expand Down
13 changes: 13 additions & 0 deletions data/nm-sshuttle-dispatcher.service.in
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,16 @@ Type=dbus
BusName=org.freedesktop.NetworkManager.sshuttle.Dispatcher
ExecStart=@LIBEXECDIR@/nm-sshuttle-dispatcher
Restart=no
# Sandbox (design §4.7). It runs nothing as the user. /etc stays writable for
# the cleanup after a single-tunnel version; no capability bounding set, as
# it starts units through systemd's D-Bus API.
ProtectSystem=true
ProtectHome=read-only
PrivateTmp=yes
ProtectKernelTunables=yes
ProtectControlGroups=yes
RestrictAddressFamilies=AF_UNIX AF_NETLINK AF_INET AF_INET6
RestrictNamespaces=yes
LockPersonality=yes
RestrictRealtime=yes
RestrictSUIDSGID=yes
17 changes: 17 additions & 0 deletions data/nm-sshuttle-tunnel@.service.in
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,20 @@ Restart=no
# retry after an unlock waits up to 110 s for the agent's prompt (design §4.3).
TimeoutStartSec=120
TimeoutStopSec=15
# Sandbox (design §4.7). The user's ssh runs here too, with whatever the
# user's ssh config runs: it must still read ~/.ssh, write known_hosts, reach
# the agent in /run/user and run setuid helpers such as ssh-keysign. So no
# NoNewPrivileges, ProtectHome, PrivateTmp, PrivateDevices,
# RestrictAddressFamilies or the others that design §4.7 lists.
# /usr and /etc read-only, so that sshuttle's root firewall helper cannot
# write /etc/hosts (design §4.8).
ProtectSystem=full
ProtectKernelTunables=yes
ProtectControlGroups=yes
LockPersonality=yes
RestrictRealtime=yes
RestrictSUIDSGID=yes
# nft, iptables and tproxy; the redirect ports below 1024; setpriv; signals
# to the user's ssh; the sweep, which reads other users' /proc/PID/fd; and
# modprobe, which iptables-legacy runs itself (design §4.7).
CapabilityBoundingSet=CAP_NET_ADMIN CAP_NET_RAW CAP_NET_BIND_SERVICE CAP_SETUID CAP_SETGID CAP_KILL CAP_DAC_READ_SEARCH CAP_SYS_PTRACE CAP_SYS_MODULE
16 changes: 14 additions & 2 deletions data/nm-sshuttle@.service.in
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ Type=notify
NotifyAccess=main
ExecStart=@LIBEXECDIR@/nm-sshuttle-service --slot %i
# After a stop, a kill or a crash: stop this slot's tunnel unit, remove its
# link, guard and stale sshuttle tables. NetworkManager never removes the link
# itself (design §4.4, §4.7).
# link, guard and stale sshuttle tables, and sshuttle's lines in /etc/hosts.
# NetworkManager never removes the link itself (design §4.4, §4.7, §4.8).
ExecStopPost=@LIBEXECDIR@/nm-sshuttle cleanup --slot %i
# The plugin owns the restart policy; a restart under an active VPN would
# leave NetworkManager's DNS entry behind.
Expand All @@ -20,3 +20,15 @@ OOMScoreAdjust=-500
# On SIGTERM the plugin gives up first and waits up to 1 s for
# NetworkManager's Disconnect; it exits within 5 s whatever happens.
TimeoutStopSec=20
# Sandbox (design §4.7). The first hop's ssh -G runs here as the user, and
# with it the user's Match exec, so no NoNewPrivileges, ProtectHome or
# PrivateTmp. /etc stays writable: cleanup removes what sshuttle left in
# /etc/hosts. No capability bounding set: starting units through systemd's
# D-Bus API takes CAP_SYS_ADMIN unless polkit is asked, and ssh-as-user needs
# CAP_SYS_RESOURCE to take the user's processes off OOMScoreAdjust's floor.
ProtectSystem=true
ProtectKernelTunables=yes
ProtectControlGroups=yes
LockPersonality=yes
RestrictRealtime=yes
RestrictSUIDSGID=yes
4 changes: 2 additions & 2 deletions debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ Description: NetworkManager VPN plugin that tunnels with sshuttle
brought up, supervised and torn down by a small root service. ssh runs as the
logged-in user, so the user's keys, agent and ~/.ssh/config apply.
.
The design needs systemd-resolved for per-link DNS; without it the DNS
settings of a profile degrade to "every lookup goes to the VPN's servers".
The design needs systemd-resolved for per-link DNS; without it a profile
that sets DNS (dns=split or dns=all) is refused at connect.

Package: nm-sshuttle-gnome
Architecture: any
Expand Down
Loading
Loading