<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[EnvMap Engineering]]></title><description><![CDATA[EnvMap Engineering]]></description><link>https://envmap.hashnode.dev</link><image><url>https://cdn.hashnode.com/uploads/logos/6b0bcb6bb775e5280ac1aab7/f69e8157-b8ff-4ba7-8243-c3739fdab81d.png</url><title>EnvMap Engineering</title><link>https://envmap.hashnode.dev</link></image><generator>RSS for Node</generator><lastBuildDate>Sat, 05 Dec 2026 00:34:21 GMT</lastBuildDate><atom:link href="https://envmap.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[How EnvMap records a privileged session, and seven things that broke on the way]]></title><description><![CDATA[How EnvMap's open-source PAM records SSH, RDP and VNC sessions without keeping secrets, and seven bugs found while building it.]]></description><link>https://envmap.hashnode.dev/how-envmap-records-a-privileged-session-and-seven-things-that-broke-on-the-way</link><guid isPermaLink="true">https://envmap.hashnode.dev/how-envmap-records-a-privileged-session-and-seven-things-that-broke-on-the-way</guid><category><![CDATA[Devops]]></category><category><![CDATA[Security]]></category><category><![CDATA[Open Source]]></category><category><![CDATA[ssh]]></category><dc:creator><![CDATA[Ammar Hassoun]]></dc:creator><pubDate>Sun, 29 Nov 2026 18:17:48 GMT</pubDate><content:encoded><![CDATA[<p><em>A session recording is evidence. It has to show what happened, hold no secrets, and still be believed a year later. This is how EnvMap's privileged access manager does it, and what went wrong before it worked.</em></p>
<p>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, the credential never leaves the server, and every session is recorded. This post is about the recording: the three decisions behind it, and seven bugs that only showed up when it ran against real servers.</p>
<p>All of the code is in <a href="https://github.com/ammar-hassoun/envmap">the repository</a>, mostly in <code>app/pam.py</code> and <code>app/kmanage.py</code>.</p>
<h2>Three things a recording has to do</h2>
<ol>
<li><strong>Show what happened.</strong> Not a summary of it: the error that scrolled past, the menu somebody picked from, the diff a script printed before it acted.</li>
<li><strong>Hold no secrets.</strong> A recording that contains the root password is a liability with a play button.</li>
<li><strong>Be provable.</strong> Somebody will ask, months later, whether this file is the one that was written that day.</li>
</ol>
<p>Each one shaped the design.</p>
<h2>Record the screen, never the keys</h2>
<p>An SSH session is recorded as an <a href="https://docs.asciinema.org/manual/asciicast/v2/">asciinema v2</a> cast: one JSON header line, then one line for each chunk of output.</p>
<pre><code class="language-text">{"version": 2, "width": 120, "height": 32, "timestamp": 1795862400}
[0.412, "o", "web-lb-01:~# "]
[2.108, "o", "nginx -t\r\n"]
[2.174, "o", "nginx: configuration file /etc/nginx/nginx.conf test is successful\r\n"]
</code></pre>
<p>Only output is written. Keystrokes never are. That one rule is what keeps passwords out: a password typed at a prompt with echo turned off never appears in the output stream, because the host does not send it back. A recording of keystrokes would hold it in full.</p>
<p>The format was chosen because it is boring. <code>asciinema play</code> reads the file, and the replay page plays it with the terminal emulator the product already ships, so there is no player to bundle.</p>
<p>Desktops go through <code>guacd</code>, the Apache Guacamole daemon, which draws RDP and VNC in the browser and writes the recording itself. It is told to leave key events out (<code>recording-include-keys: false</code>), for the same reason.</p>
<h2>The commands are a second record</h2>
<p>A replay answers "what did the screen show". An auditor usually starts with a different question: "what did they run". So EnvMap also keeps the commands of an SSH session as text.</p>
<p>A terminal has no command boundary. It has a stream of keystrokes. To turn that into commands, Backspace and Ctrl+U are applied rather than written down, so the log holds each line as the person finished writing it, and a line is closed when Enter arrives.</p>
<p>Then there is the secret problem again. The rule is the same one, seen from the other side: <strong>a line is a secret if the host did not echo it.</strong> A shell echoes each character as it is typed, so by the time Enter is pressed the line has already come back in the output. If it did, it is recorded. If it did not, only its length is kept:</p>
<pre><code class="language-text">sudo systemctl reload nginx
&lt;hidden — 14 characters typed&gt;
</code></pre>
<h2>Seven things that broke</h2>
<h3>1. Every command came out hidden</h3>
<p>The first version of that rule waited for the command to appear in the output <strong>after</strong> Enter. A shell never prints a command again after running it. So every real command was judged "not echoed" and written down as hidden, and the transcript of a busy session was a column of <code>&lt;hidden&gt;</code> lines.</p>
<p>The echo is in what arrives <strong>while</strong> the line is being typed. The check now looks there, and keeps looking for a moment after Enter, because over a slow link the last characters of the echo can still be in flight.</p>
<h3>2. A paste was written down as <code>[200~</code></h3>
<p>Modern shells ask the terminal for bracketed paste, so pasted text arrives wrapped in <code>ESC[200~</code> and <code>ESC[201~</code>. The recorder dropped the <code>ESC</code> and kept the rest, so a pasted command was logged as <code>[200~systemctl status nginx[201~</code>. Worse, because those first characters are never echoed, some pasted commands were logged as hidden.</p>
<p>An escape sequence is a key, not text. The fix was to skip the whole sequence, with one care: an <code>ESC</code> pressed alone, as in vi mode, must not swallow what is typed after it.</p>
<h3>3. The staircase</h3>
<p>On macOS, during development, every SSH prompt landed further right than the last one:</p>
<pre><code class="language-text">web-lb-01:~#
             web-lb-01:~#
                          web-lb-01:~#
</code></pre>
<p>The terminal was put in raw mode on the controlling side of the pseudo-terminal. On macOS the two sides share their settings, so that also switched off output processing on the other side. <code>ssh -tt</code> copies the local terminal's modes into its request for a remote terminal, so the remote shell stopped turning a line feed into carriage return plus line feed. The same code driving <code>kubectl exec</code> was fine, because kubectl negotiates the container's own terminal. SSH sessions now leave the mode alone and let <code>ssh</code> set it.</p>
<h3>4. A space in a folder name</h3>
<p>Host keys are pinned on first use, in a known-hosts file for each session. With the data directory under a path containing a space, the first connection failed with a message that named half a path. <code>ssh -o UserKnownHostsFile=</code> takes a <strong>space-separated list</strong> of files, so one path with two spaces in it was read as three files. Quoting the value does not help: ssh keeps the quotes. Each session's key and known-hosts file now live on a path with no spaces.</p>
<h3>5. An emoji in a password</h3>
<p>guacd's protocol is length-prefixed. An instruction looks like this:</p>
<pre><code class="language-text">6.select,3.rdp;
</code></pre>
<p>EnvMap builds those by hand, because it is the small relay that the Guacamole web application usually is. The length was counted in UTF-16 units, and guacd counts code points. The two agree for most characters and differ by one for each character outside the Basic Multilingual Plane. A password with an emoji in it made the <code>connect</code> instruction one longer than it claimed, and guacd refused the whole handshake. It showed up only against a real guacd.</p>
<p>The framing is always computed, never glued together from strings. In a protocol whose delimiters can appear inside a password, that is the same discipline as passing arguments as a list instead of building a shell command.</p>
<h3>6. Every desktop recording said it had been altered</h3>
<p>When a session ends, EnvMap takes a SHA-256 of the recording and stores it. Every time the replay page opens, it computes the checksum again and compares.</p>
<p>The first desktop recordings all failed their own check. guacd goes on writing for a moment after its socket closes. A checksum taken at once was of a file that then grew: one RDP recording was filed at 10,640 bytes and found at 10,720. Every genuine recording reported itself tampered.</p>
<p>The session now waits until the file has stopped growing for a second and a half before it files it. The lesson was about the claim, not the hash: a checksum is only a statement about the evidence if it is taken after the evidence is finished.</p>
<p>The check has five answers, not two, because the dull cases matter:</p>
<table>
<thead>
<tr>
<th>State</th>
<th>What it means</th>
</tr>
</thead>
<tbody><tr>
<td>verified</td>
<td>The file is byte for byte what was filed</td>
</tr>
<tr>
<td>tampered</td>
<td>It is not</td>
</tr>
<tr>
<td>expired</td>
<td>A retention rule removed it, and when</td>
</tr>
<tr>
<td>missing</td>
<td>The file is gone and nothing explains it</td>
</tr>
<tr>
<td>none</td>
<td>There was never a checksum</td>
</tr>
</tbody></table>
<p>Without "expired", a retention policy doing its job looks exactly like evidence going astray.</p>
<h3>7. A session that lasted zero seconds</h3>
<p>A web application can be recorded by opening it in a browser that EnvMap starts as a pod, and letting guacd record that browser like a desktop. A pod takes time to schedule, and the Guacamole client library gives up after 15 seconds without an incoming instruction. An RDP host answers in under a second, so nobody had noticed. The client reported "Server timeout", and the server filed a session zero seconds long.</p>
<p>Two changes: the page waits longer, and while the browser is being built the relay sends the protocol's own <code>nop</code> every three seconds, so the client can tell slow from dead.</p>
<h2>When the server dies mid-session</h2>
<p>A recording that exists only if the session ends cleanly is not evidence. Each session's row is written when it opens, with the path of its recording. If the process dies, the next start finds the rows that were still marked running, files them as <strong>interrupted</strong>, and indexes and checksums each recording as it stands. What happened before the crash is kept, and provable.</p>
<h2>What the recording does not see</h2>
<p>A file copied over SFTP is not terminal output, so the recording cannot show it leaving. Every transfer is written to the audit log instead, by name, direction and size, and the refused ones are logged too. A failed attempt to read <code>/etc/shadow</code> is exactly the line somebody will want to find.</p>
<p>One detail from that code: <code>sftp -b</code> reads one command per line, so a newline inside a file name is not a quoting problem. It is a second command, run with the target's credential. Such a path is refused, not escaped.</p>
<h2>What it still does not do</h2>
<ul>
<li>It records commands and does not stop them. There is no command filtering.</li>
<li>There is no automatic credential rotation. (When this post was written there were no access requests with approval either. They arrived in 0.7.79, together with <a href="https://envmap.tech/blog/ssh-without-stored-keys/">SSH certificates that last five minutes</a>.)</li>
<li>Sessions open in the browser. There is no proxy for your own <code>ssh</code> client.</li>
<li>A checksum in the same database as the session proves a file was not changed by accident or by somebody without database access. It does not stop somebody who can rewrite both.</li>
</ul>
<h2>Try it</h2>
<p>The quickest look is <a href="https://envmap.tech/demo/pam-replay/">the demo</a>, which replays a recorded session in your browser. To run it on one machine:</p>
<pre><code class="language-bash">curl -fsSLO \
  https://raw.githubusercontent.com/ammar-hassoun/envmap/main/deploy/compose/compose.yaml
ENVMAP_MODE=pam docker compose up -d
</code></pre>
<p>Then open <code>http://localhost:8471</code>. More about it: <a href="https://envmap.tech/pam/">the PAM page</a>, <a href="https://envmap.tech/pam/compare/">how it compares with JumpServer, Teleport, Warpgate and Guacamole</a>, and the docs on <a href="https://envmap.tech/docs/pam/recordings/">recordings</a> and <a href="https://envmap.tech/docs/pam/sessions/">sessions</a>.</p>
<p>If you have built a recorder and solved one of these differently, <a href="https://github.com/ammar-hassoun/envmap/discussions">tell us how</a>.</p>
<hr />
<p><em>First published on <a href="https://envmap.tech/blog/how-envmap-records-a-session/">envmap.tech</a>. EnvMap is open source under Apache-2.0: <a href="https://github.com/ammar-hassoun/envmap">github.com/ammar-hassoun/envmap</a>.</em></p>
]]></content:encoded></item><item><title><![CDATA[When a dashboard cannot see, it must say so]]></title><description><![CDATA[Four times an empty list hid a system that did not answer. How each was found, and the rule that came out of them: could not ask is never zero.]]></description><link>https://envmap.hashnode.dev/when-a-dashboard-cannot-see-it-must-say-so</link><guid isPermaLink="true">https://envmap.hashnode.dev/when-a-dashboard-cannot-see-it-must-say-so</guid><category><![CDATA[Devops]]></category><category><![CDATA[Kubernetes]]></category><category><![CDATA[monitoring]]></category><category><![CDATA[Open Source]]></category><dc:creator><![CDATA[Ammar Hassoun]]></dc:creator><pubDate>Sun, 29 Nov 2026 07:24:48 GMT</pubDate><content:encoded><![CDATA[<p><em>An empty list on a dashboard means one of two things. Either there is nothing there, or the dashboard could not find out. The first is good news. The second is no news, dressed as good news. Telling them apart is most of what makes a dashboard worth trusting.</em></p>
<p>EnvMap reads a lot of other systems: Kubernetes clusters, Argo CD, Prometheus, Alertmanager, Grafana, CI servers, scanners, certificate stores, hypervisors, server hardware. Any of them can be slow, down, or refuse the credential it was given. Every page has to decide what to show when that happens.</p>
<p>The easy answer is to show what came back. When nothing came back, that is an empty list, and an empty list looks clean. This post is about the four times EnvMap shipped that easy answer, and the rule that replaced it.</p>
<h2>1. A cluster that could not be read looked like a cluster with nothing expiring</h2>
<p>The Expiry radar collects every TLS certificate in every cluster and sorts them by when they run out. To find them it asks each cluster for its secrets of type TLS.</p>
<p>A read-only kubeconfig without permission to list secrets cluster-wide is an ordinary thing to be handed. <code>kubectl</code> answered <code>Error from server (Forbidden)</code>, the function that ran it returned an empty string for any failure, and the parser read an empty string as "no certificates". That cluster then showed on the radar as having nothing to worry about.</p>
<p>The fix was to make the read return the error with the text, and to carry kubectl's own sentence to the page. "Forbidden" is the diagnosis. Hiding it hid the reason and the problem together.</p>
<h2>2. An alert panel that said "nothing firing" about systems it could not reach</h2>
<p>The Overview can show a panel of firing alerts from every connected monitoring system. The first version asked each one in parallel and skipped any that returned nothing.</p>
<p>An unreachable Prometheus returned nothing. So a panel over three systems, none of which answered, said <strong>nothing firing</strong>, which is exactly what a person glancing at a wall screen wants to read, and exactly what was not known.</p>
<p>Now every system that did not answer is named on the panel as not answering, and when none answered the panel draws no counts at all. A zero is a measurement. It may only appear when something was measured.</p>
<h2>3. Silenced alerts counted as firing, and firing alerts counted as silenced</h2>
<p>The same panel had a second problem: each platform words alert state differently. Prometheus says <code>firing</code>. Alertmanager and Grafana say <code>active</code>. Silenced alerts are <code>suppressed</code>, <code>silenced</code> or <code>inhibited</code> depending on who you ask.</p>
<p>One page treated anything that was not <code>active</code> as muted, so every firing Prometheus alert was counted as suppressed. Another counted Grafana's silenced alerts in the firing tiles. Both pages showed plausible numbers, and both were wrong.</p>
<p>The fix was one vocabulary, set in one place, that every platform's answer passes through before anything counts it. A page counts that one list, never the raw words.</p>
<h2>4. A page that was as slow as the slowest thing it read</h2>
<p>This one looks like a performance bug, and it is the same bug.</p>
<p>On an estate of 24 clusters and 10 connections, with nothing cached yet, the GitOps page took 19.6 seconds to open. Server hardware took 16.1. The Overview took 10.4. Every one of those pages rendered in under 15 milliseconds once its data was in memory. The time was spent waiting for the one cluster that was not answering.</p>
<p>The obvious fix is a timeout. But a page that gives up after a timeout and shows what arrived has a new problem: a table of 8 clusters on an estate of 24, with nothing to explain the gap. That page lies faster than the old one.</p>
<p>So the fix has two halves:</p>
<ul>
<li><strong>Draw what has arrived</strong> within a fixed deadline, a fraction of a second, and keep reading in the background.</li>
<li><strong>Say what is missing.</strong> The page names the systems it is still reading, and fills them in when they answer.</li>
</ul>
<p>Measured afterwards: the GitOps page in 0.45 seconds, hardware in 0.42, the Overview in 0.45, each saying out loud which clusters were still on their way.</p>
<h2>The rule</h2>
<p>Out of those four came one rule, now written into how every page is built:</p>
<blockquote>
<p>A system that did not answer shows a dash or an error, never a zero. A list that could not be read is an error, never an empty list. A page still waiting on a slow system says which one.</p>
</blockquote>
<p>It sounds obvious. It was broken four times by code that was correct about everything it looked at. In each case the failure was invisible, because the wrong answer was the reassuring one.</p>
<h2>Why this matters more for an operations tool</h2>
<p>A wrong number on a sales dashboard misleads a meeting. A wrong "nothing expiring" or "nothing firing" on an operations dashboard is the reason nobody looks, until the certificate expires or the alert becomes an outage.</p>
<p>So the question to ask of any dashboard, including EnvMap, is not "is it green" but "would it tell me if it could not see". Unplug one of its sources and look at the page.</p>
<h2>Try it</h2>
<p>EnvMap is open source under Apache-2.0. The <a href="https://envmap.tech/demo/">demo</a> shows the real screens with pretend data, and it runs on one machine with Docker Compose:</p>
<pre><code class="language-bash">curl -fsSLO \
  https://raw.githubusercontent.com/ammar-hassoun/envmap/main/deploy/compose/compose.yaml
docker compose up -d
</code></pre>
<p>More on how it behaves: <a href="https://envmap.tech/docs/reference/security-model/">the security model</a>, and another post from the EnvMap blog, <a href="https://envmap.tech/blog/how-envmap-records-a-session/">how a privileged session recording is built</a>.</p>
<hr />
<p><em>First published on <a href="https://envmap.tech/blog/none-and-could-not-ask/">envmap.tech</a>. Written with help from an AI assistant; every detail was checked against EnvMap's code.</em></p>
]]></content:encoded></item></channel></rss>