Skip to content

Fix findings from the security audit - #3083

Merged
madeye merged 4 commits into
masterfrom
fix/audit-findings
Oct 28, 2026
Merged

madeye merged 4 commits into
masterfrom
fix/audit-findings

Conversation

@madeye

@madeye madeye commented Oct 27, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes every finding from a full audit of the codebase: TCP and UDP relays, the resolver, crypto, the program mains and ACL, and the manager, config and plugin code.

Remotely reachable

  • TCP pool exhaustion: idle handshakes were held for at least 24 h, so --max-connections idle sockets could lock the server out. Handshake and connect deadlines now follow --timeout.
  • IPv4-mapped ACL bypass: ::ffff:127.0.0.1 skipped IPv4 rules for both the outbound block list and the peer ACL.
  • UDP server ignored the ACL: it now applies the peer ACL and the outbound block list to literal addresses, names and resolved addresses.
  • ACL fails closed: an unreadable file or an invalid entry stops startup instead of leaving an open proxy.
  • TCP half-close: shutdown(SHUT_WR) from one side is passed on, and the other direction keeps flowing.
  • AEAD-2022 UDP: session state is created only after the timestamp and replay checks pass.

ss-manager

  • Conf files holding passwords are created 0600 and deleted on remove. The control socket is 0600, daemonize uses umask 022, and an unsafe working directory is refused.
  • IP manager addresses must be loopback. On Linux, a command is obeyed only from the manager's own user, root or the -a user. A per-server plugin is accepted only over the UNIX socket.
  • Ports are canonicalised (0080 = 80), the off-by-one in list is fixed, add and remove wait for the server, and stale pid files can no longer signal unrelated processes.

Other

  • Plugins drop to the --user user. On Linux they keep CAP_NET_BIND_SERVICE.
  • daemonize: the start succeeds only once the daemon is serving, and the pid file is opened safely.
  • Resolver: a cancelled query delivers no address.
  • Crypto: the replay filter fails closed, keys and decrypted buffers are wiped, the 2022 salt pool no longer evicts live salts, and the parsers are stricter (ATYP, reserved length bits, 900-byte UDP padding limit).
  • JSON surrogate pairs are validated and \u0000 is rejected. NULL holes in port_password and server are fixed. The ss:// plugin= value must be a plain program name.
  • The embedding API resets the ACL and exit code between runs and cleans up after a failed start. Android protect_socket now handles failure replies.

Behaviour changes for operators

  • An invalid ACL file stops the server instead of being partly applied.
  • Idle handshakes close after --timeout (default 60 s) instead of 24 h.
  • ss-manager refuses non-loopback IP addresses, and accepts per-server plugins only over its UNIX socket.
  • Plugins run as the --user user.

Tests

  • New: tests/test_server_acl.py and tests/test_half_close.py (registered with CTest).
  • Extended: the manager, ACL, AEAD-2022 and ssurl tests.
  • Local, macOS with ASan/UBSan: ctest 42/42 (memcheck label excluded), interop over all methods, tunnel interop, CLI, CLI docs, stress tests and the no-heap lint all pass.
  • The minimal build passes. The Linux (x86_64, aarch64-musl) and Windows zig cross-builds compile.
  • Linux container as root: the ACL, half-close, manager and interop tests pass, and the plugin privilege drop was confirmed.
  • clang-tidy reports no new warnings on the changed files.
  • Not run locally: GCC-specific warnings and valgrind memcheck. CI covers both.

🤖 Generated with Claude Code

madeye and others added 4 commits October 27, 2026 16:30
Remote:
- TCP: handshake/connect deadlines follow --timeout instead of a 24h
  minimum, so idle sockets can no longer fill the connection pool.
- ACL: IPv4-mapped IPv6 addresses are matched against the IPv4 lists.
- UDP server now enforces the peer ACL and the outbound block list.
- ACL loading fails closed on bad files or invalid entries.
- TCP half-close is relayed instead of tearing the connection down.
- AEAD-2022 UDP sessions are created only after timestamp/replay checks.

ss-manager:
- Owner-only conf files (deleted on remove), 0600 control socket,
  umask 022, safe working directory, loopback-only IP addresses,
  per-user sender check on Linux, plugins only over the UNIX socket.
- Port canonicalisation, list() overflow, add/remove waits for the
  server, stale pid files can't signal unrelated processes.

Also: plugins drop to --user, daemonize readiness/pid file handling,
resolver cancellation, replay-filter fail-closed, key wiping, spec
strictness in AEAD/2022 parsing, JSON surrogate validation, ss:// plugin
name checks, embedding API state reset, Android protect_socket replies.

Adds tests/test_server_acl.py and tests/test_half_close.py and extends
the manager, ACL, AEAD-2022 and ssurl tests.

Co-Authored-By: Claude <noreply@anthropic.com>
- Define _GLIBCXX_NO_ASSERTIONS: libstdc++ 15 enables assertions at -O0,
  which pulls __glibcxx_assert_fail (C++ runtime) into the programs.
- test_redir_qemu: boot the guest with -cpu max so the runner's glibc
  loader runs under TCG.
- find_program: std::string_view PATH splitting into a fixed buffer, no
  heap and no null snprintf destination (GCC -Wformat-truncation).
- manager: parse /proc/net/udp numbers with strtoul (cert-err34-c);
  walk /proc/<pid>/cmdline with std::string_view.
- ssurl: sanitise the tag through std::span.

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
…nores inconsistent

gcov 15 marks the lambda as not hit while its lines are, which lcov 2
rejects.

Co-Authored-By: Claude <noreply@anthropic.com>
@madeye
madeye merged commit 50f1ae5 into master Oct 28, 2026
27 checks passed
@madeye
madeye deleted the fix/audit-findings branch October 28, 2026 01:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant