<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Security on TurboVision</title>
    <link>https://mobile.dev.turbovision.in6-addr.net/articles/security/</link>
    <description>Recent content in Security on TurboVision</description>
    <generator>Hugo</generator>
    <language>en</language>
    <lastBuildDate>Fri, 27 Nov 2026 12:54:29 +0000</lastBuildDate>
    <atom:link href="https://mobile.dev.turbovision.in6-addr.net/articles/security/index.xml" rel="self" type="application/rss&#43;xml" />
    
    
    
    <item><title>ssh2shell</title>
      <link>https://mobile.dev.turbovision.in6-addr.net/articles/security/ssh2shell-controlmaster-considered-harmful/</link>
      <pubDate>Thu, 26 Nov 2026 00:00:00 +0000</pubDate>
      <lastBuildDate>Thu, 26 Nov 2026 00:00:00 +0000</lastBuildDate>
      <guid>https://mobile.dev.turbovision.in6-addr.net/articles/security/ssh2shell-controlmaster-considered-harmful/</guid>
      <description>&lt;p class=&#34;article-subtitle&#34;&gt;ControlMaster considered harmful&lt;/p&gt;&lt;p&gt;&lt;em&gt;How an innocent performance optimization turns an authenticated SSH connection into a reusable local security capability.&lt;/em&gt;&lt;/p&gt;
&lt;h2 id=&#34;it-starts-with-a-performance-problem&#34;&gt;It starts with a performance problem&lt;/h2&gt;
&lt;p&gt;Anyone who automates infrastructure over SSH eventually encounters the same problem: opening connections is expensive. Running a single remote command may take less time than establishing the connection required to execute it. Multiply that overhead by hundreds of commands, dozens of hosts, repeated file transfers or an entire deployment pipeline, and the temptation to optimize becomes obvious.&lt;/p&gt;
&lt;p&gt;Every new SSH connection normally requires a TCP connection, SSH protocol negotiation, cryptographic key exchange, server identity verification and user authentication. On a high-latency network, the round trips alone can be significant. Add a hardware-backed key or an interactive second factor and the cost is no longer merely computational. It becomes operational.&lt;/p&gt;
&lt;p&gt;OpenSSH offers a rather elegant solution: &lt;code&gt;ControlMaster&lt;/code&gt;. Authenticate once, keep the connection open and reuse it for subsequent invocations of &lt;code&gt;ssh&lt;/code&gt;, &lt;code&gt;scp&lt;/code&gt; or &lt;code&gt;sftp&lt;/code&gt; where supported.&lt;/p&gt;
&lt;p&gt;It works remarkably well. And that is precisely why it deserves closer scrutiny.&lt;/p&gt;
&lt;p&gt;To understand what we are optimizing away, we first need to look at what happens during authentication — and what remains after it has finished.&lt;/p&gt;
&lt;h2 id=&#34;a-key-is-more-than-a-way-to-log-in&#34;&gt;A key is more than a way to log in&lt;/h2&gt;
&lt;p&gt;Public-key authentication establishes that a client possesses the private key corresponding to a public key accepted by the server. The private key itself does not need to leave the client; it is used to produce a cryptographic signature.&lt;/p&gt;
&lt;p&gt;On a typical OpenSSH server, an administrator can authorize a public key through &lt;code&gt;authorized_keys&lt;/code&gt;. But an entry in this file can represent much more than permission to log in. It can also impose restrictions on what that authenticated connection may do.&lt;/p&gt;
&lt;p&gt;Consider a server with a dedicated automation account. Two independent jobs use the same Unix account, but they have different keys and different responsibilities. One collects status information; the other deploys software.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;div class=&#34;chroma&#34;&gt;
&lt;table class=&#34;lntable&#34;&gt;&lt;tr&gt;&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;lnt&#34;&gt;1
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;2
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-text&#34; data-lang=&#34;text&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;restrict,command=&amp;#34;/usr/local/bin/read-status&amp;#34; ssh-ed25519 AAAA... status-key
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;restrict,command=&amp;#34;/usr/local/bin/deploy&amp;#34; ssh-ed25519 AAAA... deploy-key&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;p&gt;The key material is abbreviated here. The significant part is the &lt;code&gt;command&lt;/code&gt; option: instead of allowing the client to select an arbitrary command, the server runs the designated command when a session requests execution. The &lt;code&gt;restrict&lt;/code&gt; option also disables several facilities, including forwarding and PTY allocation.&lt;/p&gt;
&lt;p&gt;Assuming the command implementations are themselves secure, this is a useful least-privilege design. The status job does not need deployment authority, even though both jobs operate through the same remote account.&lt;/p&gt;
&lt;p&gt;&lt;a href=&#34;https://mobile.dev.turbovision.in6-addr.net/articles/security/ssh2shell-controlmaster-considered-harmful/ssh2shell-controlmaster-considered-harmful-separate-keys.svg&#34;&gt;&lt;img src=&#34;https://mobile.dev.turbovision.in6-addr.net/articles/security/ssh2shell-controlmaster-considered-harmful/ssh2shell-controlmaster-considered-harmful-separate-keys.png&#34; alt=&#34;Separate keys and forced commands&#34;&gt;
&lt;/a&gt;
&lt;/p&gt;
&lt;details class=&#34;mermaid-source&#34;&gt;
  &lt;summary class=&#34;mermaid-source-summary&#34;&gt;Diagram source (Mermaid)&lt;/summary&gt;
  &lt;pre&gt;&lt;code class=&#34;language-mermaid&#34;&gt;flowchart LR
    A[Status job] --&amp;amp;gt;|Status key| S[SSH authentication A]
    B[Deployment job] --&amp;amp;gt;|Deploy key| T[SSH authentication B]
    S --&amp;amp;gt; U[read-status]
    T --&amp;amp;gt; V[deploy]
    subgraph Server[Same remote Unix account]
        S
        T
        U
        V
    end&lt;/code&gt;&lt;/pre&gt;
