此仓库包含针对 CVE-2026-34038(Coolify 中的一个严重命令注入漏洞)的文档和分析。
Coolify 中存在一个经身份验证的远程命令注入漏洞(CWE-78),允许拥有应用程序 “写入” 权限的用户实现 远程代码执行(RCE) 并 窃取 敏感环境变量(例如数据库凭据、API 密钥),即使构建环境隔离了 Docker 套接字。
CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:H/A:Hwrite(用于更新配置)和 read:sensitive(用于通过日志读取窃取的数据)。deploy 权限的令牌触发构建。dockerfile_location 注入文件: app/Jobs/ApplicationDeploymentJob.php
输入缺乏适当的 shell 转义或输入验证,允许使用元字符(如 ;、&& 和管道)进行直接命令注入。
// 第 2976-2978 行:带参数的传统构建
$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}"
);
// 第 526 行:也用于简单的 dockerfile 部署
executeInDocker($this->deployment_uuid, "echo '$dockerfile_base64' | base64 -d | tee {$this->workdir}{$this->dockerfile_location} > /dev/null"),
pre_deployment_command 执行文件: app/Jobs/ApplicationDeploymentJob.php(第 3882-3909 行)
虽然进行了基本的转义,但该函数自然执行原生 shell 命令,因此有可能将数据直接转储到构建日志中。
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 输入(在 ApplicationDeploymentJob.php 中):使用严格的正则表达式验证输入,并转义 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。