Recording RDP and VNC sessions with guacd, and seven things that broke
A desktop session is harder to record honestly than a terminal. There is no text to keep, the clipboard is a door nothing records, and a supervisor watching must not be able to type. This is how EnvMap does it with guacd, and what went wrong on the way.
EnvMap is an open-source, self-hosted control plane with a privileged access manager (PAM) in it. People open SSH, RDP and VNC sessions from the browser, never see the password, and every session is recorded. An earlier post covered SSH. This one is about the desktops.
All of the code is in the repository, mostly in app/pam.py.
The shape: a relay in front of guacd#
EnvMap does not speak RDP or VNC itself. guacd, the daemon at the heart of Apache Guacamole, does. It connects to the desktop, draws it as a stream of simple drawing instructions, and the browser paints them with Guacamole's own JavaScript client.
EnvMap sits between the two:
- The browser opens a WebSocket to EnvMap, never to guacd. The person's permission, the production gate and the reason for access are checked here, exactly as for SSH.
- EnvMap opens the connection to guacd and fills in the parameters: the address, the username, and the password, unsealed from EnvMap's database at that moment.
- guacd connects to the desktop and streams the picture back through EnvMap to the browser.
The password goes no further than guacd. The browser receives pictures, not credentials.
guacd runs as a sidecar in EnvMap's own pod (or beside it, in the Docker Compose install), and EnvMap reaches it at 127.0.0.1:4822. Without it, RDP and VNC targets say so and cannot connect. SSH does not need it.
What the recording holds#
guacd can write a recording of everything it draws. EnvMap asks it to, into the same store as the SSH recordings, and asks it to leave keystrokes out. The reason is the one from the SSH post: a password typed at a login prompt must not sit in a file. So a desktop recording is the screen, without the keys.
When the session ends, EnvMap takes a SHA-256 checksum of the file. Each time the replay page opens, it computes it again, and the page says recording verified or recording altered since it was filed.

Desktop recordings are big. An SSH cast runs at about 6 bytes a second. A guacd recording runs at about 9,000. So retention is a setting, by age and by total size, and it is off by default: deleting somebody's evidence must be a choice they made.
The clipboard is a door nothing records#
guacd leaves clipboard data out of its recordings. That makes sense for privacy, and it means text copied out of a production desktop leaves no trace in the evidence. For a tool whose job is to answer "what left that machine", that is the obvious way out.
So the clipboard is a policy, for the whole installation and per target:
- copy and paste both ways, the default, because that is what people expect;
- paste in only: the operator can paste a command in, nothing can be copied out;
- off in both directions.
guacd enforces it per connection. EnvMap only chooses which.
Watching without a keyboard#
A supervisor can watch a live desktop session, or take control of it. Both rest on a guacd feature: a second client can join a connection that is already running. Nothing is captured twice, and there is one recording. The watcher sees exactly what the recording holds.
Guacamole treats sharing as a normal feature, so guacd accepts mouse and keyboard from anybody joined to a connection. "Read-only" is therefore not something joining gives you. It is a filter in EnvMap: everything a watcher's browser sends is dropped except sync, guacd's flow control, which has to pass or the stream stalls. disconnect is dropped in both directions, so neither a watcher nor a controller can hang up on the operator. The filter is one small function, so it can be tested on its own.
Taking control needs the same permission as opening a session. Watching and taking control are both written to the audit log.

Seven things that broke#
Most of these were found by one end-to-end run against real servers: a real guacd, xrdp and x11vnc in containers, real WebSockets, a real browser. None of them showed up in unit tests.
1. An emoji in a password broke the handshake#
The guacd protocol prefixes every value with its length, as LEN.VALUE. EnvMap counted the length in UTF-16 units, which is what JavaScript and many libraries count. guacd counts code points. The two agree for almost every character, and disagree by one for anything outside the Basic Multilingual Plane, such as an emoji. A password with one in it made the connect instruction one character longer than it said, and guacd refused the whole handshake. The lengths are now counted in code points.
2. The browser choked on half an instruction#
guacd sends a TCP stream, and EnvMap read it in fixed chunks. A chunk ends wherever the read lands, often in the middle of an instruction. Guacamole's browser client parses each WebSocket message on its own and keeps nothing between messages, so half an instruction is an error ("Invalid array length"). The relay now holds back a partial instruction until the rest arrives, and forwards only whole ones. It finds the boundary by the lengths, never by looking for ;, because a password or the clipboard can contain one.
3. Every RDP target failed through the sidecar#
"Security negotiation failed", on every RDP target, only through the shipped sidecar. The container's user had no home directory: HOME was / on a read-only filesystem, and FreeRDP, inside guacd, could not create its certificate store. The Helm chart now gives guacd a writable home on a scratch volume, and a gateway from an older release is recognised and repaired in place.
4. Moving the mouse too early killed a VNC session#
The browser starts reporting the pointer the moment the pane appears. guacd 1.5's VNC client crashed on a mouse event that arrived before its display existed: 49 bytes and a dead session. Until the first frame is drawn, the relay now passes everything except input.
5. "The recording is blank"#
It was reported with a screenshot of an empty box. The recording was fine: 126 seconds, verified, with a picture on screen for most of its length. The player had never drawn a frame. A Guacamole display is zero by zero until a frame is applied, and nothing applied one when the page loaded.
The fix was a poster frame, and the first attempt got two things wrong. A seek issued while the file is still downloading is silently dropped, so the seek must wait until the file has loaded. And it must not go to zero: at 0 ms that recording was 0% lit, and at 500 ms it was 100%. The page now seeks a little way in.
6. Every desktop recording said it had been altered#
The checksum is taken when the session is filed, which is when the relay lets go. But guacd keeps writing the recording for a moment after its socket closes. So the checksum was taken over a file that was still growing, and every genuine desktop recording read altered on replay. Filing now waits until the file has stopped growing.
7. The idle timeout never fired#
A session with no input for 30 minutes is closed. The relay counted any traffic from the browser as activity. But the browser acknowledges every frame guacd draws with a sync, so a desktop with a clock on it, or a log scrolling, kept the session busy with nobody there. Only a person's input counts now: mouse, keys, clipboard, a resize.
What it does not do#
- There is no command list for a desktop. An SSH session keeps the commands as text, to search. A desktop recording is pictures, to watch.
- What passes through the clipboard is not recorded. The policy above can close it. It cannot record it.
- Sessions open in the browser. There is no proxy for a native RDP or VNC client.
- It records and does not stop. Nothing on the screen is filtered or blocked.
Try it#
RDP and VNC come with EnvMap, with guacd as a sidecar in the Helm chart. On one machine, the Docker Compose guide runs the portal and guacd side by side. In a cluster:
helm install envmap oci://ghcr.io/ammar-hassoun/devops-portal-charts/config-portal \
--namespace envmap --create-namespaceThen add a desktop as a target: Targets, Sessions and Recordings in the docs. The code is on GitHub.
Apache Guacamole and guacd are projects of the Apache Software Foundation. EnvMap is an independent open-source project that uses guacd and is not endorsed by the Foundation.
EnvMap home · Docs · GitHub