Back to skill

Security audit

Phy Env Doctor

Security checks for vulnerabilities and agentic risk

Overview

Env Doctor is a disclosed developer audit skill for finding environment-variable usage and secret-handling mistakes, with some expected sensitivity around reading project env files.

Install only if you are comfortable with an agent scanning your project source and env-related files. Run it in repositories you trust, review any report before sharing it, and prefer replacing the fixed /tmp examples with a private mktemp directory if you execute the shell snippets directly.

Vulnerability Patterns
  • Insecure Skill Coding PracticesFinds exploitable flaws such as hardcoded secrets or command injection
  • Skill Instruction HijackingAlters the agent's session goals or safety constraints when the skill loads
  • Agent Memory PoisoningWrites attacker-controlled rules into memory that affect later sessions
  • Remote Payload Retrieval and ExecutionFetches external code whose behavior can change after review
  • Embedded Malicious CodeShips malicious scripts inside the skill and executes them locally
Findings (1)

T09 · Insecure Skill Coding Practices

Warning
Location
SKILL.md:78
Finding

Predictable Shared Temporary Files Permit Symlink Attacks and Local Information Disclosure

Content
View full analysis

Vulnerability Details

File Location: SKILL.md, lines 78-90
Vulnerability Type: Predictable temporary-file usage
Risk Level: Medium

Vulnerable Code

bash
# Parse current .env (if exists)
if [ -f .env ]; then
  grep -v '^#' .env | grep '=' | cut -d= -f1 | sort -u > /tmp/env_defined.txt
  echo "Found $(wc -l < /tmp/env_defined.txt) defined vars"
else
  echo "No .env file found"
fi

# Check for .env.example
if [ -f .env.example ]; then
  grep -v '^#' .env.example | grep '=' | cut -d= -f1 | sort -u > /tmp/env_example.txt
  echo "Found $(wc -l < /tmp/env_example.txt) vars in .env.example"
fi

Technical Analysis

The workflow writes data to the fixed, globally predictable paths /tmp/env_defined.txt and /tmp/env_example.txt. It does not securely create these files, verify their ownership or type, apply restrictive permissions, or remove them after use.

On systems where /tmp is shared among users, an attacker can pre-create either path as a symbolic link. Shell output redirection follows symbolic links, so executing the documented commands can truncate and overwrite another file to which the victim process has write access. This is a time-of-check/time-of-use and unsafe temporary-file vulnerability.

The generated files contain environment-variable names rather than their values. Consequently, the code does not directly copy secret values into /tmp. However, variable names can still disclose service providers, authentication mechanisms, infrastructure components, and other project configuration details. Their readability depends on the executing process's umask.

These shared temporary files are not necessary for the Skill's declared functionality. Comparisons can be performed without persistent temporary files, or with files held inside a securely created private directory.

Attack Path

  1. A local attacker predicts that the victim will run Env Doctor.
  2. The attack ...[truncated 1658 chars]
Remediation
View remediation

Remediation Suggestions

Prefer eliminating temporary files and comparing generated lists through pipelines, process substitution, or in-memory Agent state.

If temporary files are required:

  1. Create a private temporary directory using mktemp -d.
  2. Set umask 077 before creating files.
  3. Register a cleanup trap.
  4. Quote every generated path.
  5. Fail immediately if secure temporary-directory creation fails.
  6. Do not use fixed filenames directly under a shared /tmp directory.

Example hardened pattern:

bash
umask 077
tmp_dir="$(mktemp -d "${TMPDIR:-/tmp}/env-doctor.XXXXXX")" || {
  echo "Failed to create a secure temporary directory" >&2
  exit 1
}
trap 'rm -rf -- "$tmp_dir"' EXIT HUP INT TERM

if [ -f .env ]; then
  grep -v '^#' .env |
    grep '=' |
    cut -d= -f1 |
    sort -u > "$tmp_dir/env_defined.txt"

  echo "Found $(wc -l < "$tmp_dir/env_defined.txt") defined vars"
else
  echo "No .env file found"
fi

if [ -f .env.example ]; then
  grep -v '^#' .env.example |
    grep '=' |
    cut -d= -f1 |
    sort -u > "$tmp_dir/env_example.txt"

  echo "Found $(wc -l < "$tmp_dir/env_example.txt") vars in .env.example"
fi

Where feasible, avoid retaining even environment-variable names beyond the duration required for comparison.

Vulnerability Patterns
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Tool MisuseTool Parameter Abuse, Chaining Abuse, Unsafe Defaults
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
Findings (20)

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · SKILL.md (reported line 3)May include surrounding context.

md
---
name: Env Doctor
description: Scans your codebase to auto-discover every environment variable referenced in source code, generates a fully-documented .env.example, detects missing vars in your current .env, and flags security risks (logged secrets, committed .env files, exposed keys). Works across Node.js, Python, Go, Ruby, and shell scripts. Zero config — just run it in your project directory. Triggers on "env doctor", "check env vars", "generate .env.example", "missing environment variables", "audit secrets", "/env-doctor".
license: Apache-2.0
homepage: https://canlah.ai
metadata:

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · SKILL.md (reported line 80)May include surrounding context.

md
---
name: Env Doctor
description: Scans your codebase to auto-discover every environment variable referenced in source code, generates a fully-documented .env.example, detects missing vars in your current .env, and flags security risks (logged secrets, committed .env files, exposed keys). Works across Node.js, Python, Go, Ruby, and shell scripts. Zero config — just run it in your project directory. Triggers on "env doctor", "check env vars", "generate .env.example", "missing environment variables", "audit secrets", "/env-doctor".
license: Apache-2.0
homepage: https://canlah.ai
metadata:

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · SKILL.md (reported line 81)May include surrounding context.

md
---
name: Env Doctor
description: Scans your codebase to auto-discover every environment variable referenced in source code, generates a fully-documented .env.example, detects missing vars in your current .env, and flags security risks (logged secrets, committed .env files, exposed keys). Works across Node.js, Python, Go, Ruby, and shell scripts. Zero config — just run it in your project directory. Triggers on "env doctor", "check env vars", "generate .env.example", "missing environment variables", "audit secrets", "/env-doctor".
license: Apache-2.0
homepage: https://canlah.ai
metadata:

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · SKILL.md (reported line 84)May include surrounding context.

md
---
name: Env Doctor
description: Scans your codebase to auto-discover every environment variable referenced in source code, generates a fully-documented .env.example, detects missing vars in your current .env, and flags security risks (logged secrets, committed .env files, exposed keys). Works across Node.js, Python, Go, Ruby, and shell scripts. Zero config — just run it in your project directory. Triggers on "env doctor", "check env vars", "generate .env.example", "missing environment variables", "audit secrets", "/env-doctor".
license: Apache-2.0
homepage: https://canlah.ai
metadata:

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · SKILL.md (reported line 125)May include surrounding context.

md
---
name: Env Doctor
description: Scans your codebase to auto-discover every environment variable referenced in source code, generates a fully-documented .env.example, detects missing vars in your current .env, and flags security risks (logged secrets, committed .env files, exposed keys). Works across Node.js, Python, Go, Ruby, and shell scripts. Zero config — just run it in your project directory. Triggers on "env doctor", "check env vars", "generate .env.example", "missing environment variables", "audit secrets", "/env-doctor".
license: Apache-2.0
homepage: https://canlah.ai
metadata:

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · SKILL.md (reported line 127)May include surrounding context.

md
---
name: Env Doctor
description: Scans your codebase to auto-discover every environment variable referenced in source code, generates a fully-documented .env.example, detects missing vars in your current .env, and flags security risks (logged secrets, committed .env files, exposed keys). Works across Node.js, Python, Go, Ruby, and shell scripts. Zero config — just run it in your project directory. Triggers on "env doctor", "check env vars", "generate .env.example", "missing environment variables", "audit secrets", "/env-doctor".
license: Apache-2.0
homepage: https://canlah.ai
metadata:

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · SKILL.md (reported line 128)May include surrounding context.