&lt;/details&gt;
&lt;p&gt;The important distinction is that the authorization context is derived from the credential actually accepted during authentication. The username alone does not describe the authority of an SSH connection.&lt;/p&gt;
&lt;p&gt;So far, everything behaves as intended.&lt;/p&gt;
&lt;h2 id=&#34;the-optimization&#34;&gt;The optimization&lt;/h2&gt;
&lt;p&gt;Now imagine that these jobs become part of a larger automation system. They perform repeated SSH invocations against the same host, and the accumulated connection overhead becomes noticeable.&lt;/p&gt;
&lt;p&gt;The administrator adds a familiar configuration:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code class=&#34;language-sshconfig&#34; data-lang=&#34;sshconfig&#34;&gt;Host *
    ControlMaster auto
    ControlPath ~/.ssh/cm-%C
    ControlPersist 10m&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;This deliberately broad configuration illustrates the problem; it is not a recommended default.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;ControlMaster&lt;/code&gt; enables connection sharing. &lt;code&gt;ControlPath&lt;/code&gt; identifies the local control socket. &lt;code&gt;ControlPersist&lt;/code&gt; allows the master to survive the original client session; here, it can remain alive for ten minutes of inactivity.&lt;/p&gt;
&lt;p&gt;The first invocation establishes an ordinary SSH connection and creates a local Unix-domain control socket. Later invocations can contact the master through that socket. The master opens additional logical SSH channels over the existing network connection.&lt;/p&gt;
&lt;p&gt;&lt;a href=&#34;https://mobile.dev.turbovision.in6-addr.net/articles/security/ssh2shell-controlmaster-considered-harmful/ssh2shell-controlmaster-considered-harmful-multiplexing.svg&#34;&gt;&lt;img src=&#34;https://mobile.dev.turbovision.in6-addr.net/articles/security/ssh2shell-controlmaster-considered-harmful/ssh2shell-controlmaster-considered-harmful-multiplexing.png&#34; alt=&#34;ControlMaster channel multiplexing&#34;&gt;
&lt;/a&gt;
&lt;/p&gt;
&lt;details class=&#34;mermaid-source&#34;&gt;
  &lt;summary class=&#34;mermaid-source-summary&#34;&gt;Diagram source (Mermaid)&lt;/summary&gt;
  &lt;pre&gt;&lt;code class=&#34;language-mermaid&#34;&gt;sequenceDiagram
    participant A as First SSH client / master
    participant S as SSH server
    participant B as Second SSH client
    participant C as Third SSH client
    A-&amp;amp;gt;&amp;amp;gt;S: TCP connection and SSH key exchange
    A-&amp;amp;gt;&amp;amp;gt;S: User authentication
    S--&amp;amp;gt;&amp;amp;gt;A: Authentication successful
    A-&amp;amp;gt;&amp;amp;gt;S: Open session channel 1
    B-&amp;amp;gt;&amp;amp;gt;A: Local control socket request
    A-&amp;amp;gt;&amp;amp;gt;S: Open session channel 2
    C-&amp;amp;gt;&amp;amp;gt;A: Local control socket request
    A-&amp;amp;gt;&amp;amp;gt;S: Open session channel 3
    Note over A,S: One authenticated SSH connection&lt;/code&gt;&lt;/pre&gt;
