Skip to main content
CVE Vulnerability Database
Vulnerability Database/CVE-2025-54872

CVE-2025-54872: onion-site-template Secret Exposure Flaw

CVE-2025-54872 is a secret exposure vulnerability in onion-site-template that embeds Tor secrets in images, risking hidden service compromise. This article covers technical details, affected commits, and fixes.

Updated:

CVE-2025-54872 Overview

CVE-2025-54872 affects onion-site-template, a self-hosting sample project for Tor hidden services. Versions including commit 3196bd89 build a Docker image that bakes in Tor secrets when those secrets were copied from an existing onion domain. An attacker who obtains the image, whether shared publicly or extracted from a non-containerized environment, can recover the private keys controlling the onion site. With those secrets, the attacker can impersonate the hidden service and effectively compromise the website. The issue is classified as Use of Hard-coded Credentials [CWE-798] and was fixed in commit bc9ba0fd.

Critical Impact

Disclosure of a Tor hidden service's private keys allows an attacker to take over the onion domain and impersonate the original site.

Affected Products

  • onion-site-template repository maintained by Vessel9817
  • Builds produced from commit 3196bd89 up to the fix in bc9ba0fd
  • Docker images generated using the pre-patch config/tor/Dockerfile

Discovery Timeline

  • 2025-08-06 - CVE-2025-54872 published to NVD
  • 2026-04-15 - Last updated in NVD database

Technical Details for CVE-2025-54872

Vulnerability Analysis

The onion-site-template project provides a scalable sample for hosting a Tor hidden service. In pre-patch builds, the Tor Dockerfile copied the contents of the local ./secrets/ directory directly into /var/lib/tor/website/ during image build. When operators reused secrets from an existing onion domain, the resulting image carried the onion service's private key and identity files as part of its filesystem layers.

Any party obtaining the built image, through a registry push, an exported tarball, or filesystem access on a host running the container outside an isolated environment, can extract those layers and recover the secrets. Possession of the private key permits the holder to publish descriptors for the same onion address, redirect users, and conduct phishing or content tampering under the victim's identity.

Root Cause

The root cause is embedding sensitive material into a build artifact rather than mounting it at runtime. The pre-patch Dockerfile bound the secrets to the image instead of injecting them through a runtime volume, and no .dockerignore excluded secret directories from the build context.

Attack Vector

Exploitation is network-reachable when the image is shared via a public or semi-public channel. Local exploitation is possible whenever the image, its layers, or the build context are accessible on a host that is not strictly containerized. No authentication or user interaction is required to extract the embedded files from an image.

text
// Pre-patch Dockerfile (config/tor/Dockerfile) - vulnerable behavior
// Secrets are copied into image layers at build time:
//   COPY "./secrets/" "/var/lib/tor/website/"
//   COPY "./torrc"    "/etc/tor/"

// Post-patch Dockerfile - secrets handled via a runtime volume
+FROM alpine:3.22.0 AS init
+WORKDIR /usr/app/
+COPY [ "./init.sh", "./" ]
+VOLUME [ "/secrets/" ]
+ENTRYPOINT [ "./init.sh" ]

FROM debian:bookworm-slim AS run
RUN apt-get update && \
    apt-get install -y --no-install-recommends tor && \
    apt-get clean && \
    chmod 700 -R "/var/lib/tor" && \
    chown -R debian-tor:debian-tor "/var/lib/tor"

Source: GitHub Commit bc9ba0fd

Detection Methods for CVE-2025-54872

Indicators of Compromise

  • Presence of files under /var/lib/tor/website/ inside a built image layer, including hs_ed25519_secret_key or hostname.
  • Image build contexts that contain a secrets/ directory without a matching .dockerignore entry.
  • Unexpected descriptors being published for an onion address from an IP or relay not controlled by the operator.

Detection Strategies

  • Inspect image layers with docker history and docker save to confirm secret files are not embedded in any layer.
  • Scan container registries and Git history for committed secrets/ directories or Tor key material.
  • Compare the deployed Dockerfile against commit bc9ba0fd to verify secrets are mounted as a volume rather than copied.

Monitoring Recommendations

  • Monitor onion service descriptors for unexpected publication events that may indicate key reuse by another party.
  • Alert on pushes to internal or public registries that contain images derived from the onion-site-template repository.
  • Track changes to config/tor/Dockerfile and config/tor/.dockerignore in source control to prevent regression.

How to Mitigate CVE-2025-54872

Immediate Actions Required

  • Rotate the affected onion service identity by generating new Tor keys and publishing a new onion address.
  • Delete or quarantine any images, registry tags, or backups built from vulnerable commits that may contain the secrets.
  • Update the repository to commit bc9ba0fd or later before rebuilding any images.

Patch Information

The fix is applied in commit bc9ba0fd, which removes the COPY "./secrets/" step from config/tor/Dockerfile and introduces a dedicated init stage that mounts secrets through a /secrets/ volume at runtime. A new config/tor/.dockerignore excludes secrets/, .env*, Dockerfile*, docker-compose*, and related files from the build context. See the GitHub Security Advisory GHSA-mj8m-c8w9-rw55 and the patch commit.

Workarounds

  • Remove any secrets/ directory from the build context and inject Tor keys through a bind mount or Docker volume at container start.
  • Add an explicit .dockerignore excluding secrets/, .env*, and Dockerfile artifacts before building.
  • Treat any image built from vulnerable commits as compromised and rebuild from a clean context after rotating keys.
bash
# Example: build without embedding secrets, then mount them at runtime
cat > config/tor/.dockerignore <<'EOF'
**/node_modules/
**/.env*
**/secrets/
**/Dockerfile*
**/docker-compose*
**/*.dockerfile
**/.dockerignore
**/dist/
debug/
EOF

docker build -t onion-site:safe config/tor/
docker run --rm \
  -v "$(pwd)/secrets:/secrets:ro" \
  onion-site:safe

Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

Default Legacy - Prefooter | Experience the World’s Most Advanced Cybersecurity Platform

Experience the Most Advanced Cybersecurity Platform

See how the world’s most intelligent, autonomous cybersecurity platform can protect your organization today and into the future.