Skip to content

security: [MEDIUM] Credential exposure via temp file in growth.sh #3182

@louisgv

Description

@louisgv

Finding

File: .claude/skills/setup-agent-team/growth.sh:82-97
Severity: MEDIUM

Description

Reddit credentials are substituted into a markdown file that is then passed to claude via stdin. While the file is created with 0600 permissions, credentials still touch the filesystem unnecessarily.

Current flow:

PROMPT_FILE=$(mktemp /tmp/growth-prompt-XXXXXX.md)
chmod 0600 "${PROMPT_FILE}"
cat "$PROMPT_TEMPLATE" > "${PROMPT_FILE}"

# Substitute secrets into file
safe_substitute "REDDIT_CLIENT_ID_PLACEHOLDER" "${REDDIT_CLIENT_ID:-}" "${PROMPT_FILE}"
safe_substitute "REDDIT_CLIENT_SECRET_PLACEHOLDER" "${REDDIT_CLIENT_SECRET:-}" "${PROMPT_FILE}"
safe_substitute "REDDIT_USERNAME_PLACEHOLDER" "${REDDIT_USERNAME:-}" "${PROMPT_FILE}"
safe_substitute "REDDIT_PASSWORD_PLACEHOLDER" "${REDDIT_PASSWORD:-}" "${PROMPT_FILE}"

claude -p - < "${PROMPT_FILE}"

Risk

  • Credentials persisted to disk (even with 0600) can be recovered from disk snapshots, backups, or forensic analysis
  • If the cleanup trap fails (script killed with SIGKILL, system crash), the file persists
  • Other processes with elevated privileges can read the file

Recommendation

Modify the prompt template to reference environment variables directly, rather than substituting secrets into a temp file:

# In growth-prompt.md template:
Use Reddit API with credentials from:
- Client ID: ${REDDIT_CLIENT_ID}
- Client Secret: ${REDDIT_CLIENT_SECRET}
...

# In growth.sh:
REDDIT_CLIENT_ID="${REDDIT_CLIENT_ID:-}" \
REDDIT_CLIENT_SECRET="${REDDIT_CLIENT_SECRET:-}" \
REDDIT_USERNAME="${REDDIT_USERNAME:-}" \
REDDIT_PASSWORD="${REDDIT_PASSWORD:-}" \
  claude -p - < "${PROMPT_TEMPLATE}"

This keeps credentials in memory only, never touching the filesystem.


Discovered by shell-scanner

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs-human-reviewIssue needs human review before automated processingsafe-to-workSecurity triage: safe for automated processingsecuritySecurity vulnerabilities and concerns

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions