Research: how mesh SSH takes port 22 (userspace vs kernel redirect) and identifies users #162
Closed
opened 2026-10-11 06:59:12 +00:00 by kayg
·
11 comments
No Branch/Tag specified
main
j470b-server-mesh-rejoin
mesh-compat-382
j444b-d381-key-wins-flood
j461b-macos-utun-reader-thread
j475b-remove-host-motion
fix-reconnect-new-link
j481-d380
dev
j479-mesh-soak
fix/j476-host-facts
j475-motion-pill-split
j470-mac-node-join
root-upgrade-d376
j474-review-merge
latency-targets-120hz
nightly-suite-shards
gotatun-pin-j469
macos-utun-reader-thread
fix-flood-echo-stall
wip/j416
motion-fast-ease-out
mesh-addhost-j259
takeover-close-terminals-d368
kbd-instant-followups
fix-trust-key-double-click
nightly-suite-partial-report
appwin-icons-j207
rusqlite-slice1
swipe-content-first-d374
mesh-mtu-381
addhost-instant-open
glass-contrast-d365-mock
glass-contrast-d365
signout-followups-442
fix-startup-toast-red
research-gotatun-matrix-j317
themes-sync-j304
fix-load-flakes
fix-nix-zig-patch
fix-compute01-browser-baseline
ratchet-size-baseline-419
predict-auto-d130
revoke-coverage-d367
nightly-suite-queue-timeout
nightly-browser-suite
fix-rustsec-2026-0459
fonts-ioskeley-obel
log-retention-d375
fix-kbd-no-anim-427
fix-dev-red-specs-2
takeover-proof-305-j205
wip/j410-server-pump
ui-consistency-d372
fix-osc52-clipboard
libghostty-vt-1.0
forget-retired-host-d369
j404-merge-426
fix-setup-lock-race
fix-touch-select-426
revoke-access-report-ui
fix-predictive-echo-specs
fix-selinux-agent-exec
wip/j395-checkpoint2
wip/j395
j391-review-scratch
ui-consistency-j195-deferred-rebased
fix-rustc-paths-421
decisions-wording-341
fix-install-suite-red
fix-dev-rtt-specs
fix-pending-removal-align
fix-privileged-skip
fix-install-suite-404
review-j368
mesh-dns-j254
revoke-access-report-d356b
revoke-privilege-round5
fix-removal-confirm
review-j360
gotatun-rotation-367
deps-refresh-340
review-j354
review-J351
review-j350
addhost-takeover-d359
revoke-report-items-347
revoke-end-sessions-d362
review-j348
size-mesh-ssh-346
size-trim-337
revoke-access-diff-d356
j259-pre-rebase-b06c5a6
j305-ended-at-start-spec
addhost-sudo-consent
fix-layout-real-specs-411
fix-shell-open-411
fix-console-hosts-373
fix-shell-exit
fuzz-host-name-353
fix-host-details-410
macos-filter-j197
research-gotatun-tricks
revoke-p3-j216l
stale-state-pill
revoke-followups-j216k
revoke-progress-j216e
backup/macos01-20261106/lume/j197
backup/macos01-20261106/lume/appwin-icons-j207-stash0
backup/macos01-20261106/claude/stash-0
backup/macos01-20261106/claude/stash-1
backup/macos01-20261106/claude/J80-macos-s1
backup/macos01-20261106/claude/J80
backup/macos01-20261106/claude/J80-slice1-20261102
backup/macos01-20261106/claude/J16b-appwin-on-dev
backup/macos01-20261106/claude/appwin-launch-idle-146
backup/macos01-20261106/claude/J80-s1-run
wip/j259
trust-285-p3c
runtime-lock-j216f
mesh-ssh-p3-j175
tun-proof-p3b
trust-285-p3
terminal-polish-j271
tun-proof-p3
ssh-install-flakes-j216i
fuzz-fixes-j264
trust-285-a
trust-285-b
restart-oversized-fixture-j198
backup/macos01-20261106/lume/appwin-icons-j207
restart-bound-j216h
up-preflight-p3-j198
backup/macos01-20261106/lume/j251
up-preflight-j198
wip/up-preflight-j198-j245-p2
wip/up-preflight-j198-j245-p1
agent-fsync-offloop-j196
wip/up-preflight-j198-j245
settings-offscreen-j231
wip/up-preflight-j198-j226-inspection
wip/j103f
themes-j206
wip/up-preflight-j198-j226
flakes-j216c
backup/macos01-20261106/claude/j197
flakes-j216b
backup/macos01-20261106/claude/j197-red
wip/up-preflight-j198-review
flakes-j216
backup/macos01-20261106/claude/appwin-icons-j207
engineering-j208b
appwin-mock-j209
toast-stack-j165
engineering-j208
decisions-d351
decisions-d350
decisions-d349
appearance-presets-mock-j129
decisions-d348
docs-audit-spec
doc-coverage-baseline-raise
decisions-d347
decisions-d346b
decisions-d346
j88h-profile
ui-consistency-j195-deferred
ui-consistency-j195
engineering-practices-j194
preferred-login-ui-j166
signin-pools-263-j174
macos-node-265-s1
decisions-d345
decisions-d344
proxy-cgroup-j164
verify-quick-fuzz-329
proxy-start-io-j168
timing-flakes-j163
up-263-s1
mcp-events-j147
verify-quick-fuzz-j158
proxy-p3-j159
agent-resource-j157-detect
wip/j103d-final
remote-cancel-hang-j155
proxy-traefik-281-j62d
j149-verify-quick
proxy-traefik-281-j62b
j150-drop-unnamed
wip/j79d-red-r4
wip/j103d-d332
rootless-toast-j142
wip/j103d-head
wip/j103d
j125c-mcp
macos-build-j136
backup/macos01-20261106/claude/j136
wip/j79d-red-cli
wip/j79d-red-server
j121-link-liveness
j118c-tracer-failures
wip/j79c-head
release-desktop-j131
j124c-signed-macos
wip/j79c-red-p3
wip/j79c-red-p23
wip/j79c-red-p22
merge-j128-check
perf-deferred-j128
sidebar-toggle-260
j127-shortcut-changed-dot
j125-mcp
j118-tracer-failures
j126-account-summary
settings-sections-mock-j92
j120-pinch-lock
sidebar-292
backup/macos01-20261106/claude/j120
taste-2026-11-03
row-actions-242-215
backup/macos01-20261106/claude/stash-0-untracked
backup/macos01-20261106/claude/J80-265-s1-run
backup/macos01-20261106/claude/J80-macos-s1-20261102
j112-canvas-commands
ui-no-overshoot-scroll
fix-recovery-restart
backup/macos01-20261106/claude/stash-1-untracked
taste-2026-11-02
size-baseline-ratchet
machine-cards-structure-j108
j109-boot-copy-mockups
fix-dev-red
wip/up-263-s1
j95b-settings-rows
proxy-traefik-281
j95-option-rows
docs-human-j91
docs-keys-palette
fix-flood-1013-270-j38d
mesh-ssh-s1
mesh-ssh-s0
addhost-d291-tunnel
test-stability-load
mesh-relay-220
repro-296
shim-thp-off-24
mesh-pins-258-v2
mesh-dns
signin-d311-merged
docs-pages
ui-size-283
fix-ui-batch-specs
wip/j12b-edge-update
gate-on-arm
fix-rename-sync-293
trust-285-j60b
fix-focus-ring-clip
integ-ui-1101
edge-update-v2
signin-d311
taste-2026-11-01
layout-per-tab-250
ui-approved-splitopt-224
ui-approved-splitopt-224-on-dev
icon-text-centre-282
ui-approved-189-212-216
research-reverse-proxy
transfer-budget-320
review-mesh-pins-258-r2
sidebar-pill-259
review-mesh-relay-220
wip/j12-edge-update-v2
nix-package
status-crash-loop-237
fix-dev-test-failures
fix-fixture-socket-path
wip/mesh-relay-220-pre-dev-advance-rebase
fix-canvas-side-clip
research-head-to-head
frosted-real-256
review-mesh-pins-258
wip/mesh-relay-220-pre-final-rebase
review-layout-per-tab-250-r2
broad-suite-triage
nix-devshell
review-status-crash-loop-237-r3
wip/nix-devshell-pre-p3
taste-frosted-real
wip/code-serve-demo-2026-10-30
wip/code-serve-glass-2026-10-30
wip/code-serve-clusters-2026-10-30
wip/code-merge-release94-dev-2026-10-30
wip/rproxy-delta-scratch-2026-10-30
wip/stale-note-257-staged-2026-10-30
wip/d241-size-staged-2026-10-30
review-broad-suite-207
wip/mesh-pins-258-pre-split
wip/mesh-relay-220-pre-rebase
mesh-measure-220
plan-211-update
review-edge-autoupdate-r3
perf24-reconnect
review-stale-note-r2
release-prod-live
d241-shell-marker
review-mesh-pins-server-258
review-revocation-r3
review-setup-token-r2
review-sync-journal-r3
wip/review-mesh-pins-258-prune-review-1995fee46
frosted-scroll-256
sync-journal-r3
revocation-per-account-wip
review-tokio-asyncfd-0386
review-sync-p3s
wip/stash-8by64-stash0-2026-10-30
mesh-drag-r2
setup-token-data-wip
release-9-4
auth-busy-1013
mesh-view-overlap
sync-p3s
review-auth-busy-wake
review-readd-r8-wip
mesh-drag-bounds
audit-auth-93
app-windows-stream-start
review-authority-cap-r3
app-windows-r7-measure
readd-minimal-r6
readd-minimal-r5
app-windows-r7-soak
readd-minimal-r4
app-windows-r7
app-windows-r6
readd-minimal-r3
readd-minimal-r2
readd-minimal
merge-release8-dev
review-busy-page-liveness-r2
review-busy-page-liveness
mesh-view-trim
review-authority-read-retry-r2
review-remove-uninstall-r2
release-retry-reattach
release-retry
review-remove-uninstall
review-authority-read-retry
app-windows-ship
mesh-autoswitch-p2
mesh-ssh
mesh-relay
mesh-macos-node
screen-and-control
session-labels
review-real-logins-r5
review-real-logins-r4
review-real-logins-r3
shim-memory-r2
review-real-logins-r2
shim-memory
shadow-addhost-instant
shadow-real-logins
shadow-same-session-flood
shadow-prod-perf-fix
hosts-from-server
app-windows-real
app-windows-transport
release-prod-6w
mesh-policy-verify
quiet-close-toast
dev-merge-r4
review-mesh-agent-transport
review-app-windows-transport
settings-roundtrip
review-release-pipeline-r4
mesh-agent-transport
ended-strip-fix
review-audit-ca-update-d244
settings-rows
phone-width
signout-clear
fix-restart-tests
dev-merge-rp
signer-hardening
review-audit-ca-update
terminal-fidelity
review-audit-ca-update-wip
mesh-integrate
review-mesh-agent-transport-515d3712
review-mesh-dataplane-feec1988
mesh-dataplane
signout
research-canvas-node
wip/review-renderer-cost
wip/review-terminal-fidelity
padlock-glyph
review-release-pipeline-2e95b689
phone-polish
sidebar-polish
inbox-generic
review-mesh-dataplane-378d4055
prod-batch
ui-inbox
ui-ca-unlock
ui-machine-sections
review-mesh-dataplane-a5f744fb
tls-session-prod
session-bounds-prod
fix-dead-session
session-bounds
tls-session
palette-polish
shortcuts-d222
research-appmeta
phone-gutter
ui-centre-button
wip/ui-centre-button
wip/tls-session
review-addhost-breakit
ui-platform
renderer-cost
remote-agents
mesh-api
ssh-bootstrap
prod-hotfix2
prod-fixes
review-remote-agents
review-mesh-dataplane
session-life
research-browser
review-mesh-api
research-capture
review-mesh-api-round3
review-mesh-api-round1
gate-stability
review-gate-stability
review-relay-direct
review-mesh-api-findings
proto-sessions
font-picker
proto-addhost
proto-windows
mesh-core
latency-gate
research-bsd
research-discovery
keytray-mods
mock-core
ui-tweaks
fix-motion-sel
fix-motion
integrate2
fix-robust
t-web
t-server
vt-ghostty
fix-snap-echo
t-web-auth
review-vt2
t-agent
lane-protocol
lane-shim
lane-auth
s1-base
s1-contracts
s1-workspace
No results found.
No labels
launch-qa
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".
No due date set.
Dependencies
No dependencies set
Reference
kayg/infraternal#162
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Owner request (2026-10-11): research how existing mesh SSH products take over port 22, before we build SSH over our mesh (D197 M1, D227 step 3). Owner's recollection: Tailscale SSH does not go through the kernel (it intercepts in its own userspace network stack), while NetBird does and redirects 22 to 22022, which causes problems on his hosts.
Also in scope: how each identifies which person (not only which machine) is connecting, and what happens on a machine with several local users (e.g. a Mac with
kaygandagentsaccounts), including SSH to another local user on the same machine.Started research-mesh-ssh on branch research-mesh-ssh at base/head
4fc2460d92(mesh slice 1), clean worktree, only writer. Read #162 (0 comments), its mesh parent #129 and parent #79 history, repository contract, requested decisions from origin/dev, and contracts/mesh-dataplane.md. Research and throwaway prototypes only; no product code or deployment.Finding: Tailscale SSH is a per-flow userspace interception. In pinned source 3bb8a906c27738c7904ef301c9539da763181f85,
ShouldInterceptTCPPortonly enables interception when netstack is built (ipn/ipnlocal/local.go:8379-8387); inbound packets from WireGuard to a local Tailscale IP are selected bywgengine/netstack/netstack.go:1253-1280and consumed withDropSilentlyinstead of continuing toward the host stack (:1440-1487).tailssh.HandleSSHConnis the in-process SSH entry (ssh/tailssh/tailssh.go:162-178). The docs say port 22 is claimed only for tailnet traffic and ordinary host SSH remains available for non-tailnet traffic: https://tailscale.com/docs/features/tailscale-ssh.Finding: NetBird’s “port 22 to 22022” description is a kernel DNAT rule on Linux (iptables/nftables), with a packet-rewrite equivalent in its userspace firewall. In pinned source 67c2041fb5534c19d7b2320617cfc3aaab8e7d3d,
client/internal/engine_ssh.go:31-52,274-310installs22 -> 22022for the WireGuard address and starts the embedded listener at 22022;client/firewall/iptables/dnat_linux.go:16-45andclient/firewall/nftables/dnat_linux.go:17-93match the WireGuard interface;client/firewall/uspfilter/filter.go:1218-1249rewrites before its ACL path. Current docs date the native port model to v0.60.0+ and require v0.61.0+ for all SSH peers: https://docs.netbird.io/manage/peers/ssh. Reports show a v0.54.1 Docker PREROUTING/Input-ACL bypass (#4351) and a Kubernetes/CNI ordering report (#4470); they are user reports, not proof that every current setup is affected. IPv6 redirection/listener setup exists in the current code but is best-effort (warnings on failure); PR #5687 added it, merged 2026-04-07: https://github.com/netbirdio/netbird/pull/5687.Finding: Tailscale’s source SSH identity is the node’s tailnet user (or tag identity), not the local Unix account running the SSH client. Its docs explicitly warn that any local OS user on a client can use Tailscale SSH, so a multi-user machine can exercise the node owner’s policy;
check/alwaysadds SSO reauthentication but does not bind to the caller UID. Tagged nodes are service identities, and tag-based SSH is restricted to tagged destinations; shared-user cases haveautogroup:sharedpolicy semantics. Sources: https://tailscale.com/docs/features/tailscale-ssh and https://tailscale.com/docs/features/tags. Tailscale’s own issue #12810 is still a request to support SSH into the source node itself; the inbound WireGuard hook is the path handled inwgengine/netstack/netstack.goabove: https://github.com/tailscale/tailscale/issues/12810.NetBird’s current code separates mesh peer ACL identity from SSH OIDC user identity and target OS username. A valid JWT user ID plus requested local username are checked by
client/ssh/server/server.go:678-725andclient/ssh/auth/auth.go:102-149; no mapping fails closed. In addition, merged PR #7378 binds cached SSH JWTs to the local Unix UID/Windows SID that obtained them (merge commit 7b22d55bf685427e7d8a313dc79358326af10497); the current cache andSO_PEERCREDimplementation are inclient/server/jwt_cache.go:42-103andclient/internal/ipcauth/peercred_linux.go:12-38: https://github.com/netbirdio/netbird/pull/7378. With default cache TTL 0, each new session does OIDC; enabled cache is caller-scoped. Thus a different local account cannot reuse a cached JWT through the daemon, though it can authenticate as its own IdP user. This differs from a design that authorizes solely by the shared mesh peer.Correction on Tailscale SSH-to-self: #12810 was closed as a duplicate of #4475, not as a fix. #4475 remains open/needs-fix and documents that connecting to the node’s own Tailscale IP bypasses the TUN/WireGuard hook and reaches host OpenSSH instead: https://github.com/tailscale/tailscale/issues/4475. NetBird has a corresponding explicit own-peer rejection in
client/ssh/server/server.go:835-850at source commit 67c2041fb5534c19d7b2320617cfc3aaab8e7d3d. I’ll distinguish both self cases from remote mesh SSH in the report.Completed benchmark step; harness committed and pushed as
1a7ffd85. On infraternal-dev (8 vCPU, Linux 6.12.111, rootless user/net namespaces, CPUWeight=10000), two full runs used 100 setup samples and five 32 MiB transfers per path. Run 1 p50/p95 setup RTT and median goodput (MiB/s): direct 0.591/2.522, 1574.97; DNAT 0.514/1.443, 2041.93; TPROXY 0.409/0.923, 1673.01; Unix proxy 1.149/4.194, 1059.57. Run 2: direct 0.378/2.792, 986.31; DNAT 0.528/6.016, 727.26; TPROXY 0.371/7.087, 950.24; Unix proxy 2.683/11.688, 535.83. Load average was 15.18→15.18 in run 1 and 15.76→17.06 in run 2, so treat these as noisy TCP transport comparisons, not a ranking. A 0.0.0.0:22 listener made an additional mesh-IP:22 bind fail with EADDRINUSE. The UDS probe saw UID 0 in the user namespace, mapped to host UID 1001. No SSH protocol, WireGuard encryption, or gVisor was measured. Raw results are under $HOME/.cache/codex-scratch/research-mesh-ssh/.Correction after reviewing the harness: the first Unix-proxy goodput timer began before the proxy's remote TCP connect finished. Fixed the timing in pushed commit
da5dd08cand reran two full series; all earlier throughput values in my previous comment are superseded by these calibrated results. Each run used 100 setup samples and five 32 MiB transfers per path. p50/p95 setup RTT ms and median MiB/s: run 1 — direct 0.244/0.581, 1974.39; DNAT 0.343/0.532, 1420.92; TPROXY 0.391/1.276, 1457.14; Unix proxy 1.335/4.577, 1313.71. Run 2 — direct 0.398/1.304, 1799.57; DNAT 0.460/3.650, 982.06; TPROXY 0.515/3.701, 893.49; Unix proxy 2.323/10.949, 615.55. Load averages were 19.80→19.80 and 19.65→21.76 on 8 vCPUs. Run-to-run variance remains material; this is TCP transport only, without SSH, WireGuard, or gVisor. Calibrated summary and current raw run are in $HOME/.cache/codex-scratch/research-mesh-ssh/.Fast-gate finding (2026-10-11): the full rerun with the scratch Cargo target and a temporary worktree
targetsymlink failed the Rust test and static-build rows. All sixagent_reviewprobes returned “terminal open refused” inside the high-priority user scope. The x86_64 static binary was 20,614,624 bytes against the 16,404,816-byte maximum. A direct run stopped at the latency self-test (p50 318.44 ms for configured 300 ms). This research job made no runtime-code changes; I’m recording the gate output and continuing with the requested research artifact.Finished on branch
research-mesh-ssh; pushed head SHA:e5854958ab47b397c86a8ca47ddcbff8377026c0. Research note: research/mesh-ssh/README.md.Short answer: Tailscale serves tailnet-IP TCP 22 inside
tailscaled, diverting selected traffic into its gVisor netstack; NetBird redirects matching mesh-interface TCP 22 to its embedded listener on 22022 with nftables/iptables DNAT. Tailscale policy identifies the source node owner or tags, so local accounts share node rights. NetBird adds an OIDC user JWT and scopes cached tokens to the calling local UID/SID, while the target username selects the local account. The note covers the exceptions, versioned issue evidence, and owner decisions without choosing an infraternal transport or identity model.The corrected transport measurements remain load-sensitive and are transport-only. The high-priority full gate run failed the Rust test and static-build rows; six agent-review probes returned “terminal open refused”, and the x86_64 binary measured 20,614,624 bytes against a 16,404,816-byte maximum. The direct run stopped at the latency self-test (p50 318.44 ms for configured 300 ms).
scripts/verify fastRust gate output, verbatim:Orchestrator: owner grill concluded 2026-10-11; recorded as D235 (dev
3fb20239). Build is queued after D215 and the TCP/443 fallback (D227 order).Closed by the orchestrator during the 2026-10-28 handover (#254), on the owner's request to close finished issues. Evidence: Research note delivered (research/mesh-ssh) and owner grill outcome recorded as D235. Reopen if anything is still missing.
kayg referenced this issue2026-10-28 17:53:55 +00:00