Summary
Dockwatch contains an unauthenticated OS command injection flaw where attacker-controlled input is passed directly into shell_exec() during Docker compose operations.
By abusing an incomplete authentication redirect and a writable session flag, remote attackers can inject arbitrary commands via a POST parameter and fully compromise the host that runs Dockwatch.
Affected context
This vulnerability appears in Dockwatch deployments that expose the web interface and rely on loader.php for authentication gating.
It is relevant when ajax/compose.php is reachable, uses shell_exec() for Docker compose-related actions, and accepts user-supplied composePath values without sanitization or command-line validation.
The risk is heightened in typical configurations where the Docker socket is mounted into the Dockwatch environment, effectively bridging web-level compromise into container and host-level control.
Exploit preconditions
- Attack surface: Publicly accessible Dockwatch HTTP endpoints, particularly loader.php and ajax/compose.php.
- Required access: Network access to the Dockwatch interface; no valid credentials are strictly required due to the incomplete authentication flow.
- Trigger point: Issuing a composePull action with a crafted composePath POST parameter after seeding the session via the redirect logic in loader.php.
- Why exploitation is possible: The authentication path fails to terminate execution after redirect, allowing a session flag to be set without full auth, and composePath is passed unsanitized to shell_exec(), enabling direct command injection.
Why this happens
The underlying bug combines two insecure patterns.
First, an incomplete authentication redirect in loader.php (mapping to CWE-698: Incorrect Handling of Exceptional Conditions) fails to call exit(), letting subsequent logic run while setting a session flag that appears to represent authenticated state.
Second, ajax/compose.php uses shell_exec() with unvalidated user input (composePath), directly concatenating or interpolating that value into shell commands, which aligns with CWE-78: OS Command Injection.
Together, these flaws allow untrusted data to be treated as part of executable shell syntax while the intended authorization barrier is effectively bypassed.
Potential impact
- Remote execution of arbitrary shell commands on the Dockwatch host.
- Full compromise of the underlying server, including file read/write and process control.
- Manipulation, creation, or destruction of Docker containers via the mounted Docker socket.
- Pivoting into other services or networks reachable from the compromised host.
- Disruption of application availability through resource exhaustion or destructive commands.
General mitigation guidance
Mitigation generally focuses on strengthening both command handling and authentication flow.
For command execution, favor APIs that avoid shell parsing entirely (e.g., direct Docker client libraries or parameterized process execution) and strictly validate any path-like inputs against an allowlist of known-safe locations.
Ensure that authentication redirects terminate execution unambiguously, and centralize authorization checks so that session flags cannot be set or trusted before full verification.
Deploy Dockwatch with least-privilege principles: avoid unnecessary Docker socket exposure, reduce filesystem write access from the web component, and isolate the service within constrained runtime environments to limit the blast radius of any injected command.
How teams detect issues like this
Detection can focus on both code-level and runtime indicators.
At the code level, static analysis rules can flag uses of shell_exec() and similar shell APIs that incorporate variables derived from HTTP request data, especially POST parameters like composePath.
Code review should highlight authentication flows that perform redirects without explicit termination, and any authorization logic that relies solely on session flags set outside a validated login process.
Runtime monitoring can look for anomalous command patterns originating from the Dockwatch process, unexpected container lifecycle events, or unusual access to the Docker socket, all of which may indicate exploitation attempts.