&lt;/details&gt;
&lt;p&gt;There is nothing inherently suspicious about this. SSH was designed to carry multiple channels over one authenticated connection. Multiplexing is not a workaround for the protocol; it uses the protocol as intended.&lt;/p&gt;
&lt;p&gt;But look carefully at the diagram. What happened to authentication for the second and third invocations?&lt;/p&gt;
&lt;p&gt;It disappeared.&lt;/p&gt;
&lt;p&gt;That is the source of the performance improvement. It is also the source of the security problem.&lt;/p&gt;
&lt;h2 id=&#34;when-a-different-key-makes-no-difference&#34;&gt;When a different key makes no difference&lt;/h2&gt;
&lt;p&gt;Return to our two automation jobs. Suppose the deployment job runs first and establishes a master connection using its deployment key. A little later, the status job invokes SSH with its own, deliberately restricted identity.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;div class=&#34;chroma&#34;&gt;
&lt;table class=&#34;lntable&#34;&gt;&lt;tr&gt;&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;lnt&#34;&gt;1
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;2
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;ssh -i ~/.ssh/deploy-key automation@server.example.com
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;ssh -i ~/.ssh/status-key automation@server.example.com&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;p&gt;Assume the first invocation successfully authenticates with the deployment key, and the second resolves to the same available control socket. Under those conditions, the second invocation does not authenticate with the status key at all.&lt;/p&gt;
&lt;p&gt;It contacts the existing master. The server receives a new channel request on the connection that was authenticated with the deployment key. The deployment forced command remains applicable to that channel.&lt;/p&gt;
&lt;p&gt;&lt;a href=&#34;https://mobile.dev.turbovision.in6-addr.net/articles/security/ssh2shell-controlmaster-considered-harmful/ssh2shell-controlmaster-considered-harmful-different-key.svg&#34;&gt;&lt;img src=&#34;https://mobile.dev.turbovision.in6-addr.net/articles/security/ssh2shell-controlmaster-considered-harmful/ssh2shell-controlmaster-considered-harmful-different-key.png&#34; alt=&#34;Reusing an existing master bypasses the second key&#34;&gt;
&lt;/a&gt;
&lt;/p&gt;
&lt;details class=&#34;mermaid-source&#34;&gt;
  &lt;summary class=&#34;mermaid-source-summary&#34;&gt;Diagram source (Mermaid)&lt;/summary&gt;
  &lt;pre&gt;&lt;code class=&#34;language-mermaid&#34;&gt;flowchart LR
    A[Deployment job] --&amp;amp;gt;|Deploy key authenticated| M[SSH master]
    B[Status job] --&amp;amp;gt;|Local socket: new session| M
    M ==&amp;amp;gt;|Existing deployment-authorized connection| S[sshd]
    S --&amp;amp;gt; D[deploy forced command]
    B -.-&amp;amp;gt;|Status key never presented| K[Status identity]&lt;/code&gt;&lt;/pre&gt;
