T09 · Insecure Skill Coding Practices
- Location
scripts/script.sh:35- Finding
Plaintext Persistence of Potentially Sensitive Command Inputs
- Content
View full analysis
> "$DATA_DIR/history.log"; } cmd_scan() { echo " Scanning for vulnerabilities..." _log "scan" "${1:-}" } cmd_audit() { echo " Running audit checklist..." _log "audit" "${1:-}" } cmd_check() { echo " Checking: $1" _log "check" "${1:-}" } cmd_report() { echo " Security report generated" _log "report" "${1:-}" } cmd_harden() { echo " Step 1: Update | Step 2: Firewall | Step 3: Auth" _log "harden" "${1:-}" } cmd_encrypt() { echo " Encrypting: $1" _log "encrypt" "${1:-}" } cmd_hash() { echo "$1" | sha256sum | cut -d" " -f1 _log "hash" "${1:-}" } ``` ### Technical Analysis The shared `_log` function writes command arguments directly into the persistent `$DATA_DIR/history.log` file. In particular, the `encrypt` and `hash` commands accept values that users may reasonably expect to be secrets, credentials, tokens, personal information, or cryptographic material. Although `hash` produces a SHA-256 digest on standard output, it subsequently records the original unhashed input. The `encrypt` command similarly records its original input without protecting it. The script does not explicitly create the data directory and history file with restrictive permissions, does not redact sensitive values, and does not implement retention or cleanup. This creates a confidentiality flaw rather than a privilege-escalation vulnerability. Exploitation requires filesystem access to the resulting log, such as access through another local account, a compromised process, an insecure backup, or accidentally broad permissions. ### Attack Path 1. A user invokes `scripts/script.sh hash ` or `scripts/script.sh encrypt `. 2. The command passes the orig ...[truncated 856 chars]- Remediation
View remediation
