---
title: "Discussion on \"How EnvMap records a privileged session, and seven things that broke on the way\" | Hashnode"
description: "Discussion on \"How EnvMap records a privileged session, and seven things that broke on the way\". How EnvMap's open-source PAM records SSH, RDP and VNC sessions without keeping secrets, and seven bugs found while building it."
url: "https://hashnode.com/posts/how-envmap-records-a-privileged-session-and-seven-things-that-broke-on-the-way/6b0c6c4c22db662209f3dcb7"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [How EnvMap records a privileged session, and seven things that broke on the way](https://envmap.hashnode.dev/how-envmap-records-a-privileged-session-and-seven-things-that-broke-on-the-way?utm_source=hashnode&utm_medium=feed)

How EnvMap's open-source PAM records SSH, RDP and VNC sessions without keeping secrets, and seven bugs found while building it.

2d ago · 9 min read · envmap.hashnode.dev  
Read the article

-   [#devops](https://hashnode.com/tag/devops)
-   [#security](https://hashnode.com/tag/security)
-   [#opensource](https://hashnode.com/tag/opensource)
-   [#ssh](https://hashnode.com/tag/ssh)

## Written by

[Ammar Hassoun](https://hashnode.com/@ammarhassoun)

@ammarhassoun

  
[View profile](https://hashnode.com/@ammarhassoun)

DevOps engineer, maintainer of EnvMap

I maintain EnvMap, an open-source, self-hosted DevOps control plane: Kubernetes, GitOps, certificates and a privileged access manager that records SSH, RDP and VNC sessions. I write about what broke while building it.

## Responses 2

Markdown supported · ⌘↵ to post

[c-wind](https://hashnode.com/@c-wind)

[11h ago](https://hashnode.com/posts/how-envmap-records-a-privileged-session-and-seven-things-that-broke-on-the-way/6b0c6c4c22db662209f3dcb7/comment/6b0ecaff837e335bc00918a0)

The bracketed-paste bug is a particularly sharp example of how a terminal-protocol detail can poison a higher-level policy. If the logger treats ESC\[200~~...ESC\[201~~ as typed text, two things go wrong at once: the command log is corrupted with the CSI markers, and because those bytes are not echoed, the "host did not echo it, therefore secret" rule hides a paste that was often a perfectly ordinary command. Skipping the whole sequence without swallowing a lone ESC (vi mode) is the right shape for that fix.

The broader caveat you already hint at is worth keeping in the foreground: reconstructing "commands" from keystrokes plus echo is a client-side hint, not proof of what the shell actually ran. Aliases, delayed echo, and multiline pastes can all disagree with the reconstructed line, which pairs naturally with the post's own limit that this records commands and does not stop them. Bug 3 (raw mode on macOS leaking through ssh -tt so the remote shell stops doing ONLCR) is another reminder that PTY state is shared more widely than the recording path first assumes.

[Ammar Hassoun](https://hashnode.com/@ammarhassoun)

[8h ago](https://hashnode.com/posts/how-envmap-records-a-privileged-session-and-seven-things-that-broke-on-the-way/6b0c6c4c22db662209f3dcb7/comment/6b0ecaff837e335bc00918a0#reply-6b0ef64c84839721129c45fe)

Thanks, that's a careful read, and you put the limit more plainly than the post did.

Yes: the command list is rebuilt from keystrokes and echo at the edge of the session, so it shows what the person typed, not what the shell ran. An alias shows up as the alias, and anything the remote side runs by itself never appears as a "command" at all. That's why the replay of the output is the main record and the command list is the second one, there to search, not to stand alone. Proof of what actually executed would have to come from the host itself, such as auditd or shell history shipped off the machine, and EnvMap doesn't claim that.

Agreed on the PTY point too. The staircase took a while precisely because nobody expected a mode set on our side to reach the remote shell.