&lt;/details&gt;
&lt;p&gt;Specifying a different &lt;code&gt;IdentityFile&lt;/code&gt;, using &lt;code&gt;-i&lt;/code&gt;, or enabling &lt;code&gt;IdentitiesOnly&lt;/code&gt; does not change this if the existing master is reused successfully. These settings influence authentication when authentication actually takes place.&lt;/p&gt;
&lt;p&gt;Reverse the order and the deployment job may instead receive the status job&amp;rsquo;s restricted execution environment. The outcome becomes dependent on which job happened to establish the connection first. In a concurrent automation environment, that may be a race rather than a deliberate decision.&lt;/p&gt;
&lt;p&gt;The server has not ignored either key&amp;rsquo;s restrictions. It has faithfully enforced the restrictions of the only key that was used to authenticate. The second key never entered the decision.&lt;/p&gt;
&lt;p&gt;This is not an unconditional privilege escalation: a restricted master remains restricted. But a less-privileged job can inherit a more-privileged master&amp;rsquo;s authority, or a privileged job can accidentally inherit a restricted one. In either direction, the intended separation between credentials has disappeared at the client.&lt;/p&gt;
&lt;h2 id=&#34;surely-ssh-certificates-solve-this&#34;&gt;Surely SSH certificates solve this?&lt;/h2&gt;
&lt;p&gt;At this point, an administrator might reasonably turn to SSH certificates. Instead of distributing long-lived public-key authorizations to every server, an organization can establish a trusted certificate authority and issue short-lived user certificates.&lt;/p&gt;
&lt;p&gt;Certificates can describe principals, validity intervals, critical options such as &lt;code&gt;force-command&lt;/code&gt; and &lt;code&gt;source-address&lt;/code&gt;, and extensions governing access to facilities such as port forwarding or PTYs. They provide a powerful mechanism for expressing narrowly scoped, temporary authorization.&lt;/p&gt;
&lt;p&gt;Imagine that our deployment job receives a certificate valid for five minutes. The status job receives another certificate, with a different forced command and a more restrictive permission set.&lt;/p&gt;
&lt;p&gt;The same problem returns. If the status job reuses the deployment master, its certificate is never offered to the server. Its principals, validity interval and restrictions do not participate in authorization. The original connection&amp;rsquo;s authentication-derived restrictions still apply.&lt;/p&gt;
&lt;p&gt;And there is another consequence: the five-minute validity of the deployment certificate does not impose a five-minute lifetime on an already authenticated SSH connection.&lt;/p&gt;
&lt;p&gt;&lt;a href=&#34;https://mobile.dev.turbovision.in6-addr.net/articles/security/ssh2shell-controlmaster-considered-harmful/ssh2shell-controlmaster-considered-harmful-certificates.svg&#34;&gt;&lt;img src=&#34;https://mobile.dev.turbovision.in6-addr.net/articles/security/ssh2shell-controlmaster-considered-harmful/ssh2shell-controlmaster-considered-harmful-certificates.png&#34; alt=&#34;Multiplexed channels outlive a short-lived SSH certificate&#34;&gt;
&lt;/a&gt;
&lt;/p&gt;
&lt;details class=&#34;mermaid-source&#34;&gt;
  &lt;summary class=&#34;mermaid-source-summary&#34;&gt;Diagram source (Mermaid)&lt;/summary&gt;
  &lt;pre&gt;&lt;code class=&#34;language-mermaid&#34;&gt;sequenceDiagram
    participant C as Client / master
    participant S as SSH server
    participant J as Later local job
    C-&amp;amp;gt;&amp;amp;gt;S: Authenticate with short-lived certificate
    S--&amp;amp;gt;&amp;amp;gt;C: Accepted while certificate is valid
    Note over C,S: Authenticated connection remains open
    Note over C,S: Certificate expires
    J-&amp;amp;gt;&amp;amp;gt;C: Request another session via socket
    C-&amp;amp;gt;&amp;amp;gt;S: Open new channel
    S--&amp;amp;gt;&amp;amp;gt;C: Channel accepted if existing policy allows
    Note over C,S: No new certificate validation&lt;/code&gt;&lt;/pre&gt;
&lt;/details&gt;
&lt;p&gt;Certificate expiration controls when a credential may be accepted for authentication. It is not, by itself, a connection termination mechanism. Revoking a credential similarly prevents future authentication when the revocation is enforced; it does not automatically tear down existing connections.&lt;/p&gt;
&lt;p&gt;Short-lived certificates are still valuable. They reduce the opportunity to establish new connections with compromised credentials. But the lifetime of an authenticated connection is a separate security parameter, and it needs a separate policy.&lt;/p&gt;
&lt;h2 id=&#34;surely-mfa-solves-this&#34;&gt;Surely MFA solves this?&lt;/h2&gt;
&lt;p&gt;Consider an operator who uses a hardware security key and a second authentication factor to access production infrastructure. Private key material is protected, and authentication requires deliberate user interaction. The operator may even remove the hardware token immediately after logging in.&lt;/p&gt;
&lt;p&gt;The authentication has already happened.&lt;/p&gt;
&lt;p&gt;When another local application uses the control socket, there is no second public-key authentication and no additional MFA challenge. Nothing in ordinary SSH multiplexing asks the server to verify that the operator has approved this new invocation.&lt;/p&gt;
&lt;p&gt;MFA has not been defeated cryptographically. It has done its job. The authenticated connection is the result of that job, and the control socket provides access to the result.&lt;/p&gt;
&lt;p&gt;This distinction matters because protecting a credential and protecting an authenticated session are different problems. A system can be excellent at the former while being dangerously permissive about the latter.&lt;/p&gt;
&lt;h2 id=&#34;the-socket-becomes-the-credential-like-object&#34;&gt;The socket becomes the credential-like object&lt;/h2&gt;
&lt;p&gt;Until now, our examples have involved legitimate jobs accidentally sharing an authentication context. But the next question follows naturally: what prevents an application that is not legitimate from using the same socket?&lt;/p&gt;
&lt;p&gt;OpenSSH&amp;rsquo;s local multiplexing interface is protected by operating-system mechanisms. On Unix-like systems, filesystem access controls and local peer-identity checks are relevant safeguards. The master also needs to be protected against process manipulation, memory access and interference.&lt;/p&gt;
&lt;p&gt;These mechanisms are meaningful. An arbitrary unprivileged user does not automatically gain access to another user&amp;rsquo;s master merely by learning its socket path. But applications running under the same local identity are not necessarily isolated from one another by ordinary Unix discretionary access controls.&lt;/p&gt;
&lt;p&gt;If an untrusted process can reach the control interface and satisfy its local access checks, it may request additional remote sessions or other operations permitted by the existing connection. It does not need to possess the original private key, obtain a new certificate or complete a fresh MFA challenge. A forced command remains a forced command; a broadly authorized administrative connection remains broadly authorized.&lt;/p&gt;
&lt;p&gt;&lt;a href=&#34;https://mobile.dev.turbovision.in6-addr.net/articles/security/ssh2shell-controlmaster-considered-harmful/ssh2shell-controlmaster-considered-harmful-socket-capability.svg&#34;&gt;&lt;img src=&#34;https://mobile.dev.turbovision.in6-addr.net/articles/security/ssh2shell-controlmaster-considered-harmful/ssh2shell-controlmaster-considered-harmful-socket-capability.png&#34; alt=&#34;Local control socket as a reusable capability&#34;&gt;
&lt;/a&gt;
&lt;/p&gt;
&lt;details class=&#34;mermaid-source&#34;&gt;
  &lt;summary class=&#34;mermaid-source-summary&#34;&gt;Diagram source (Mermaid)&lt;/summary&gt;
  &lt;pre&gt;&lt;code class=&#34;language-mermaid&#34;&gt;flowchart LR
    subgraph Client[Client operating system]
        A[Legitimate operator] --&amp;amp;gt; M[SSH master process]
        X[Compromised local application] --&amp;amp;gt; G{Local access controls}
        G --&amp;amp;gt;|Access permitted| U[Control socket]
        U --&amp;amp;gt; M
        G --&amp;amp;gt;|Access denied| N[Blocked]
    end
    M ==&amp;amp;gt;|Authenticated transport| S[Remote SSH server]
    S --&amp;amp;gt; P[Existing authorization context]&lt;/code&gt;&lt;/pre&gt;
&lt;/details&gt;
&lt;p&gt;From the server&amp;rsquo;s perspective, these channel requests arrive over an already trusted connection. SSH does not inherently communicate which local application initiated them or whether that application represents a fresh decision by the human operator.&lt;/p&gt;
&lt;p&gt;The control socket is therefore best understood as a local, credential-like capability. Not a private key, not a portable bearer token, but an interface to live authenticated authority. Its usefulness depends on the master remaining alive and on the caller satisfying local access controls.&lt;/p&gt;
&lt;h2 id=&#34;the-workstation-is-now-part-of-the-authorization-model&#34;&gt;The workstation is now part of the authorization model&lt;/h2&gt;
&lt;p&gt;Suppose the operator&amp;rsquo;s workstation is also used for email, web browsing, development and everyday office work. An advertising component on a website exploits a browser vulnerability. A malicious dependency executes during a build. An extension or desktop application is compromised.&lt;/p&gt;
&lt;p&gt;A browser exploit alone does not necessarily provide access to an SSH socket. The browser sandbox, operating-system isolation and privileges of the compromised process determine what is reachable. But if the compromise reaches a context that can use the control interface, the attacker can inherit the remote authority of the master.&lt;/p&gt;
&lt;p&gt;The operator may have a hardware-protected private key, short-lived certificates and strong MFA. None of these mechanisms independently blocks reuse of the already authenticated connection.&lt;/p&gt;
&lt;p&gt;This is not a Linux-versus-Windows argument. The relevant question is what isolation the actual SSH client environment provides. Native Win32-OpenSSH has historically lacked ControlMaster support, so this particular Unix-socket scenario should not be attributed to every Windows SSH installation. A Linux client running under WSL, inside a virtual machine or in another environment supporting multiplexing requires an assessment of that environment&amp;rsquo;s actual boundaries and host integration.&lt;/p&gt;
&lt;p&gt;An administrator cannot simply assume that every process running in a workstation session is equally trustworthy. Yet an accessible multiplexing socket can make that assumption part of the remote infrastructure&amp;rsquo;s effective security model.&lt;/p&gt;
&lt;h2 id=&#34;ci-pipelines-different-jobs-one-local-identity&#34;&gt;CI pipelines: different jobs, one local identity&lt;/h2&gt;
&lt;p&gt;A shared CI runner makes this problem particularly visible. Independent jobs may run under the same service account, share a home directory, inherit the same SSH configuration or reuse a persistent worker. Each job may receive its own credentials from a secrets manager, creating the impression of strong separation.&lt;/p&gt;
&lt;p&gt;But what happens when a privileged deployment job leaves a master running and a different job can access its socket?&lt;/p&gt;
&lt;p&gt;The second job does not need to recover the deployment secret. The authentication result is already present on the worker. If the local identity, socket visibility and master access checks allow reuse, the job may inherit the deployment connection&amp;rsquo;s authority.&lt;/p&gt;
&lt;p&gt;&lt;a href=&#34;https://mobile.dev.turbovision.in6-addr.net/articles/security/ssh2shell-controlmaster-considered-harmful/ssh2shell-controlmaster-considered-harmful-ci-worker.svg&#34;&gt;&lt;img src=&#34;https://mobile.dev.turbovision.in6-addr.net/articles/security/ssh2shell-controlmaster-considered-harmful/ssh2shell-controlmaster-considered-harmful-ci-worker.png&#34; alt=&#34;Shared CI worker control socket reuse&#34;&gt;
&lt;/a&gt;
&lt;/p&gt;
&lt;details class=&#34;mermaid-source&#34;&gt;
  &lt;summary class=&#34;mermaid-source-summary&#34;&gt;Diagram source (Mermaid)&lt;/summary&gt;
  &lt;pre&gt;&lt;code class=&#34;language-mermaid&#34;&gt;flowchart TD
    A[Trusted deployment job] --&amp;amp;gt;|Privileged authentication| M[Persistent SSH master]
    B[Less-trusted CI job] --&amp;amp;gt;|Same UID and reachable socket| U[Shared control socket]
    U --&amp;amp;gt; M
    M ==&amp;amp;gt;|Existing authorized connection| P[Production server]
    subgraph Runner[Shared CI worker]
        A
        B
        U
        M
    end&lt;/code&gt;&lt;/pre&gt;
