T09 · Insecure Skill Coding Practices
- Location
scripts/restore.sh:61- Finding
Unvalidated archive extraction permits writes outside the restore directory
- Content
View full analysis
- Remediation
View remediation
Security audit
Security checks for vulnerabilities and agentic risk
This appears to be a real backup tool, but it needs Review because it handles credentials and executable agent state with unsafe restore and encryption behavior.
Review this before installing. Treat its backup files as containing passwords, tokens, conversations, and executable agent components. Do not restore archives from anyone you do not fully trust, do not rely on configured encryption unless you explicitly pass --encrypt, and do not use cloud upload without auditing the uploader and destination.
scripts/restore.sh:61Unvalidated archive extraction permits writes outside the restore directory
scripts/restore.sh:166Restore imports untrusted executable scripts, skills, and persistent cron state
scripts/restore.sh:50Predictable temporary paths expose plaintext credentials and decrypted backups
scripts/backup.sh:7Configured encryption is ignored when creating backups
scripts/backup.sh:298Cloud upload executes an unverified user-writable external script
A second independent mismatch is present: the document centers on a full backup platform, yet no actual executable implementation is shown here and static analysis reports major missing functionality. In a backup product, unsupported claims are security-relevant because users may assume recoverability, confidentiality, and off-site protection that are not real.
A second independent mismatch is present: the document centers on a full backup platform, yet no actual executable implementation is shown here and static analysis reports major missing functionality. In a backup product, unsupported claims are security-relevant because users may assume recoverability, confidentiality, and off-site protection that are not real.
Tool parameters are crafted to achieve unintended or unsafe behavior. Parameter abuse can bypass intended safety checks (e.g. shell=True, --force, dangerous glob patterns).
### Security Best Practices
1. **File Permissions**
- Backups created with `chmod 600` (owner only)
- Never `chmod 777` a backup
2. **Storage**
This backup tool intentionally copies a .env file containing secrets into the backup set. While expected for a backup utility, it materially increases the sensitivity of the produced archive and magnifies the impact of any weakness in storage, encryption, upload, or retention handling.
fi
# Environment (secrets)
if [[ -f "${PLATFORM_HOME}/.env" ]]; then
cp "${PLATFORM_HOME}/.env" "${WORK_DIR}/config/"
info " .env (secrets)"
fi
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
# Environment (secrets)
if [[ -f "${PLATFORM_HOME}/.env" ]]; then
cp "${PLATFORM_HOME}/.env" "${WORK_DIR}/config/"
info " .env (secrets)"
fi
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
# Environment (secrets)
if [[ -f "${PLATFORM_HOME}/.env" ]]; then
cp "${PLATFORM_HOME}/.env" "${WORK_DIR}/config/"
info " .env (secrets)"
fi
# Identity
Using ls output piped to xargs rm is unsafe because filenames can contain whitespace, newlines, or leading dashes, causing incorrect deletion targets or option confusion. Since BACKUP_DIR comes from a user-controlled config file, malformed or adversarial filenames in that directory could make pruning delete unintended files matching the glob selection behavior.
BACKUP_COUNT=$(ls -t "${BACKUP_DIR}"/hermes-backup_*.tar.gz* 2>/dev/null | wc -l)
if [[ "$BACKUP_COUNT" -gt "$KEEP_COUNT" ]]; then
info "Pruning old backups (keeping last ${KEEP_COUNT})..."
ls -t "${BACKUP_DIR}"/hermes-backup_*.tar.gz* | tail -n +$((KEEP_COUNT + 1)) | xargs rm -f
info " Removed $((BACKUP_COUNT - KEEP_COUNT)) old backup(s)"
fi
The restore logic restores a backed-up .env file directly into the agent home, which commonly contains API keys, tokens, and other secrets. Because the archive is extracted and its contents are trusted without authenticity verification or content validation, a tampered backup can inject attacker-controlled credentials or configuration, leading to account compromise, data exfiltration, or redirection of the agent to attacker infrastructure.
if [[ "$TARGET_PLATFORM" == "hermes" ]]; then
# Hermes-specific files
[[ -d "${BACKUP_DIR}/config" ]] && restore_item "${BACKUP_DIR}/config/config.yaml" "${TARGET_HOME}/config.yaml" "config.yaml"
[[ -f "${BACKUP_DIR}/config/.env" ]] && restore_item "${BACKUP_DIR}/config/.env" "${TARGET_HOME}/.env" ".env"
[[ -d "${BACKUP_DIR}/identity" ]] && restore_item "${BACKUP_DIR}/identity/SOUL.md" "${TARGET_HOME}/SOUL.md" "SOUL.md"
[[ -d "${BACKUP_DIR}/memories" ]] && restore_item "${BACKUP_DIR}/memories/" "${TARGET_HOME}/memories" "memories"
[[ -d "${BACKUP_DIR}/sessions" ]] && restore_item "${BACKUP_DIR}/sessions/" "${TARGET_HOME}/sessions" "sessions"
The skill advertises and instructs use of shell-capable operations but declares no explicit tool scope or permission boundaries. For a backup skill that handles secrets, filesystem access, restore actions, and cloud configuration, missing tool restrictions increases the chance of overbroad execution or accidental invocation with more access than intended.
The natural-language trigger 'Create a backup of my agent' is broad and could cause unintended invocation in ordinary conversation. In the context of a skill that archives highly sensitive files, accidental triggering could collect secrets, sessions, and workspace contents without the user intending to start a backup operation.
Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.
1. **File Permissions**
- Backups created with `chmod 600` (owner only)
- Never `chmod 777` a backup
2. **Storage**
- Keep local backups in encrypted disk/VeraCrypt
Code scans file system directories looking for sensitive files. This could be reconnaissance for credential theft.
# Check directory permissions
ls -la ~/backups/hermes/
# Fix
chmod 700 ~/backups/hermes/
Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.
ls -la ~/backups/hermes/
chmod 700 ~/backups/hermes/
### "Backup is corrupted"
The script creates a plaintext tar.gz archive containing highly sensitive material such as .env files, auth.json, tokens, credentials, sessions, and state before encryption is optionally applied. This leaves secrets exposed by default and also creates a window where sensitive data exists unencrypted on disk, which is especially risky on shared systems, compromised hosts, or if the backup directory is synced or monitored.
The script can upload archives that contain credentials and conversation/session data to cloud storage without enforcing encryption or presenting a strong confirmation about remote transmission of secrets. If cloud configuration is insecure, misdirected, or compromised, this can lead to broad disclosure of sensitive agent data and authentication material.
Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.
AUTO_BACKUP="/tmp/hermes-pre-restore-$(date +%Y%m%d_%H%M%S).tar.gz"
warn "Creating safety backup of current state..."
tar -czf "$AUTO_BACKUP" -C "$HOME" ".${TARGET_PLATFORM}" 2>/dev/null || true
chmod 600 "$AUTO_BACKUP"
info "Safety backup: $AUTO_BACKUP"
echo ""
fi
Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.
AUTO_BACKUP="/tmp/hermes-pre-restore-$(date +%Y%m%d_%H%M%S).tar.gz"
warn "Creating safety backup of current state..."
tar -czf "$AUTO_BACKUP" -C "$HOME" ".${TARGET_PLATFORM}" 2>/dev/null || true
chmod 600 "$AUTO_BACKUP"
info "Safety backup: $AUTO_BACKUP"
echo ""
fi
Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.
AUTO_BACKUP="/tmp/hermes-pre-restore-$(date +%Y%m%d_%H%M%S).tar.gz"
warn "Creating safety backup of current state..."
tar -czf "$AUTO_BACKUP" -C "$HOME" ".${TARGET_PLATFORM}" 2>/dev/null || true
chmod 600 "$AUTO_BACKUP"
info "Safety backup: $AUTO_BACKUP"
echo ""
fi
Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.
AUTO_BACKUP="/tmp/hermes-pre-restore-$(date +%Y%m%d_%H%M%S).tar.gz"
warn "Creating safety backup of current state..."
tar -czf "$AUTO_BACKUP" -C "$HOME" ".${TARGET_PLATFORM}" 2>/dev/null || true
chmod 600 "$AUTO_BACKUP"
info "Safety backup: $AUTO_BACKUP"
echo ""
fi