T09 · Insecure Skill Coding Practices
- Location
add-to-fstab.sh:39- Finding
Unvalidated SMB target fields allow persistent /etc/fstab injection
- Content
View full analysis
> /etc/fstab ``` ### Technical Analysis The script validates `LOCAL_NAME`, but does not validate `IP` or `SHARE` before incorporating them into a root-owned `/etc/fstab` entry. Replacing spaces in `SHARE` with `\040` does not neutralize tabs, newlines, carriage returns, backslashes, or other characters with structural meaning in an fstab file. Shell quoting prevents ordinary shell command injection, but it does not prevent configuration injection. A newline embedded in `IP` or `SHARE` remains present when `echo` appends `FSTAB_ENTRY`. An attacker who can influence arguments supplied to this privileged script can therefore terminate the intended record and introduce additional fstab records. The result is persistent because `/etc/fstab` is processed across reboots and the script subsequently reloads systemd. The declared persistent automount feature is legitimate, but accepting unvalidated data when constructing its privileged configuration exceeds safe implementation requirements. `USERNAME` is also written without validation to a credentials file. Embedded line breaks could alter that file's directive structure, although the more severe persistent system configuration issue is caused by `IP` and `SHARE`. ### Attack Path 1. ...[truncated 1428 chars]- Remediation
View remediation
