# push (client certificate):
git remote set-url --push origin https://coredump.ws:8443/repos/x11vnc-fixes.git
Branches and tags
Files at HEAD (b85721b890) · download zip
Recent commits · all
| b85721b8 | README: show vnc_conn_rate with a timeout | no-body-in-particular | 22 days ago |
| 4439308d | Relicense under GPL-3.0-or-later | no-body-in-particular | 27 days ago |
| 3c942bb9 | License under GPL-2.0 | no-body-in-particular | 28 days ago |
| b177c456 | x11vnc 0.9.17-r11, libvncserver 0.9.15-r10: CU stop-and-wait, resize hang | no-body-in-particular | 2026-10-08 |
| a2115124 | x11vnc 0.9.17-r10: resize deadlock, framebuffer races, stuck keys, 70 s TLS drop | no-body-in-particular | 2026-10-08 |
| a5530208 | x11vnc 0.9.17-r9, libvncserver 0.9.15-r9: performance release | no-body-in-particular | 2026-10-08 |
| 6bbf8283 | x11vnc 0.9.17-r8, libvncserver 0.9.15-r8: pre/post-auth hunt fixes | no-body-in-particular | 2026-10-08 |
| 3355e965 | libvncserver 0.9.15-r7: refuse WebSocket origins not in LIBVNCSERVER_WS_ORIGINS | no-body-in-particular | 2026-10-08 |
| d9dacd99 | x11vnc 0.9.17-r6, libvncserver 0.9.15-r6: lifetime races, main-loop stalls, SIGTERM | no-body-in-particular | 2026-10-07 |
| 33b20dec | x11vnc 0.9.17-r5, libvncserver 0.9.15-r5: resize and scaled-screen fixes | no-body-in-particular | 2026-10-07 |
README.md
x11vnc-fixes
Fixes and a Gentoo ebuild for x11vnc 0.9.17,
as run behind NoVNCAudio on
coredump.ws: -ssl with -sslverify client certificates as the only
authentication, on a port open to the internet. Everything here also applies to
an x11vnc that serves anything else over -ssl.
It also carries fixes for libvncserver 0.9.15, the library x11vnc serves clients with. x11vnc has had no release since 0.9.17 (2025-04-11), libvncserver none since 0.9.15, and none of this is upstream yet.
What it changes
Patches (overlay/x11-misc/x11vnc/files/, against 0.9.17):
| Patch | Fix |
|---|---|
| 0001 configure | Carried from ::gentoo (x11vnc#268): drop AC_FUNC_STAT, which breaks with -Werror=implicit-function-declaration. |
| 0002 copy_tiles | copy_tiles() narrowed a changed tile's update rectangle to the columns that differ, but scanned after the memcpy() that had made old and new identical, so the narrowing never happened. The scan now runs first, with an SSE2/word-wise byte scan instead of a memcmp() per pixel. On a scrolling 2px-wide line, incremental traffic drops from 552,961 to 34,561 pixels. |
| 0003 sslhelper | Unauthenticated DoS. Every rejected connection left a zombie: the parent sent SIGTERM to the failed SSL helper and then did a WNOHANG wait before it had exited, and nothing reaped it later. Zombies count against RLIMIT_NPROC, so junk connections eventually stop the user from forking at all, x11vnc included. The wait is now blocking. |
| 0004 sslhelper | Unauthenticated DoS. A client that connected and then said nothing hung the whole server: the helper's VeNCrypt/ANONTLS negotiation read with no timeout, and the main loop waited for the helper's cookie with no timeout either. One idle connection was seen holding a public server for 17 minutes. The SSL_INIT_TIMEOUT alarm now covers the whole helper initialization, and the parent's wait is bounded. |
| 0005 sslhelper | Local authentication bypass. For VeNCrypt/ANONTLS clients the helper wrote its cookie truncated, and the parent accepted any prefix of it, down to a bare RB=. A local process could race the helper to the parent's loopback port and get a session with no certificate (with -nopw, full desktop control). The whole cookie is now sent and must match exactly. |
| 0006 sslhelper | Bytes from an unauthenticated client that did not send an RFB version were logged raw, so terminal escape sequences could be put into the log. Non-printable bytes are now replaced. |
| 0007 sslhelper | No protocol floor or cipher list was set, so OpenSSL 3 defaults allowed TLS 1.2 static-RSA and CBC-SHA1 suites. The server now requires TLS ≥ 1.2 and, for TLS 1.2, ECDHE with AES-GCM or ChaCha20-Poly1305 (so -dhparams no longer has an effect). X11VNC_SSL_CIPHERS overrides the list. |
A second review, with dynamic tests against a lab build, found gaps in
0003-0007. Fixed in -r3:
| Patch | Fix |
|---|---|
| 0008 sslhelper | 0004 armed the timeout early, but the handshake loop re-armed it and cancelled it on success, so the helper could take twice SSL_INIT_TIMEOUT and the HTTP sniffing after the handshake ran unbounded (one loop spun at full CPU on a half-closed client). One deadline now covers everything until the helper starts relaying. The 20s greeting wait after an HTTPS fetch is capped to fit inside it, and SSL_INIT_TIMEOUT is capped at a day. |
| 0009 sslhelper | The parent still searched for the VENCRYPT= tag anywhere in a helper message. HTTPS messages carry the client's request line, so a crafted URL was taken as a VeNCrypt selection (harmless, but wrong). The message must now be exactly <prefix>,VENCRYPT=<n>,<cookie>. |
| 0010 sslhelper | 0006 missed the invalid version log line, which RFB 3.7 plus five escape bytes still reached. |
| 0011 sslhelper | With 0003 reaping a helper after rfbNewClient() fails, its pid stayed in the helper table and could be signalled at exit after reuse. The entry is now removed. |
libvncserver (overlay/net-libs/libvncserver/files/, against 0.9.15 plus
the ::gentoo cmake4 patch). x11vnc's -threads runs libvncserver's threaded
client mode: one thread applies the client's messages while another encodes
screen updates, and the first changed state the second was using without
taking its lock. Each race was reproduced under ASan/UBSan against both a
minimal threaded server and x11vnc 0.9.17 itself. Every trigger needs a client
that has already authenticated (with -ssl -sslverify, a valid certificate).
| Patch | Fix |
|---|---|
| 0001-0004 | Backports of upstream server-side fixes after 0.9.15: e7ee07dd and eae4f703 (no invalid fds to FD_SET, which aborts under _FORTIFY_SOURCE), 1b4f87f4 (fd leak on an interrupted file transfer), 5ea5fc30 (no update sending once the client is shutting down). |
| 0005 | eae4f703 returns from rfbWriteExact() with outputMutex held, which can deadlock a later rfbClientConnectionGone(). Also in upstream master. |
| 0006 | Input and output threads could both tear down a client on disconnect: double free of cl->wspath (and of the SSL context for wss). Teardown moves to rfbClientConnectionGone() in threaded mode. |
| 0007 | Repeated GET lines in a websocket handshake leaked cl->wspath, and the handshake had no overall deadline (one trickling client could hold the accepting thread for minutes). |
| 0008 | SetPixelFormat wrote the client's format before validating it and swapped the translation tables under the encoder: use-after-free, a heap overflow past cl->updateBuf (x11vnc died with its client list overwritten by pixel data), and a division by zero for bpp=0 that killed x11vnc. The format is now validated into a local and swapped under sendMutex. Also rejects ZRLE shifts over 31. |
| 0009 | SetEncodings reset the Tight compression level mid-rectangle, so tight.c indexed past tightConf[4] and divided by a value read beyond it (SIGFPE). The list is now read first and applied under sendMutex. |
| 0010 | Bounds checks on the Tight configuration tables, in case a level reaches them some other way. |
| 0011 | SetScale swapped the client's scaled framebuffer under the encoder, which then read past the end of the new one and sent adjacent heap memory to the client. Now swapped under sendMutex. |
| 0012 | rfbWriteExact() encoded a WebSocket frame into the per-client buffer before taking outputMutex, so two threads writing to one client (an update, and x11vnc's main loop sending clipboard text) could send each other's frame; noVNC drops the connection on a bad frame. The lock now covers the encoding too. |
None of the races exist without -threads, but dropping it has a real cost:
x11vnc's main loop blocks on every incoming SSL handshake, and without threads
that freezes input and encoding as well as screen polling. On a public port,
where scanners connect all the time, the desktop became noticeably slower.
Keep -threads and use this library.
-r4
x11vnc 0012-0035 (all against 0.9.17, applied after 0001-0011):
| Patches | Change |
|---|---|
| 0012-0017, 0034 | The main loop no longer waits on SSL handshakes. Before, each connection's helper was waited for in the main loop, so a port scanner holding a handshake froze screen updates (and without -threads, input) for everyone - measured 7-18% of the time on a public port. Helpers now sit in a bounded table polled each pass; at most 4 pending handshakes per source address (a source at its cap replaces its own oldest), the oldest of the busiest source is evicted when the table is full. The helper cookie is 256 random bits, the connect-back port is chosen by the kernel, and the certificate/DH reports go through unlinked temp files, so nothing is left in /tmp. With 6 stalled connections a connected viewer's longest update gap went from 8.1 s to 0.39 s, and a new client's connect time from 11 s to under a second. X11VNC_SSL_SYNC_HELPER=1 restores the old behaviour. |
| 0018-0019 | The pre-auth SSL helper closes every inherited descriptor and, with -sslverify, runs under a seccomp allowlist, PR_SET_NO_NEW_PRIVS, not-dumpable and zero process/core limits before it reads anything from the client (X11VNC_SSL_HELPER_SANDBOX=0 or =log). |
| 0020 | X11VNC_NO_NEW_PRIVS=1 sets PR_SET_NO_NEW_PRIVS for x11vnc itself (opt-in). |
| 0021 | The accepted client certificate (subject, issuer, serial, SHA-256) is logged; -users sslpeer= and RFB_SSL_CLIENT_CERT work again. |
| 0022-0025 | Clipboard text over 128 KiB read at the wrong offset; a self-deadlock on every framebuffer change (-xrandr resize) with -threads and a client; cursors[-1] after a new framebuffer; a departed client's deferred pointer events. |
| 0026 | TCP_NODELAY on both sockets of the SSL relay. Nagle held the second of the two TLS records of every Tight update until the first was ACKed: keystroke-to-glyph on loopback 49.7 -> 8.8 ms (p50), and a round trip less on about half of small updates over a WAN. |
| 0027-0031 | Review fixes: async-signal-safe SIGALRM handlers; the HTTP sniff wait fits inside the helper deadline; no inherited log/timezone locks in the forked helper; client_gone() no longer blocks on a helper; helper-table/reap fixes. |
| 0032-0033 | The "holds its port but never accepts" wedge. With -threads the scan locked every client's sendMutex and unlocked by walking the client list again; a client removed in between - a refused HTTP/WebSocket GET does that - stayed locked, and its thread blocked forever in rfbClientConnectionGone(). The send ban now unlocks exactly the clients it locked (holding a reference), and framebuffer changes use the same ban. |
| 0035 | With IPv6 and no -ssl, libvncserver opened its own listener on [::]:5900, ignoring -rfbport, -localhost and -noipv6. |
libvncserver 0001-0026 (against 0.9.15 + the ::gentoo cmake4 patch): 0001-0004 are upstream cherry-picks; 0005-0013 the threaded-mode races and locking above (plus ExtendedClipboard replies under sendMutex, TLS teardown order for GnuTLS); 0014-0025 bugs found by fuzzing, none fixed upstream as of master 98aaee05 - a TightPng heap overflow (16 bpp client, up to ~64 KiB written past the buffer), Tight with a 24 bpp client sending up to ~64 KiB of adjacent heap to the client, a SIGFPE on an empty FramebufferUpdateRequest, a WebSocket control-frame livelock and split frame headers, scaled screens across resizes, a NULL cursor in CopyRect, and smaller ones; 0026 sends a small Tight update as one write.
Both ebuilds add FORTIFY level 3, zero-initialised automatic variables and explicit RELRO/now/noexecstack, and drop a global --allow-multiple-definition; x11vnc requires libvncserver-0.9.15-r4.
tests/run.sh builds both packages from the tarballs and the overlay patches (or tests a given binary) and runs a lab regression suite: TLS policy, zombies and fd leaks, handshake stalls, log sanitising, VeNCrypt, threaded stress, input, clipboard and resize. See tests/README.md.
-r11 (x11vnc) and libvncserver -r10
| Patch | Fix |
|---|---|
| libvncserver 0062 | ContinuousUpdates fell into stop-and-wait on short, fast links. The flow-control window was one bandwidth x base-RTT plus an average update size capped at that same product, so at 20 ms a single video frame overflowed it: every update waited for the answer to the previous one (transfer, client decode, round trip, next encode in series), and the rate measured under that cap could never grow the window. The extra term is now the largest of the last 16 updates, uncapped, and before any rate sample the window is 64 kB plus that, so at least two updates are always in flight. Real noVNC, 20 ms / 3 MB/s, 640x360 video: 2.9 -> 4.5 pictures/s and draw-to-pixel p90 2172 -> 627 ms; ZRLE at 20 ms / 10 MB/s: 6.1 -> 11.8 updates/s. |
| libvncserver 0063 | rfbNewFramebuffer() in threaded mode locked every client's sendMutex in one walk and unlocked in a second; a client that closed in between stayed locked and its input thread hung for good in rfbClientConnectionGone() (found by fuzzing; x11vnc -threads does its own resize locking and was not affected). It now unlocks exactly the clients it locked, holding a reference on each. |
| x11vnc 0075 | Other threads' "check this area" requests no longer write the scan's tile bitmap directly. |
| x11vnc 0076 | The scroll-copy decision is made under the send ban, in the same pass that applies it, not one pass earlier. |
-r10 (x11vnc only; libvncserver stays -r9)
| Patch | Fix |
|---|---|
| 0068 | X error handlers no longer call into Xlib. With -clear_all, an X error during a resize storm went Xerror() -> clear_keys() -> XQueryKeymap() inside Xlib and deadlocked the main thread while it held X_LOCK and every client's sendMutex. The handler now logs, sets shut_down and lets the main loop exit cleanly (status 1, so -loop restarts). Before: 5 of 9 resize stress runs deadlocked; after: 30 of 30 clean. |
| 0069 | Trap handlers kept a pointer to Xlib's on-stack XErrorEvent; they keep a copy. |
| 0070 | XShmAttach() is now waited for (XSync under a serial-matched trap). A refused attach is retried once, then x11vnc falls back to XGetImage instead of failing later on a segment the server never attached. |
| 0071-0072 | Framebuffer writes outside the scan now take the send ban: the black-screen clear, the wireframe box, direct_fb_copy() and the CopyRect moves (which could otherwise move torn pixels on the client for good). |
| 0073 | Held keys are released when the last client disconnects. With -repeat, a key held when a viewer's connection dropped kept auto-repeating into the focused window until x11vnc restarted. |
| 0074 | The SSL relay no longer reaps helpers at its 70 s cutover: under the -r8 seccomp filter that kill(pid,0) killed the relay, so a TLS session ended 70 s after connecting whenever another helper (a scanner's handshake, a reconnect) was running. |
-r9 (performance)
Six measured performance rounds, merged on -r8 (every -r8 security fix and PoC still holds; the strict suite, an ASan/UBSan suite, byte-exact encoder output and exact-pixel convergence after scroll/drag/video are part of the gate). Over an emulated 115 ms / 2.5 MB/s link:
| -r8 | -r9 | |
|---|---|---|
| Typing key->glyph p50 | 126 ms | 121 ms |
| Terminal scroll settles p50 | 285 ms | 133 ms |
| Window drag settles | 239 ms | 153 ms |
| 640x360 video, Tight | 16 fps | 28 fps |
| 640x360 video, H.264 adaptive (opt-in) | 3.7 fps (ZRLE) | 29 fps at 1/6 the bandwidth |
| Typing during video p50 (ZRLE) | 344 ms | 174 ms |
| Idle CPU, x11vnc / X server | 2.5% / 1.0% | 0.4% / 0.1% |
- libvncserver 0053: rfbDoCopyRegion copied multi-rectangle regions in the wrong order (corrupting the server's framebuffer).
- 0054-0058: cheaper encoders, byte-identical output (pixel translation by byte shuffle with SSSE3/AVX2 and a portable fallback, ZRLE tile analysis, Tight palettes, Pack24).
- 0059-0060: ContinuousUpdates and Fence with fence-paced flow control;
LIBVNCSERVER_CONTINUOUS_UPDATES=0turns them off. - 0061: H.264 (RFB encoding 50) with libx264, USE=x264, used only when x11vnc is started with
-h264. - x11vnc 0063: TLS 1.2 browsers on links over ~90 ms RTT could not open the WebSocket (the GET arrived after the 100 ms sniff); the helper now waits for it.
- 0064-0066: read only what XDAMAGE reports (full-screen check every 2 s, fallback to the tile scan after repeated misses;
X11VNC_XDSCAN=0), adaptive poll sleep, vertical scrolls sent as CopyRect (X11VNC_SCROLLCOPY=0). - 0067:
-h264 off|adaptive|full|both(off by default).adaptivestreams only areas that keep changing as H.264 and resends them losslessly when they go quiet.
The matching noVNC changes (ContinuousUpdates/Fence, the H.264 decoder and "Video (H.264)" menu entry, a wasm ZRLE decoder, ImageDecoder for JPEG, one bundled script) are in NoVNCAudio.
-r7 and -r8
-r7 (libvncserver 0045): the WebSocket Origin allowlist, LIBVNCSERVER_WS_ORIGINS. A browser sends its TLS client certificate with a WebSocket that any page opens, and with -nopw the certificate is the whole authentication: without this, every website the certificate holder visited could open the session and type into it (cross-site WebSocket hijacking). Set it to the noVNC page's own origin only, and serve that page from an origin nothing else shares.
-r8 merges a further security round: a fix agent (soft cursor drawn per client, clipboard/bells queued to the output thread, X error-handler leaks) and two exploit hunts (pre-auth: a use-after-free of the last client address and an -allow bypass in the non-blocking accept, a single-address accept flood, TLS session tickets with a shared key and no peer-cert check in the helper, the SIGTERM fallback; post-auth: view-only pointer lock, ZRLE raw tiles to 15-bit clients, client cut text without a terminating NUL, hotkeys ignoring -input), plus a cursor race found by ThreadSanitizer.
libvncserver 0.9.15 (0046-0052, on -r7 0001-0045)
- 0045 (already in -r7) WebSockets: refuse an Origin not listed in LIBVNCSERVER_WS_ORIGINS (unset: no check, as before).
- 0046 Soft cursor drawn into a per-client copy of the rectangles it overlaps, never into the shared frame buffer (threaded mode sent cursor pixels and permanent cursor trails to other clients).
- 0047 Threaded mode: ServerCutText is queued per client (newest replaces an unsent one) and sent by the client's output thread, so a viewer that stopped reading no longer stalls the caller (x11vnc's main loop) and every other client's clipboard.
- 0048 Threaded mode: bells queued the same way (at most 4 pending); Bell statistics recorded per client instead of for the iterator's final NULL.
- 0049 View-only clients: PointerEvent returns before the pointerClient bookkeeping (a held button no longer locks every other client's mouse); Xvp and SetDesktopSize refused.
- 0050 ZRLE: raw tiles to 15-bit (RGB555-style 16 bpp) clients were sent at half length, corrupting the stream; now BPPOUT/8 bytes per pixel.
- 0051 ClientCutText and inflated ExtendedClipboard text handed to setXCutText()/setXCutTextUTF8() NUL-terminated.
- 0052 rfbRedrawAfterHideCursor() reads screen->cursor under cursorMutex (SetEncodings on a client's input thread raced rfbSetCursor() replacing/freeing the cursor; found by the -r8 TSan campaign).
x11vnc 0.9.17 (0053-0062, on -r6 0001-0052)
- 0053 -ssl: ssl_pending_poll() runs before accept, not after: helper_complete() replaced openssl_last_ip mid-accept (heap use-after-free for IPv6, -allow/-deny checked against another client's address).
- 0054 -ssl: a source at its 4-handshake cap whose oldest handshake is under 1 s old is refused without a fork; forks paced by a token bucket (16/s, bursts of 8) and the listeners drained every main-loop pass, so one source's flood no longer fills the accept queue.
- 0055 -ssl: no TLS session tickets; with -sslverify the helper requires a peer certificate that verified and a session that was not resumed.
- 0056 The 5 s SIGTERM fallback sets quiet before clean_shm(), so it never takes the log lock.
- 0057 XRANDR_CHK_TRAP_RET restores the previous X error handler on every path (trap_getimage_xerror stayed installed and swallowed every X error).
- 0058 -id/-sid: restore the X error handler only if the subwindow trap installed one (XSetErrorHandler(NULL) put Xlib's exiting default in place of Xerror()).
- 0059 initialize_signals() run twice (-display WAIT:) no longer saves Xerror/XIOerr as the handlers they chain to.
- 0060 Alt_L/Super_L hot sequences only for a client that may type (-input without K, -viewonly).
- 0061 A -viewpasswd login with empty view-only permissions stays viewOnly to libvncserver, and pointer_event() releases the pointer-client lock of a client whose buttons are not used (needs libvncserver 0049 for the viewOnly case).
- 0062 xcut_receive()/check_sel_direction(): compare and copy client cut text within its length (-remote_prefix heap over-read).
x11vnc 0061 relies on libvncserver 0049 for viewOnly clients; 0062 is correct with or without libvncserver 0051.
-r5 and -r6
-r5 (post-deploy locking tests: SetScale during resizes crashed -r4): new clients wait while a framebuffer change holds the send ban, scaled screens are rebuilt after it, no NULL-framebuffer sampling, update regions clipped to the current framebuffer, settle_clients() measures scaled clients by their own size, no shm cleanup of freed tile rows.
-r6 merges three follow-up rounds - remaining libvncserver bugs, a ThreadSanitizer race hunt of x11vnc -threads, and a main-loop latency/robustness pass (a watchdog found 132 main-loop pauses over 100 ms in two minutes of realistic load; none remain). Notable: a viewer that stops reading no longer freezes the server (it could, for up to a week); a reconnect with -nevershared no longer frees the old client under an iterator; SIGTERM no longer deadlocks in Xlib; one leaked 8 MiB thread per connection; connecting while another viewer is busy takes ~0.2 s instead of 4-8 s.
libvncserver 0.9.15 (0029-0044, on -r5 0001-0028)
- 0029 Client iterators step, skip closed clients and take references under rfbClientListMutex; a threaded client stays linked (hidden by sock = -1) until it is freed, so an iterator never walks into a freed client.
- 0030 rfbShutdownServer(): stop listening first, read the thread id while the reference is held, join exiting clients too (use-after-free).
- 0031 Detach client threads that end on their own (one leaked 8 MiB stack per connection with -threads).
- 0032 Non-shared ClientInit: close each other client while the iterator still holds it (use-after-free on reconnect).
- 0033 Threaded teardown: RFB_SHUTDOWN set and rechecked under updateMutex (lost wakeup), socket closed under updateMutex+outputMutex (no write to a reused fd), rfbCloseClient() shutdown()s the socket (a stuck writer or a handshake overwriting RFB_SHUTDOWN can't keep a closed client alive).
- 0034 Threaded mode: don't update the shared allFds/maxFd from client and listener threads.
- 0035 Link a new client into the list only after it is initialised; scaledScreenRefCount++ under cursorMutex.
- 0036 Bell and ServerCutText only to clients in RFB_NORMAL, checked under sendMutex; RFB_NORMAL set under sendMutex after ServerInit.
- 0037 SetScale: no UltraVNC ResizeFrameBuffer to a NewFBSize client (noVNC/TigerVNC dropped the connection).
- 0038 Build cursor shape updates under cursorMutex.
- 0039 Publish statistics list entries with an atomic compare-and-swap.
- 0040 screen->pointerClient accessed atomically, cleared on disconnect only if still that client.
- 0041 Pixel/byte-order shifts in unsigned arithmetic (UBSan; wrong ZRLE CPIXEL choice for shift-24 client formats).
- 0042 Tight Pack24(): no negative shift for client formats with shifts over 24.
- 0043 rfbReadExactTimeout()/rfbPeekExactTimeout(): retry select() on EINTR instead of dropping the client.
- 0044 New rfbNewClientNoWebSockets(): rfbNewClient() without the 100 ms WebSockets sniff.
x11vnc 0.9.17 (0039-0052, on -r5 0001-0038)
- 0039 Survive screen changes in quick succession: drain queued RRScreenChangeNotify, read the root's real size, trap BadMatch on the root XGetImage.
- 0040 -threads: no fixed sleeps or dropped input around a framebuffer change (X11VNC_THREADS_NEW_FB_SLEEP=ms restores them).
- 0041 settle_clients(): read client flags and regions under updateMutex.
- 0042 The scan's send ban is taken with trylock, all clients or none; a busy client skips one pass instead of stopping the main loop.
- 0043 -threads: rfbMaxClientWait 60 s instead of a week (-rfbwait still overrides).
- 0044 Hold the send ban (trylock) while copy_screen() rewrites the framebuffer.
- 0045 Change and read a client's input permissions (input string + viewOnly) under one lock.
- 0046 progress_client(): don't read latest_client after it is freed.
- 0047 ssl_gone_poll(): atomic lock-free peek.
- 0048 screen_has_clients() for the lock-free "any clients?" tests.
- 0049 SIGTERM/SIGHUP/SIGQUIT: cleanup runs in the main loop, not in the handler (X deadlock); 5 s _exit fallback.
- 0050 -ssl: no fixed 0.5 s/200 ms accept waits when no handshake is pending; idle loop poll()s the listeners.
- 0051 -ssl: sniff for WebSockets without blocking the main loop, then rfbNewClientNoWebSockets() (weak symbol).
- 0052 UBSan: empty CUT_BUFFER0 memcpy, 2 GiB relay byte counter overflow.
x11vnc 0051 uses rfbNewClientNoWebSockets() from libvncserver 0044 when present; with an older library it falls back to rfbNewClient().
Ebuilds: x11vnc-0.9.17-r10 and libvncserver-0.9.15-r9, the ::gentoo
ebuilds with the patches above.
It does not install the ::gentoo init/conf scripts, because NoVNCAudio
drives x11vnc from its own /etc/init.d/vnc.
Installing
As an overlay of its own:
cat > /etc/portage/repos.conf/x11vnc-fixes.conf <<'EOF'
[x11vnc-fixes]
location = /var/db/repos/x11vnc-fixes/overlay
EOF
git clone https://coredump.ws/repos/x11vnc-fixes.git /var/db/repos/x11vnc-fixes
emerge -av1 =net-libs/libvncserver-0.9.15-r10::x11vnc-fixes =x11-misc/x11vnc-0.9.17-r11::x11vnc-fixes
Or copy overlay/x11-misc/x11vnc and overlay/net-libs/libvncserver into an
existing local overlay. Without
Gentoo, apply the patches in order to the 0.9.17 tarball with patch -p1.
A running x11vnc keeps the old binary until it is restarted. Its -loop
parent re-execs the binary from disk, so the whole tree has to go down
(NoVNCAudio: rc-service vnc restart_vnc).
Recommended runtime flags
These need no rebuild and complement the patches:
-sslonlyonly on an unpatched x11vnc: it disables VeNCrypt and ANONTLS negotiation, removing the code paths behind 0004, 0005 and 0006. With these patches it is not needed, and it has a cost: x11vnc no longer sends an RFB greeting before TLS, so scanners expecting one sit silent until a timeout instead of hanging up, and each one holds up the accept loop about twice as long.-safer -noultraext: turns off X property remote control and VNC_CONNECT, and the UltraVNC extensions (server-input and single-window messages, which reallocate the framebuffer under a running client thread).-env SSL_INIT_TIMEOUT=8: how long a pending handshake may hold a slot in the helper table (default 20s). Before -r4 this was also how long a slow handshake stalled the whole server.-sb 0: x11vnc's "screen blank" throttle slows polling after 60s without input; the first update after a quiet spell took ~2 s over a 115 ms link instead of ~70 ms. Costs ~1% of a core while idle.- A per-source connection rate limit on the port. Each connection forks a helper. coredump.ws uses
meter vnc_conn_rate size 65535 { ip saddr timeout 10m limit rate 60/minute burst 30 packets }. -threadsonly with the patched libvncserver. Stock 0.9.15's threaded mode lets a certificate holder race the encoder thread (heap overflow, use-after-free).
Other findings
Collected while writing these patches, not fixed here:
- No published CVE after 0.9.17 affects x11vnc's server side. CVE-2020-29074 (world-accessible shm) is already fixed in 0.9.17.
-wait 5 -defer 5cuts median draw-to-client latency from ~26-33ms to ~6ms, for 9% → 12% of a core. Defaults are 20/20.- zlib-ng as a drop-in
libz.so.1makes Tight frames ~11.5% smaller for the same screen; ZRLE is unaffected. - Not worth it:
-O3 -march=native -flto(no gain over-O2), Tight quality/compression levels (libvncserver does not use JPEG for text).
License
GPL-3.0-or-later, see LICENSE. The exception is the ebuilds and init scripts that are modified copies of Gentoo's: they are Gentoo's work under GPL-2, as their headers say, and stay that way. The patches are also offered under the licence of the project they patch, so they can go upstream.