md
---
name: Env Doctor
description: Scans your codebase to auto-discover every environment variable referenced in source code, generates a fully-documented .env.example, detects missing vars in your current .env, and flags security risks (logged secrets, committed .env files, exposed keys). Works across Node.js, Python, Go, Ruby, and shell scripts. Zero config — just run it in your project directory. Triggers on "env doctor", "check env vars", "generate .env.example", "missing environment variables", "audit secrets", "/env-doctor".
license: Apache-2.0
homepage: https://canlah.ai
metadata:

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · SKILL.md (reported line 154)May include surrounding context.

md
---
name: Env Doctor
description: Scans your codebase to auto-discover every environment variable referenced in source code, generates a fully-documented .env.example, detects missing vars in your current .env, and flags security risks (logged secrets, committed .env files, exposed keys). Works across Node.js, Python, Go, Ruby, and shell scripts. Zero config — just run it in your project directory. Triggers on "env doctor", "check env vars", "generate .env.example", "missing environment variables", "audit secrets", "/env-doctor".
license: Apache-2.0
homepage: https://canlah.ai
metadata:

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · SKILL.md (reported line 194)May include surrounding context.

md
---
name: Env Doctor
description: Scans your codebase to auto-discover every environment variable referenced in source code, generates a fully-documented .env.example, detects missing vars in your current .env, and flags security risks (logged secrets, committed .env files, exposed keys). Works across Node.js, Python, Go, Ruby, and shell scripts. Zero config — just run it in your project directory. Triggers on "env doctor", "check env vars", "generate .env.example", "missing environment variables", "audit secrets", "/env-doctor".
license: Apache-2.0
homepage: https://canlah.ai
metadata:

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · SKILL.md (reported line 212)May include surrounding context.

md
---
name: Env Doctor
description: Scans your codebase to auto-discover every environment variable referenced in source code, generates a fully-documented .env.example, detects missing vars in your current .env, and flags security risks (logged secrets, committed .env files, exposed keys). Works across Node.js, Python, Go, Ruby, and shell scripts. Zero config — just run it in your project directory. Triggers on "env doctor", "check env vars", "generate .env.example", "missing environment variables", "audit secrets", "/env-doctor".
license: Apache-2.0
homepage: https://canlah.ai
metadata:

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · SKILL.md (reported line 213)May include surrounding context.

md
---
name: Env Doctor
description: Scans your codebase to auto-discover every environment variable referenced in source code, generates a fully-documented .env.example, detects missing vars in your current .env, and flags security risks (logged secrets, committed .env files, exposed keys). Works across Node.js, Python, Go, Ruby, and shell scripts. Zero config — just run it in your project directory. Triggers on "env doctor", "check env vars", "generate .env.example", "missing environment variables", "audit secrets", "/env-doctor".
license: Apache-2.0
homepage: https://canlah.ai
metadata:

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · SKILL.md (reported line 214)May include surrounding context.

md
---
name: Env Doctor
description: Scans your codebase to auto-discover every environment variable referenced in source code, generates a fully-documented .env.example, detects missing vars in your current .env, and flags security risks (logged secrets, committed .env files, exposed keys). Works across Node.js, Python, Go, Ruby, and shell scripts. Zero config — just run it in your project directory. Triggers on "env doctor", "check env vars", "generate .env.example", "missing environment variables", "audit secrets", "/env-doctor".
license: Apache-2.0
homepage: https://canlah.ai
metadata:

Credential Access

High
Category
Privilege Escalation
Confidence
87% confidence
Finding

Step 2 explicitly compares against the current .env, meaning the skill is designed to access a file that commonly contains secrets. Even if it only extracts variable names, the operation touches credential-bearing material and could be adapted or mishandled by an agent to expose secret contents or metadata.

Content

