Skip to content

[Docs]: Use secure mktemp pattern instead of predictable temp files #153

@sjnims

Description

@sjnims

Which documentation needs improvement?

  • Skill documentation

Specific Location

  • plugins/plugin-dev/skills/plugin-settings/references/parsing-techniques.md (lines 202, 219, 228)
  • plugins/plugin-dev/skills/plugin-settings/references/real-world-examples.md (lines 204, 295, 359)

What's unclear or missing?

The documentation shows a predictable temp file pattern that could be exploited in certain scenarios:

# Current (predictable - uses PID which can be guessed)
TEMP_FILE="${FILE}.tmp.$$"

This pattern is a known security anti-pattern because:

  • $$ (PID) is predictable and can be enumerated
  • Attackers could pre-create symlinks to sensitive files
  • Race conditions between check and use

Suggested Improvement

Replace with secure mktemp pattern:

# Secure - uses random filename
TEMP_FILE=$(mktemp) || { echo "Failed to create temp file" >&2; exit 1; }
trap 'rm -f "$TEMP_FILE"' EXIT

# ... use temp file ...

mv "$TEMP_FILE" "$TARGET_FILE"

Type of issue

  • Incorrect information (security best practice)

Additional Context

Found 6 instances using grep -rn '\.tmp\.\$' plugins/plugin-dev/skills/:

  1. parsing-techniques.md:202
  2. parsing-techniques.md:219
  3. parsing-techniques.md:228
  4. real-world-examples.md:204
  5. real-world-examples.md:295
  6. real-world-examples.md:359

While this is documentation (not executable code), it teaches developers a pattern they might copy into production scripts.

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions