T09 · Insecure Skill Coding Practices
- Location
scripts/script.sh:19- Finding
Option Injection Through Unvalidated ZIP Command Arguments
- Content
View full analysis
}" shift [ $# -eq 0 ] && die "No files specified" zip -rv "$archive" "$@" 2>&1 | while IFS= read -r line; do echo " $line" done ``` ```bash cmd_add() { check_deps local archive="${1:?Usage: zip add }" shift [ $# -eq 0 ] && die "No files specified" [ ! -f "$archive" ] && die "Archive not found: $archive" zip -rv "$archive" "$@" 2>&1 | while IFS= read -r line; do echo " $line" done ``` ```bash cmd_password() { check_deps local archive="${1:?Usage: zip password }" local pass="${2:?Missing password}" shift 2 [ $# -eq 0 ] && die "No files specified" zip -e -P "$pass" -rv "$archive" "$@" 2>&1 | while IFS= read -r line; do echo " $line" done ``` ### Technical Analysis Quoting shell variables prevents shell word splitting and shell metacharacter expansion, but it does not prevent the invoked `zip` program from interpreting an argument beginning with `-` as an option. The archive name and user-provided file operands are forwarded directly to `zip` without validation or a supported end-of-options delimiter. Consequently, an attacker who controls the archive name or file arguments can supply option-like values that alter the behavior of `zip`. Common Info-ZIP implementations support security-sensitive options, including archive test command configuration such as `-T` and `-TT`. Where options are accepted after the archive operand, malicious file arguments can therefore reach utility-level command execution functionality. Even where the installed `zip` implementation or argum ...[truncated 1490 chars]- Remediation
View remediation
