T09 · Insecure Skill Coding Practices
Warning
- Location
- scripts/scaffold-workspace.sh:9
- Finding
- Unconditional Overwrite of Existing Workspace Files## Vulnerability Details **File Location**: `scripts/scaffold-workspace.sh`, lines 9–58 **Vulnerability Type**: Unsafe file overwrite **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 target directory defaults to the current working directory. The script creates destination directories but does not verify that the target is a new or empty workspace. Each `cat >` redirection opens its destination with truncation. Consequently, existing workspace files are replaced without a warning, confirmation prompt, backup, dry run, or explicit force option. This behavior affects identity, user preferences ...[truncated 1709 chars]
- Remediation
- ## Remediation Suggestions 1. Refuse to modify an existing or non-empty workspace by default. 2. Check every destination before writing, for example with `[[ -e "$path" ]]`. 3. Add an explicit `--force` option rather than treating replacement as the default. 4. Before forced replacement, list all affected files and request confirmation when running interactively. 5. Create timestamped backups of every existing destination before overwriting it. 6. Provide a `--dry-run` mode that reports planned directories and file changes. 7. Generate files in a temporary staging directory and move them into place only after all checks succeed. 8. Where appropriate, use no-clobber semantics such as `set -o noclobber` or guarded creation rather than unconditional `>` redirection. 9. If updating an existing workspace is supported, show diffs and modify only explicitly selected files instead of replacing the complete configuration.
