Cybersecurity

Dokploy 0.31 build secrets leak: fix, verify clean rebuild

Fix a Dokploy 0.31 build-secret leak with an incident runbook for rotation, cache and registry cleanup, BuildKit mounts, and clean-build verification.

Dokploy Docker deployment security check verifying clean build secrets handling
Dokploy Docker deployment security check verifying clean build secrets handling

Fix a Dokploy 0.31 build-secret leak by treating the credential as compromised. Preserve redacted evidence, rotate the credential, replace ARG or ENV use with a BuildKit secret mount when the active build path supports it, and rebuild from a clean boundary. A successful redeploy proves nothing by itself. Check logs, arguments, image history, metadata, layers, cache, registry artifacts, and running containers.

Treat the secret as compromised before investigating

Treat the secret as compromised first. A token may appear in build output, a failed-build notification, a Dockerfile ARG or ENV, image history, or a deployed image that still works after removal. If it appeared in a build log, assume anyone who could read that log may have obtained it. Later masking does not revoke the credential.

Preserve enough evidence to identify the affected build, but never copy the value. Record the application, Dokploy version, build ID, commit or image digest, timestamps, builder, registry repository, deployment target, and exposure location. Keep the record access-controlled and redacted.

  1. Pause automatic builds, webhooks, scheduled deployments, and registry pushes for the affected application. If the build system is shared and cannot isolate it, pause the shared job.
  2. Record the locations and audiences of the logs without copying secret-bearing lines. Include Dokploy logs, email, chat, CI output, and incident systems.
  3. List every credential the build could read. Include package-registry tokens, cloud keys, SSH keys, signing keys, database passwords, and API tokens.
  4. Store and test a controlled replacement in the intended runtime or deployment path.
  5. Revoke or rotate the old credential through its issuing system. Start with the credential that has the broadest access or greatest impact. Do not rebuild with the old value just to diagnose the incident.

If the secret was committed to Git, treat clones, forks, pull requests, CI workspaces, and repository caches as potentially exposed. Remove it from future revisions. Follow the repository provider’s current procedure for rewriting history and purging cached views. Rewriting history does not rotate the credential.

If build-error or backup notifications were enabled and a build or backup failed, rotate the secrets for the affected application or database.

Trace every possible exposure point

Check every place where the credential may remain. Dokploy 0.31 can use Dockerfile, Compose, Railpack, or a remote builder paths. Confirm the active path in your installation. Compare its controls with current Dokploy and Docker documentation. Do not assume a control or UI field from another release exists in 0.31.

Exposure pointSafe checkWhat the result proves
Logs or notificationsSearch access-controlled logs for a short fingerprint or label, not the value; review email and chat deliveryReaders of that output may have obtained the credential
Dockerfile inputsReview the Dockerfile and build configuration for ARG and ENVThe value was supplied in a form that can persist in configuration or metadata
Image historyInspect docker history --no-trunc IMAGE without copying sensitive outputA command or argument may contain the value
Image configurationInspect Config.Env and labels with sensitive fields redactedThe final image metadata may contain the value
Image layersExport a disposable image and search extracted files without printing matchesA file may remain in an intermediate or final layer
Build cacheReview the active builder and cache configuration without exporting secret-bearing contentA cache record may preserve an unsafe result
RegistryReview tags, manifests, digests, attestations, retention copies, and access logsPushed artifacts may remain after a deployment is deleted
Running containerInspect variable names, mounted files, process configuration, and writable application directories with values redactedThe old credential may still exist at runtime

Run local metadata checks only in a protected environment. Do not paste their output into a ticket or chat.

Linux shell
docker history --no-trunc IMAGE
docker image inspect IMAGE
docker buildx ls

Search for a fingerprint or marker, and report only counts and filenames. A positive result shows where the value existed. It does not show every reader. A negative local result does not clear a remote builder, registry, notification system, or running container.

Dokploy’s exact build-secret fields, cache controls, and builder behavior for 0.31 require confirmation against current Dokploy documentation and release information. Available Dokploy material recommends build-time secrets instead of build arguments and environment variables because those inputs can persist in the image or build history.

Replace unsafe build inputs with a secret mount

Use a BuildKit secret mount for sensitive build input. It makes the secret available to one build step without deliberately placing it in the resulting image or image history. Build arguments and environment variables can appear in metadata, logs, or cached records. Deleting a secret file later does not remove an earlier layer that contained it.

Use a placeholder identifier. Make the package tool read the mounted file:

Dockerfile
# syntax=docker/dockerfile:1
FROM your-builder-image AS build
WORKDIR /src
COPY . .
RUN --mount=type=secret,id=PACKAGE_TOKEN \
    your-package-command --token-file /run/secrets/PACKAGE_TOKEN

FROM your-runtime-image
COPY --from=build /src/output /app

The package command must support file-based input. Do not put the secret in a command line, write it into a configuration copied to the next stage, or print the mounted file.

  1. Remove sensitive ARG and ENV declarations from the Dockerfile and Dokploy build variables. Keep ordinary build settings separate.
  2. Confirm that the active builder uses BuildKit. Confirm that the Dokploy 0.31 path can pass a named secret mount. Check current Dokploy 0.31 documentation, release notes, and Docker builder documentation for the exact setting name and syntax.
  3. If Dokploy exposes the required control, map a secret source to the Dockerfile id. Do not place its value in a command, repository file, ordinary build argument, or Dockerfile.
  4. If the Dokploy 0.31 path cannot provide a verifiable secret mount, stop using that path for the credential. Use a separately controlled BuildKit builder or an external CI process that documents secret-mount support. Then have Dokploy deploy the resulting image.
  5. Run a disposable canary build before changing production. If the canary cannot read the secret through the mount, stop. Do not fall back to ARG or ENV.

