T09 · Insecure Skill Coding Practices
Warning
- Location
- scripts/scaffold-workspace.sh:10
- Finding
- Workspace Files Are Overwritten Without Confirmation or Symlink Protection<![CDATA[ ## Vulnerability Details **File Location**: `scripts/scaffold-workspace.sh`, lines 10–58 **Vulnerability Type**: Unchecked destructive file overwrite and symbolic-link following **Risk Level**: Medium ### Vulnerable Code ```bash TARGET="${1:-.}" mkdir -p "$TARGET/references" "$TARGET/memory" "$TARGET/scripts" # Minimal placeholders (you can overwrite with your customized versions) cat > "$TARGET/IDENTITY.md" <<'EOF' # IDENTITY.md - Name: Omni - Vibe: sharp, calm, practical - Emoji: 🦞 EOF cat > "$TARGET/USER.md" <<'EOF' # USER.md - Preferred name: - How to address you: - Timezone: Europe/Oslo EOF cat > "$TARGET/SOUL.md" <<'EOF' # SOUL.md You are Omni 🦞. Be direct and practical. Prefer tool-first verification when correctness matters. EOF cat > "$TARGET/TOOLS.md" <<'EOF' # TOOLS.md # Environment-specific notes (paths, aliases, services). Do not store secrets here. EOF cat > "$TARGET/AGENTS.md" <<'EOF' # AGENTS.md Every session: read SOUL.md, USER.md, memory/YYYY-MM-DD.md (today+yesterday). In main private session also read MEMORY.md if present. Safety: - Ask before destructive actions; prefer trash over rm. - Ask before outbound messages. - Stop on CLI errors; run --help and recover. - Never store credentials in this repo. EOF cat > "$TARGET/HEARTBEAT.md" <<'EOF' # HEARTBEAT.md # Keep empty to skip heartbeat. EOF cat > "$TARGET/BOOTSTRAP.md" <<'EOF' # BOOTSTRAP.md First-run ritual: 1) Ask user for mission + autonomy + boundaries + memory preference. 2) Update IDENTITY/USER/SOUL/AGENTS. 3) Seed memory/YYYY-MM-DD.md Delete this file after completion. EOF ``` ### Technical Analysis The script accepts an arbitrary destination directory and writes workspace files using truncating shell redirection. It does not determine whether destination files already exist, request confirmation, create backups, stage changes, or reject symbolic links. For regular files, `>` truncates existing content before writing the scaffold. This can destroy customized ...[truncated 1802 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Refuse to overwrite existing files by default and require an explicit `--force` or `--overwrite` option. 2. Before every write, check that the destination does not exist as a symbolic link, for example with `[[ -L "$path" ]]`. 3. When overwriting is explicitly authorized, create timestamped backups and display a diff before replacement. 4. Prefer creating the complete scaffold in a newly created staging directory, validating it, and then moving it into place. 5. Create files with no-clobber semantics where possible, such as `set -o noclobber` or an atomic exclusive-create implementation. 6. Canonicalize and validate the target directory, especially when it may be shared or controlled by another user. 7. Warn against running the script with elevated privileges and fail when the target directory or existing files have unexpected ownership. 8. Apply equivalent protections to the dated memory file written later in the script. ]]>
