Hi DEV! I'm Miguel, and for the last months I've been building MuDeskClient: a full remote desktop (RDP) client that runs in the browser, powered by a single PHP application. No database, no Composer packages, no daemons — it installs on ordinary shared hosting. It's free software, Apache-2.0.
miguelenred
/
mudeskclient
Remote desktop (RDP) client in the browser, with a gateway in plain PHP 8.1-8.5. No database, no dependencies, no build step.
MuDeskClient
Remote desktop (RDP) client that runs in the browser. The browser only uses HTML, CSS and JavaScript; a gateway written in plain PHP speaks RDP to the remote computers. Nothing has to be installed on the remote computers and no database is needed: all data is kept in JSON files.
Screenshots
Demo data: invented names and documentation addresses.
Features
- Bulk compression (MPPC, NCRUSH, XCRUSH) end to end and drawing orders with the bitmap cache: both links carry compressed data.
- RDP with TLS and NLA (CredSSP with Kerberos or NTLMv2) and, for Windows XP and Server 2003, Standard RDP Security; RDS licensing, 15/16/24/32-bit color. User names as
user,DOMAIN\user,HOST\user,.\user(local account of the server) oruser@domain(UPN). - Sign-in: users and administrator, optional TOTP and passkeys (passwordless, or a second step after the password: the…
This post is the story of the two decisions that shaped everything, what implementing RDP in pure PHP actually looked like, and the bugs that taught me the most.
The constraint that shaped the architecture
Every browser RDP gateway I know needs infrastructure: Guacamole needs guacd (a C daemon) and usually a database; commercial ones need Java, .NET or Node layers. I wanted to deploy for my clients on cheap shared hosting where you get exactly two things: PHP and MySQL. I decided to give up MySQL and see how far plain PHP goes.
That produces this architecture:
Browser PHP app Remote computers
──────── ──────── ────────────────
<canvas> + WebCodecs ⇄ rdp.php (long-lived request) ⇄ Windows / xrdp :3389
keyboard, mouse, POSTs speaks RDP natively, TLS (NLA, RD Gateway...)
The long-lived HTTP request to rdp.php is the RDP client: PHP opens the TLS connection to the remote computer and speaks the protocol itself. Graphics stay compressed on the wire all the way to the browser (H.264/AVC420 is decoded with WebCodecs; RemoteFX, ClearCodec and the rest in JavaScript on a canvas). Input, clipboard, drives and printers come back through short POSTs.
No daemon means: upload the files, point a domain, sign in. The trade-off — holding one PHP-FPM request open per session — was the most interesting engineering problem: output buffering, timeouts and process-per-connection limits vary on every host, and the documentation explains how to check and configure each one.
Implementing the protocol, layer by layer
The client is written against Microsoft's specifications (MS-RDPBCGR, MS-RDPGFX, MS-NLMP, MS-TSGU...):
- Transport and security: TLS 1.0–1.3 from PHP streams; NLA with CredSSP v6 — Kerberos (AES or RC4) or NTLMv2 — and, for Windows XP and Server 2003, the old Standard RDP Security.
- Graphics: the RDPGFX pipeline with AVC420, RemoteFX, RemoteFX progressive, ClearCodec and planar, plus the surface cache; and the classic path with MPPC/NCRUSH/XCRUSH bulk compression and drawing orders with a bitmap cache — both links carry compressed data.
- Everything else: full clipboard (text, HTML, images, files, drag & drop, a Win+V-style history), drive redirection (a server folder plus a folder of the user's own machine), a virtual PDF printer, remote audio, microphone and camera redirection, multi-monitor with dynamic layout, RemoteApp (RAIL), Wake-on-LAN, session recording and shareable session links.
-
The boring-but-hard parts: an RD Gateway (MS-TSGU over HTTPS, including the RPC-over-HTTP transport of Windows Server 2008) in plain PHP, and following a connection broker's redirection. Import/export of
.rdpfiles, TOTP and passkeys, OpenID Connect sign-in, and Windows-account sign-in validated through NLA without LDAP or any extension.
Stored RDP passwords are encrypted (AES-256-GCM) with a key derived from each user's own password, so not even the administrator can read them.
What I learned
1. The hardest part wasn't the protocol — it was the keyboard. Windows' own Notepad drops or repeats characters when its spell checker underlines a word, and it races you on Enter. The gateway now waits for each character's pause and keeps the order, and pastes instead of typing bursts. That single problem generated more test cases than half the protocol.
2. Old Windows servers are a museum. Server 2003 speaks RC4 Standard RDP Security, 2008 R2 needs TLS 1.0 and CredSSP version 3, and each era reports its capabilities differently. Supporting 2003 → 2022 meant building a compatibility table instead of assuming one protocol.
3. Fuzzing pays for itself immediately. The gateway and the browser decoders are fuzzed on every push (and nightly, 10–20k cases per target). So far it found 9 real bugs — 4 in the gateway, 5 in the browser decoders — all fixed. NTLMv2 is unit-tested against Microsoft's own MS-NLMP test vectors.
4. JSON files can replace a database for this kind of app: users, connections, audit logs (with tamper detection and signed export) all live in JSON files. For the target deployment — a handful of teams per host — it keeps the install to "upload and go".
5. Honest testing beats brave claims. Tested against real machines: Windows 11, Server 2022 (its RD Gateway with all three transports, its connection broker, Active Directory with Kerberos, RD licensing), 2012 R2, 2012, 2008 R2, 2008, 2003, xrdp and the FreeRDP 3 server. Not tested yet: broker redirection to a second session host, a real Hyper-V console, and Safari (I own no Apple device) — all written down in docs/TESTING.md, which I keep updated as coverage grows.
Try it
docker run -d -p 8443:443 -v mudesk-data:/var/www/html/data ghcr.io/miguelenred/mudeskclient
It is not a Guacamole replacement — it only does RDP — and it's young (first stable release days ago). What I need most now is people trying it in real environments: odd hosts, real RD Gateways, Hyper-V, whatever breaks.
What would you want it to do (or do differently)? I'd love your feedback — and I'm happy to answer questions about the protocol or the architecture. Thanks for reading!
``




Top comments (9)
Two things here will bite people on shared hosting long before the protocol does.
A session is one PHP-FPM worker held open for hours, so
pm.max_childrenquietly becomes your session cap — once those are taken, every other request on the site queues behind them and it looks like the whole host is down. Worth telling people to put MuDesk in its own pool with its own limit. The other half is the timeout in front of PHP: nginx'sfastcgi_read_timeoutis 60s by default, Apache'sProxyTimeoutis similar, so the socket gets cut while PHP is still sitting happily in its read loop, and any buffering proxy in between makes it worse. A keepalive no-op on the wire after ~30s of silence saves a support ticket per host.The key derivation worries me more. AES-256-GCM under a key derived from the user's own password means the moment that password is changed or reset by an admin, every stored RDP credential in their JSON file is unreadable — and it only shows up at connect time, on a machine nobody is watching. How do you handle it today: re-encrypt on password change, or is there a separate per-user KEK that survives it?
Both fair — one's already documented, the other is a deliberate trade.
Capacity: docs/HOSTING.md has the sizing formula (pm.max_children = sessions + 10) and literally recommends a dedicated FPM pool for rdp.php. The app also caps itself (max_sessions_total, measured by tools/check.php before install) — at the limit a new session gets "server busy" instead of queueing the site. The stream sends a keep-alive frame every 10 s, which resets those fastcgi_read_timeout/ProxyTimeout timers.
Key derivation: there is a per-user data key that survives password changes (re-wrapped at next sign-in) — but saved RDP credentials are deliberately NOT under it: they're derived from the user's own password, so a change or admin reset forgets them. A KEK that survived would have to live server-side, and that ends "not even the administrator can read them". Cost: re-enter credentials after a password change.
The keyboard lesson is my favorite part — that the hardest problem in implementing an entire remote desktop protocol was Notepad's spell checker racing you on Enter is the kind of thing you only learn by shipping it. Waiting for each character's pause and pasting instead of typing bursts is a beautifully unglamorous fix. The constraint that shaped it is just as interesting: giving up MySQL to fit on cheap shared hosting, then holding one PHP-FPM request open per session and documenting how each host's buffering and timeouts behave. And the honesty in TESTING.md — listing broker redirection to a second session host, a real Hyper-V console, and Safari as not tested yet — is exactly what makes me trust the claims that are tested. One question: with fuzzing finding 9 real bugs so far, was there one that surprised you most — a place where the protocol spec and a real server disagreed in a way you hadn't expected?
Honest answer: the spec was almost never the problem — the real servers were.
The fuzzer (a tool that throws random garbage at the code) found 9 bugs, but those were all my parsers being too trusting: no malformed input should ever crash anything.
The surprises came from plugging into real Windows machines. My favorite: the documentation says "offer feature X and the server will use it" — and Windows quietly picks an older one instead. On some virtual machines it refuses to send video at all, no matter what you offer. Nothing was broken; each Windows version just speaks its own dialect of the spec.
So the client now simply asks the server what it can do when it connects, and adapts. Fighting the documentation was never going to work.
For clients accessing a RemoteApp from unmanaged devices, can you disable clipboard and drive redirection separately for each connection?
Yes — each redirection is a separate per-connection setting. When an administrator creates a connection (Administration → Connections, assigned to specific users or to all), these can each be turned off individually: clipboard, shared folder (drive redirection), MuDeskPDF printer, remote audio, and microphone/camera.
On those admin-managed connections, the user can leave a redirection off but cannot turn it back on: in the connect dialog the box shows unticked and greyed out, with the note "The administrator has turned it off for this connection". Users keep their own saved password and options, but the redirections you disabled stay out of their reach.
Thanks for explaining how administrators disable each redirection per connection, Miguel. I build BrowserBox, which streams a remote browser for web applications and can block clipboard copy-out and downloads for unmanaged clients; it is for browser sessions rather than Windows RemoteApps: browserbox.io/go/forum-20261126-de...
9 fuzzing bugs, 4 in the gateway and 5 in the browser decoders, made me ask whether my own parsers would survive the same treatment?
Probably not — mine didn't either, and that's the whole point. Nine real bugs, all found before a user could. It's an afternoon to try: take the function that reads your wire format, throw random bytes and mutated real captures at it, and treat even a PHP warning as a failure. Worth it.
Some comments have been hidden by the post's author - find out more