
CVE-2026-34038: Injeção Remota de Comandos Autenticada no Coolify
Este repositório contém documentação e análise para CVE-2026-34038, uma vulnerabilidade crítica de injeção de comandos no Coolify.
Uma vulnerabilidade autenticada de injeção remota de comandos (CWE-78) no Coolify permite que usuários com permissões "write" no aplicativo alcancem Execução Remota de Código (RCE) e Exfiltrem variáveis de ambiente sensíveis (ex.: credenciais de banco de dados, chaves de API) através dos logs de deployment, mesmo que o ambiente de build isole o socket do Docker.
CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:H/A:Hwrite (para atualizar a configuração) e read:sensitive (para ler dados exfiltrados via logs).deploy disparem builds.dockerfile_locationArquivo: app/Jobs/ApplicationDeploymentJob.php
A entrada não possui escaping adequado de shell nem validação de entrada, permitindo injeção direta de comandos usando metacaracteres como ;, && e pipes.
// Lines 2976-2978: Traditional build with args
$build_command = $this->wrap_build_command_with_env_export(
"docker build {$this->buildTarget} --network {$this->destination->network} -f {$this->workdir}{$this->dockerfile_location} {$this->build_args} --progress plain -t $this->build_image_name {$this->workdir}"
);
// Lines 526: Also used in simple dockerfile deployment
executeInDocker($this->deployment_uuid, "echo '$dockerfile_base64' | base64 -d | tee {$this->workdir}{$this->dockerfile_location} > /dev/null"),
pre_deployment_commandArquivo: app/Jobs/ApplicationDeploymentJob.php (Linhas 3882-3909)
Embora um escaping básico seja realizado, a função naturalmente executa comandos nativos do shell, tornando possível despejar dados diretamente nos logs de build.
private function run_pre_deployment_command()
{
if (empty($this->application->pre_deployment_command)) {
return;
}
// ...
$cmd = "sh -c '".str_replace("'", "'\\''", $this->application->pre_deployment_command)."'";
$exec = "docker exec {$containerName} {$cmd}";
$this->execute_remote_command(
[
'command' => $exec,
'hidden' => true,
],
);
}
dockerfile_location (em ApplicationDeploymentJob.php):Valide a entrada usando expressões regulares estritas e faça o escape do argumento do shell:
if ($this->application->dockerfile_location) {
if (!preg_match('/^[a-zA-Z0-9._\-\/]+$/', $this->application->dockerfile_location)) {
throw new \RuntimeException("Invalid dockerfile_location: contains forbidden characters");
}
if (str_contains($this->application->dockerfile_location, '..')) {
throw new \RuntimeException("Invalid dockerfile_location: path traversal detected");
}
$this->dockerfile_location = escapeshellarg($this->application->dockerfile_location);
}
bootstrap/helpers/api.php):'dockerfile_location' => [
'string',
'nullable',
'regex:/^[a-zA-Z0-9._\-\/]+$/',
'max:255'
],
docker_compose_location.