Scanner excerpt · SKILL.md (reported line 76)May include surrounding context.


Step 2: Compare Against Current .env

bash
# Parse current .env (if exists)

Credential Access

High
Category
Privilege Escalation
Confidence
92% confidence
Finding

The shell snippet reads '.env' directly and parses it, creating a clear credential-access path since .env files often contain API keys, passwords, and tokens. Although the intent is inventorying variable names, direct file access to secrets materially raises exposure risk in an autonomous agent setting.

Content

Scanner excerpt · SKILL.md (reported line 79)May include surrounding context.

Step 2: Compare Against Current .env

bash
# Parse current .env (if exists)
if [ -f .env ]; then
  grep -v '^#' .env | grep '=' | cut -d= -f1 | sort -u > /tmp/env_defined.txt
  echo "Found $(wc -l < /tmp/env_defined.txt) defined vars"

Credential Access

High
Category
Privilege Escalation
Confidence
89% confidence
Finding

The git check reveals whether '.env' is tracked, which is security-relevant metadata about secret storage practices. While not exposing the values themselves, it can disclose the presence and repository status of sensitive files and is part of a credential-discovery workflow.

Content

Scanner excerpt · SKILL.md (reported line 124)May include surrounding context.

Check for dangerous patterns that could expose secrets:

bash
# 1. Is .env committed to git?
git ls-files .env 2>/dev/null && echo "⚠️  .env IS TRACKED BY GIT"

# 2. Is .env in .gitignore?

Credential Access

High
Category
Privilege Escalation
Confidence
88% confidence
Finding

Searching for '.env*' files enumerates secret-bearing files across the repository, including nested environments that may contain production credentials. File discovery alone is lower risk than value extraction, but in agent workflows it expands the sensitive surface and can facilitate further unauthorized inspection.

Content

Scanner excerpt · SKILL.md (reported line 140)May include surrounding context.

-E "(api_key|apikey|secret|password|token)\s*=\s*['"][a-zA-Z0-9+/]{20,}['"]"
. | grep -v ".env|test|spec|mock|example" | grep -v node_modules | head -10

5. Any .env files other than root?

find . -name ".env*" -not -path "/node_modules/" -not -name ".env.example" -not -name ".env.sample"

text

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · SKILL.md (reported line 222)May include surrounding context.

md
### ⚠️ Security Issues

**[CRITICAL]** `.env` is tracked by git
→ Run: `echo ".env" >> .gitignore && git rm --cached .env`

**[HIGH]** Secret potentially logged at `src/auth.js:42`:
→ `console.log('Auth config:', process.env.JWT_SECRET)` — remove this log

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The metadata embeds broad trigger phrases such as 'check env vars', 'generate .env.example', and 'audit secrets' that can plausibly appear in normal conversation or unrelated workflows. Because this skill reads code and inspects .env-related files, accidental invocation could cause unintended access to sensitive project configuration and secret-adjacent data.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

The trigger section repeats ambiguous phrases without guardrails, increasing the chance of unintentional activation. In this skill's context, accidental activation is more dangerous than usual because the subsequent workflow inspects source code, repository state, and environment configuration artifacts that may reveal secret names or locations.

Content

No source excerpt is available for this finding.

Unsafe Defaults

Medium
Category
Tool Misuse
Confidence
60% confidence
Finding

Tool defaults are unsafe or overly permissive (e.g. disabled TLS verification, no authentication, world-writable permissions). Unsafe defaults widen the attack surface.

Content

Scanner excerpt · SKILL.md (reported line 168)May include surrounding context.

md
STRIPE_WEBHOOK_SECRET= # Stripe webhook signing secret. Get from Stripe CLI or dashboard.

# ─── APP CONFIG ─────────────────────────────────────────────
NODE_ENV=development   # Environment: development | staging | production
PORT=3000              # HTTP server port
LOG_LEVEL=info         # Logging level: debug | info | warn | error
EOF

Static analysis

No suspicious patterns detected.