&lt;/details&gt;
&lt;p&gt;Containerization can provide a real boundary here, but only to the extent that it actually isolates the relevant resources. A container with no access to the socket or master process cannot simply reuse the connection because it happens to run a similarly named user. User namespaces, mounts, process isolation and host security policy all matter.&lt;/p&gt;
&lt;p&gt;Conversely, a shared socket directory, an unnecessarily exposed host filesystem or a container escape that grants sufficient host access can undermine that separation. A container escape is already a serious incident; a surviving privileged SSH master can expand its impact from the runner into remote infrastructure.&lt;/p&gt;
&lt;p&gt;Deleting the job&amp;rsquo;s private key or allowing its certificate to expire at the end of a pipeline does not necessarily clean up a surviving master process. Credential cleanup and connection cleanup are different operations.&lt;/p&gt;
&lt;h2 id=&#34;the-feature-selects-for-a-particular-kind-of-user&#34;&gt;The feature selects for a particular kind of user&lt;/h2&gt;
&lt;p&gt;There is an uncomfortable asymmetry in who is likely to encounter this problem.&lt;/p&gt;
&lt;p&gt;An occasional SSH user may never enable multiplexing. OpenSSH does not enable &lt;code&gt;ControlMaster&lt;/code&gt; by default, and someone connecting to a single machine occasionally has little reason to change that.&lt;/p&gt;
&lt;p&gt;The users with a stronger incentive are experienced operators: infrastructure engineers, system administrators and automation developers. They understand that connection establishment costs time. They maintain scripts, orchestration systems and pipelines. They may work across substantial environments, using multiple identities, delegated credentials and production access.&lt;/p&gt;
&lt;p&gt;These are precisely the situations where preserving authorization boundaries matters most.&lt;/p&gt;
&lt;p&gt;This is a risk profile, not a statistical claim about who actually enables the feature. The point is structural: the operational incentives for multiplexing can coincide with broad remote authority, complex trust relationships and a large potential blast radius.&lt;/p&gt;
&lt;p&gt;A performance optimization adopted by technically experienced users can quietly undermine the very least-privilege design those users have put in place.&lt;/p&gt;
&lt;h2 id=&#34;making-the-optimization-explicit&#34;&gt;Making the optimization explicit&lt;/h2&gt;
&lt;p&gt;There are circumstances in which multiplexing is a reasonable trade-off. A dedicated, isolated automation worker performing many operations within one well-defined authorization context is a different proposition from a general-purpose workstation sharing a global socket namespace.&lt;/p&gt;
&lt;p&gt;The first rule is to separate masters by authorization context, not merely by network destination. OpenSSH&amp;rsquo;s &lt;code&gt;%C&lt;/code&gt; token identifies connection parameters; it does not encode the selected private key, certificate restrictions or MFA policy. Separate aliases with distinct control paths can prevent accidental sharing:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code class=&#34;language-sshconfig&#34; data-lang=&#34;sshconfig&#34;&gt;Host production-status
    HostName server.example.com
    User automation
    IdentityFile ~/.ssh/status-key
    IdentitiesOnly yes
    ControlMaster auto
    ControlPath ~/.ssh/control/status-%C
    ControlPersist 30s

Host production-deploy
    HostName server.example.com
    User automation
    IdentityFile ~/.ssh/deploy-key
    IdentitiesOnly yes
    ControlMaster no
    ControlPath none&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;The control directory should be private to the intended local identity, for example mode &lt;code&gt;0700&lt;/code&gt; on a Unix-like system. Distinct paths prevent accidental cross-identity reuse; they do not isolate mutually untrusted applications running under the same UID. Nor does a fixed alias distinguish successive certificates with changed authority. Such changes require a fresh connection or a genuinely separate master lifecycle.&lt;/p&gt;
