Repository navigation
Description
Affected layers
- Backend (
server/): affected.parseDockerHostinserver/src/docker.tsmapstcp://tohttp, acceptshttp://as well, defaults both to port 2375, and never looks at the host. Every Docker call then crosses that connection: image pulls, container creation with the config directory bind-mounted, start, stop, removal and log reads. No TLS material is passed to the client, sohttps://can only reach a daemon that does not require client certificates;ssh://goes through the SSH transport of the Docker client library. - Frontend (
src/): not affected. It never sees the Docker endpoint; the backend owns the connection. shared/: not affected. It lists local socket paths; the URL parsing is in the backend.
Problem
DOCKER_HOST is the documented way to point the backend at a Docker daemon other than the local socket. With a tcp:// or http:// value naming a host that is not loopback, the backend talks to that daemon in cleartext, with no confidentiality or integrity on the wire. The README names the variable without saying which transports are safe, and the backend accepts the plaintext ones silently.
Impact
An attacker on the network path between the backend and the daemon can read and rewrite privileged requests. Rewriting one container creation to run a different image with a host bind gives them the remote Docker host, not just the mining stack. It needs an operator to have configured a non-local plaintext DOCKER_HOST; the local socket and loopback are unaffected. Medium per Loupe for that reason.
Expected outcome
- A
tcp://orhttp://DOCKER_HOSTnaming a host other than loopback is rejected, no Docker request is sent to it, and the error names the reason and the accepted alternatives. - Unix sockets, loopback plaintext,
https://andssh://keep working as today. - The README says which remote transports are accepted.
Possible approach (non-binding)
Check the hostname in parseDockerHost and throw before building the connection, so the backend fails at startup the way it already does for an unsupported protocol. A test can follow Docker connection metadata never exposes URL credentials in server/src/docker.test.ts, which already swaps DOCKER_HOST and restores it, and assert that remote plaintext values throw while tcp://127.0.0.1:2375 does not.
Loupe findings
- project-loupe/audit-sv2-ui#39:
tcp://andhttp://are accepted for any host and default to port 2375 (reported as docker: a remote Docker daemon is only reached over an encrypted transport #346)
Related issues and PRs
Loupe export for #346 (finding #39)
Finding
- repo:
stratum-mining/sv2-ui(https://github.com/stratum-mining/sv2-ui.git) - reviewed revision:
b610455ac2d1e017c1df5db8787c0b2e505eabdc - title: Reject plaintext connections to remote Docker daemons
- severity:
medium - location:
server/src/docker.ts:62-77 - cwe: CWE-319
- scanner:
llm-code-review - fingerprint:
4e58fb17c817f452479ac585194dd60d472f7f03860b5e005bcc23943feb791b
Description
parseDockerHost() maps tcp:// to http and explicitly accepts both HTTP forms, defaulting them to the conventional plaintext port 2375. All later Dockerode operations—including image pulls, bind-mounted container creation, starts, stops, and removals—then cross that connection without transport confidentiality or integrity. In a deployment configured with a remote Docker daemon, an on-path attacker can read or alter these privileged API requests. For example, rewriting a createContainer request to run attacker-controlled code with a host bind can turn network interception into control of the remote Docker host. Exploitation is conditional on an administrator selecting a non-local plaintext DOCKER_HOST, so this is rated medium rather than high. Reject non-loopback tcp:///http:// endpoints and require https:// with authenticated TLS (or a correctly supported SSH transport); Unix sockets are unaffected. Prior searches for DOCKER_HOST plaintext http tcp, Docker host cleartext transport MITM, remote Docker daemon tcp 2375, and related protocol terms found no matching report.
Proof of Concept
diff --git a/server/src/docker.test.ts b/server/src/docker.test.ts
--- a/server/src/docker.test.ts
+++ b/server/src/docker.test.ts
@@ -1,6 +1,9 @@
import assert from 'node:assert/strict';
import { test } from 'node:test';
-import { getBitcoinRpcProbeTransports } from './docker.js';
+import {
+ getBitcoinRpcProbeTransports,
+ getDockerConnectionInfo,
+} from './docker.js';
test('Bitcoin RPC probing tries host loopback before Docker host gateway', () => {
assert.deepEqual(getBitcoinRpcProbeTransports(), [
@@ -17,3 +20,30 @@ test('Bitcoin RPC probing tries host loopback before Docker host gateway', () =>
},
]);
});
+
+test('remote Docker connections cannot use a plaintext transport', () => {
+ const previousHost = process.env.DOCKER_HOST;
+ const previousSocket = process.env.DOCKER_SOCKET_PATH;
+
+ try {
+ delete process.env.DOCKER_SOCKET_PATH;
+
+ for (const dockerHost of [
+ 'tcp://192.0.2.10:2375',
+ 'http://192.0.2.10:2375',
+ ]) {
+ process.env.DOCKER_HOST = dockerHost;
+ assert.throws(
+ () => getDockerConnectionInfo(),
+ undefined,
+ `remote plaintext Docker endpoint was accepted: ${dockerHost}`,
+ );
+ }
+ } finally {
+ if (previousHost === undefined) delete process.env.DOCKER_HOST;
+ else process.env.DOCKER_HOST = previousHost;
+
+ if (previousSocket === undefined) delete process.env.DOCKER_SOCKET_PATH;
+ else process.env.DOCKER_SOCKET_PATH = previousSocket;
+
+ getDockerConnectionInfo();
+ }
+});
Suggested Fix
diff --git a/server/src/docker.ts b/server/src/docker.ts
index 59406ad..75e15e6 100644
--- a/server/src/docker.ts
+++ b/server/src/docker.ts
@@ -65,6 +65,14 @@ function parseDockerHost(dockerHost: string): DockerConnectionConfig {
if (protocol !== 'http' && protocol !== 'https' && protocol !== 'ssh') {
throw new Error(`Unsupported DOCKER_HOST protocol: ${url.protocol}`);
}
+
+ const isLoopback = url.hostname === 'localhost' ||
+ url.hostname === 'localhost.' ||
+ url.hostname.startsWith('127.') ||
+ url.hostname === '[::1]';
+ if (protocol === 'http' && !isLoopback) {
+ throw new Error('Plaintext DOCKER_HOST connections are only allowed for loopback endpoints');
+ }
const defaultPort = protocol === 'https' ? 2376 : 2375;
This finding was discovered by Project Loupe.
Activity
[-]Reject plaintext connections to remote Docker daemons[/-][+]docker: a remote Docker daemon is only reached over an encrypted transport[/+]