Dokploy: a schedule name that reaches the shell

Dokploy · CVE-2026-129985 · CWE-77

Contents

Dokploy is a self-hosted PaaS: you point it at a server and it runs your applications, databases and scheduled jobs on top of Docker. CVE-2026-129985 is a command injection in its scheduling feature, fixed in 0.31.1. The CVE record scores it CVSS v4.0 8.7 High; the project’s advisory labels it Critical.

Dokploy had already built the defence against this kind of bug and applied it to eight schemas. This was the ninth.

Where appName comes from

A schedule is a cron entry: a name, an expression, a command, and a scheduleType saying what it runs against. Create and update payloads go through a Zod schema generated from the database table.

// packages/server/src/db/schema/schedule.ts
export const createScheduleSchema = createInsertSchema(schedules, {
  scheduleType: z.enum(["application", "compose", "server", "dokploy-server"]),
});

One field is constrained. scheduleType has to be one of four literals. Every other column inherits whatever the table allows, and appName is a text column, so appName is any string the caller cares to send.

The field exists to name a directory. Each schedule gets a working folder:

const fullPath = path.join(SCHEDULES_PATH, schedule?.appName || "");

path.join is a path function. It normalises separators, collapses .. segments, and hands back a string. It makes no claim about shell metacharacters, and it will return /etc/dokploy/schedules/backups; id; # as readily as /etc/dokploy/schedules/backups.

Where that path reaches a shell

Creating or updating a schedule writes the script file out, and the path goes into the script as text:

// packages/server/src/services/schedule.ts  — handleScript()
const script = `
  mkdir -p ${fullPath}
  rm -f ${fullPath}/script.sh
  touch ${fullPath}/script.sh
  chmod +x ${fullPath}/script.sh
  echo "${encodedContent}" | base64 -d > ${fullPath}/script.sh
`;

if (schedule?.scheduleType === "dokploy-server") {
  await execAsync(script);

execAsync wraps child_process.exec, which runs its argument through /bin/sh -c. This is the path the CVE describes, and its reach is narrow by design: handleScript is only called when the schedule type is server or dokploy-server, and only dokploy-server runs the script on the control plane itself. Those are the types Dokploy restricts to owners and admins, which is why the CVE is scored as needing an authenticated user rather than an anonymous one.

Deleting a schedule builds a command the same way, and this one is not gated by schedule type:

// packages/server/src/services/schedule.ts  — deleteSchedule()
const fullPath = path.join(SCHEDULES_PATH, schedule?.appName || "");
const command = `rm -rf ${fullPath}`;
await execAsync(command);

The deployment path builds a third one, but only for schedules bound to a remote server:

// packages/server/src/services/deployment.ts  — createDeploymentSchedule()
if (serverId) {
  const command = `
    mkdir -p ${SCHEDULES_PATH}/${schedule.appName};
    echo "Initializing schedule" >> ${logFilePath};
  `;
  await execAsyncRemote(server.serverId, command);
} else {
  await fsPromises.mkdir(path.join(SCHEDULES_PATH, schedule.appName), { recursive: true });
  await fsPromises.writeFile(logFilePath, "Initializing schedule\n");
}

That else branch is worth sitting with. For a local schedule, the same operation is done with fsPromises.mkdir and fsPromises.writeFile: no command string, no shell, nothing to escape. Dokploy already had the safe version of this code. It just was not the version on the other branch.

Why the existing validation did not stop it

An earlier command injection in Dokploy was closed by adding a shared allowlist:

// packages/server/src/db/schema/utils.ts
export const APP_NAME_REGEX = /^[a-zA-Z0-9._-]+$/;

By the time of this CVE that regex guarded the appName field in eight schemas: application, compose, libsql, mongo, mariadb, mysql, postgres and redis. Each one rejects a semicolon long before it can reach a command string.

The schedule schema is the ninth place the field appears, and it never got the regex. Nothing about this is a misunderstanding of the bug. The defence was written, it was correct, and it was applied everywhere the author of that fix looked. It simply was not applied here.

A per-field allowlist has to be remembered at every site that introduces the field, which makes it a fix that decays. It holds at the eight places someone thought of and does nothing at the ninth, and nothing goes red when it is missing. There is no test for a validator that was never written.

What the injected value does

The value only has to be a valid shell fragment. A semicolon ends mkdir’s argument list, whatever follows runs, and a trailing comment swallows the rest of the line.

Payload 27 bytes
backups; id > /tmp/proof; #

It travels as an ordinary field, on a request an authenticated owner or admin is entitled to make:

Request

POST /api/trpc/schedule.create HTTP/1.1
Host: dokploy.example
Content-Type: application/json
Cookie: better-auth.session_token=...

{"json":{"name":"nightly","cronExpression":"0 0 * * *","command":"true",
"scheduleType":"dokploy-server","enabled":false,
"appName":"backups; id > /tmp/proof; #"}}

Response

HTTP/1.1 200 OK
Content-Type: application/json

{"result":{"data":{"json":{"scheduleId":"...","appName":"backups; id > /tmp/proof; #"}}}}

The string is stored exactly as sent. When handleScript builds its five-line script around it, the shell receives this:

mkdir -p /etc/dokploy/schedules/backups; id > /tmp/proof; #
rm -f /etc/dokploy/schedules/backups; id > /tmp/proof; #/script.sh

Each line is parsed on its own, so the injected id runs twice and the trailing # comments away the /script.sh that the template appends after it.

The Dokploy control plane runs as root and mounts the host Docker socket, which is how it manages containers at all. Command execution there is not confined to the container: root holding a Docker socket can start a privileged container or bind-mount the host filesystem. That is the difference between code running in a sandbox and the host being gone.

The fix

Version 0.31.1, commit 0fa3101a, three files. The codebase’s own history points at one fix; the maintainers shipped a better one.

First, the field stops being client-controlled:

  export const createScheduleSchema = createInsertSchema(schedules, {
    scheduleType: z.enum(["application", "compose", "server", "dokploy-server"]),
- });
+ }).omit({ appName: true, organizationId: true });

Zod’s omit drops appName from the accepted input. There is no longer any value a caller can send, well-formed or otherwise, because the server derives the name itself.

Second, every site that still interpolates a path into a command quotes it:

+ import { quote } from "shell-quote";

- const command = `rm -rf ${fullPath}`;
+ const command = `rm -rf ${quote([fullPath])}`;

shell-quote escapes the string so the shell reads it as one word rather than as syntax. The same change lands in handleScript and in createDeploymentSchedule, so all three command strings are covered, including the two the CVE does not describe.

Adding APP_NAME_REGEX to a ninth schema would have closed the reported bug too. This is stronger for a reason worth naming: removing the input ends the whole class for this field, since a future schema cannot forget a regex on something callers can no longer set, and quoting the sinks means a metacharacter arriving tomorrow from somewhere the server currently trusts is still only data. The allowlist addressed the source, at the sites someone remembered. This addresses the source and the sink, everywhere.

What to take from it

The trap is that path.join looks like sanitisation. It normalises paths and escapes nothing, and a value that is perfectly safe as a path is just a string once it lands in a command template. In a diff the two cases look identical.

The real defect is the interpolation, not the missing regex. execFile takes a command and its arguments as a list, so no shell ever parses them, and fs.rm and fs.mkdir need no shell at all. One branch of Dokploy’s own deployment code already does it that way.

And when you read a project that has fixed one instance of a class, do not stop at “is this fixed”. Grep for the field. Eight correct schemas show the maintainers understood the bug perfectly well. What was missing was the search for copy number nine.

References