&lt;p&gt;For operations that must authenticate independently, explicitly disable socket reuse with &lt;code&gt;ControlPath none&lt;/code&gt;. Setting &lt;code&gt;ControlMaster no&lt;/code&gt; alone is not sufficient: a client may still use an existing master through a configured control path.&lt;/p&gt;
&lt;p&gt;When persistence is justified, limit its duration and terminate the master explicitly when its work is complete. OpenSSH provides &lt;code&gt;ssh -O exit &amp;lt;host-alias&amp;gt;&lt;/code&gt; for that purpose; terminating the master also interrupts its active multiplexed sessions. A &lt;code&gt;ControlPersist&lt;/code&gt; duration is an idle timeout, not an absolute lifetime, so it cannot enforce a hard authorization deadline by itself.&lt;/p&gt;
&lt;p&gt;For shared runners, isolate jobs through distinct local identities or appropriately isolated execution environments. For privileged administrative access, consider dedicated workstations or stronger application isolation. Server-side forced commands, forwarding restrictions and session limits remain valuable. &lt;code&gt;MaxSessions 1&lt;/code&gt; can prevent multiple simultaneous session channels, but it does not prevent sequential reuse and is not a per-invocation authentication policy. Server-side idle and channel timeouts can reduce exposure, but a hard access deadline requires connection lifecycle enforcement rather than merely credential expiration.&lt;/p&gt;
&lt;p&gt;These measures address different risks. Socket naming prevents accidental credential mixing. OS isolation prevents unauthorized local reuse. Connection termination limits the lifetime of the delegated authority. None substitutes for the others.&lt;/p&gt;
&lt;h2 id=&#34;the-safe-is-still-open&#34;&gt;The safe is still open&lt;/h2&gt;
&lt;p&gt;Imagine a gold safe protected by a sophisticated lock. Opening it requires a physical key, a PIN and perhaps a second person&amp;rsquo;s approval. The key is carefully protected, the PIN is never stored and permission to open the safe expires after a few minutes.&lt;/p&gt;
&lt;p&gt;The administrator opens the safe, removes the key and walks away — leaving the door open so that the next operation will be faster.&lt;/p&gt;
&lt;p&gt;The analogy is not perfect: an SSH master still enforces its original authorization restrictions, and the control socket has local access checks. But the essential distinction holds. Protecting the key that opens the safe is not the same as protecting the contents once it is open.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;ControlMaster&lt;/code&gt; deliberately preserves the result of authentication. &lt;code&gt;ControlPersist&lt;/code&gt; can preserve it even after the operator believes the original session is finished. Together, they can leave live remote authority accessible to other local processes without another authentication ceremony.&lt;/p&gt;
&lt;p&gt;The criticism of OpenSSH is not that multiplexing violates the SSH protocol, nor that it should never have been implemented. It is that the feature is presented primarily as a connection-sharing optimization, while its security consequences are less obvious than its performance benefits. A configuration can look like a harmless caching decision while silently changing which credentials are consulted and which local processes can exercise remote authority.&lt;/p&gt;
&lt;p&gt;A clearer security contract would make this explicit: the connection cache is not merely caching connectivity. It is preserving authenticated authority. Reusing a connection means reusing the authorization context that came with it, even when a later invocation appears to select a different identity.&lt;/p&gt;
&lt;p&gt;The responsibility ultimately lies with the administrator who chooses to enable it. The assumption that the local client is secure must be treated as a security requirement, not as an unexamined convenience. The socket and master process must be protected for as long as the connection remains authenticated.&lt;/p&gt;
&lt;p&gt;If that guarantee cannot be made, the time saved by avoiding authentication may be the wrong thing to optimize.&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id=&#34;technical-references&#34;&gt;Technical references&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://man.openbsd.org/ssh_config&#34;&gt;OpenSSH ssh_config(5)&lt;/a&gt;
 — &lt;code&gt;ControlMaster&lt;/code&gt;, &lt;code&gt;ControlPath&lt;/code&gt;, &lt;code&gt;ControlPersist&lt;/code&gt;, &lt;code&gt;IdentityFile&lt;/code&gt;, token expansion and connection sharing.&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://man.openbsd.org/ssh&#34;&gt;OpenSSH ssh(1)&lt;/a&gt;
 — multiplexing control commands and command-line options.&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://man.openbsd.org/sshd&#34;&gt;OpenSSH sshd(8)&lt;/a&gt;
 — authorized key options, forced commands and restrictions.&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://man.openbsd.org/ssh-keygen&#34;&gt;OpenSSH ssh-keygen(1)&lt;/a&gt;
 — certificate validity, principals, critical options and extensions.&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://man.openbsd.org/sshd_config&#34;&gt;OpenSSH sshd_config(5)&lt;/a&gt;
 — authentication methods, &lt;code&gt;MaxSessions&lt;/code&gt;, channel and connection timeouts.&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://www.rfc-editor.org/rfc/rfc4252&#34;&gt;RFC 4252 — SSH Authentication Protocol&lt;/a&gt;
 — authentication protocol architecture.&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://www.rfc-editor.org/rfc/rfc4254&#34;&gt;RFC 4254 — SSH Connection Protocol&lt;/a&gt;
 — channel multiplexing over authenticated transport.&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://github.com/openssh/openssh-portable/blob/master/mux.c&#34;&gt;OpenSSH multiplexing implementation&lt;/a&gt;
 — local control protocol and peer-identity checks.&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://github.com/PowerShell/Win32-OpenSSH/wiki/Project-Scope&#34;&gt;Win32-OpenSSH project scope&lt;/a&gt;
 — platform-specific limitations, including client multiplexing.&lt;/li&gt;
&lt;/ul&gt;
</description>
    </item>
    
  </channel>
</rss>