A reported Dokploy advisory names version 0.31.1 as the patched version for its described issue. It also recommends rotating anything that may have leaked. Confirm that the advisory’s scope matches this incident before treating an upgrade as the complete fix. The same advisory says an upgrade stops new leaks but does not remove secrets already present in emails, chat channels, or container logs.

Contain contaminated cache, images, and containers

Contain every affected copy before cleanup. Keep the redacted incident record and a known-good rollback image. Deleting a Dokploy deployment does not prove that registry layers, remote cache records, notification copies, or files in an existing container are gone.

  1. Mark affected image digests and tags as unsafe. Prevent their promotion or deployment. Use a rollback image only after checking that it was built without the exposed credential.
  2. Stop reusing the affected local builder cache. For the repaired build, use the documented no-cache option or a new builder context when the unsafe instruction or its output could be cached.
  3. Record the relevant local builder and cache state. Then clear only the records you identified. Broad pruning can remove unrelated rollback images and cache data.
  4. Review remote BuildKit caches, shared runner caches, and registry-backed caches separately. Docker Engine cleanup does not automatically clean a remote builder.
  5. Remove registry tags and manifests that point to contaminated images. Then review immutable digests, retention copies, vulnerability-scan archives, attestations, and audit logs. Registry deletion and retention behavior varies, so check the current rules for the registry in use.
  6. Rebuild from clean source and push the result under a new digest. Record the old digest before removing or quarantining old artifacts.
  7. Redeploy from the new digest. Replace old containers. Inspect their environment, mounted files, process arguments, and writable application directories for the old credential.
  8. If any copy is found after the first rotation, revoke the credential again. Continue treating the affected image or cache as contaminated.

A no-cache build does not delete remote cache records or registry artifacts. If you cannot establish those cleanup boundaries, keep the credential revoked and do not promote the affected image.

Verify the repair with a disposable canary

Verify the repair with a disposable canary before production. Use a narrowly scoped canary credential or unique marker, not a production secret. The expected result is zero matches in logs, image metadata, layers, relevant cache records, registry artifacts, and the deployed canary container.

  1. Create a canary credential with only the permission required by the build step. Record a fingerprint or unique marker separately, never the credential value.
  2. Run the repaired Dockerfile through the exact Dokploy 0.31 path intended for production. Use a disposable application, image repository, and runtime target. Disable or isolate the old cache for this test.
  3. Review build output with a non-printing search. Confirm that neither the credential nor command-line material that could reconstruct it appears.
  4. Inspect docker history --no-trunc IMAGE and docker image inspect IMAGE, with sensitive fields redacted. The marker should be absent from commands, environment entries, labels, and other metadata.
  5. Inspect the final image and, where the test process permits, its extracted layers. Report only match counts and path names. The expected match count is zero.
  6. Review relevant local and remote cache records without exporting secret-bearing content. Confirm that the unsafe build was not reused and that the repaired build contains no marker.
  7. Push the canary image to its disposable registry location. Check tags, manifests, digests, registry logs, attestations, and retention views without copying matched content. Remove the canary artifacts after recording the result.
  8. Deploy the canary container. Inspect variable names, mounted files, process arguments, and application logs with values redacted. The secret should be available only during the required build step unless the application separately needs a rotated runtime credential.
  9. Revoke the canary credential. After the canary passes, repeat the checks for the production rebuild. Promote only the new image digest.

If any check finds the marker, stop promotion. Revoke the canary credential, identify the retaining layer or system, and rebuild after fixing that path. If Dokploy 0.31 cannot provide a verifiable BuildKit secret mount, keep the sensitive build outside Dokploy. Give Dokploy only the clean image.

Conclusion

Document the affected build IDs, old and new image digests, rotated credentials, cache and registry actions, and canary results. Keep contaminated artifacts quarantined until your retention and incident policies allow removal. Then monitor the repaired path for secret-bearing output.

Frequently Asked Questions

Should I upgrade Dokploy before rotating the secret?

Rotate or revoke the exposed credential before relying on an upgrade. A reported advisory names 0.31.1 as the patched version for its described issue, but an upgrade cannot erase secrets already copied into logs, caches, registries, or containers. Confirm that the advisory matches the incident. Check current Dokploy release guidance before changing production.

Are Docker build arguments safe if I delete them later?

No. An ARG or ENV value can enter image history, metadata, logs, or cache before you remove it. Use a BuildKit secret mount for the build step. Then inspect the resulting image and builder records. If the value was already used, rotate it before rebuilding.

What if the secret appeared only in a failed build log?

Treat it as compromised. A failed build can still send logs through Dokploy notifications, CI systems, email, chat, or shared log storage. Preserve the build identifier and access path without copying the value. Rotate the credential. Restrict or remove the affected log according to current Dokploy and log-provider controls.

Sources

Security & Systems Desk

Think Tech Editorial

Practical Linux networking, container hardening, and zero-trust infrastructure playbooks.