T05 · Unauthorized Access and Privilege Escalation
Error
- Location
- SKILL.md:19
- Finding
- Recovery instructions grant unnecessary write access to the raw target device<![CDATA[ ## Vulnerability Details **File Location**: `SKILL.md:19-22`; repeated in `scripts/diag.sh:18-22` and `references/tool-limits.md:78` **Vulnerability Type**: Violation of least privilege for raw block-device access **Risk Level**: High ### Vulnerable Code and Instructions From `SKILL.md:19-22`: ```markdown 2. **All operations must open the device read-only**. When permissions are required, granting read permission is sufficient (`sudo chown $USER:disk <dev> && sudo chmod 660 <dev>`); do not use `sudo mount`. ``` The same recommendation is presented to users by `scripts/diag.sh:18-22`: ```bash if [ ! -r "$DEV" ]; then echo "!! No permission to read $DEV. Run as root, or execute:" echo " sudo chown \$USER:disk $DEV && sudo chmod 660 $DEV" exit 1 fi ``` It is also repeated in `references/tool-limits.md:78`: ```markdown 2. Is the device readable? → No: sudo chown $USER:disk <dev> ``` ### Technical Analysis The documented `chmod 660` operation grants both read and write access to the device owner and group. Changing the device owner to the interactive user additionally gives every process running under that account direct write access to the raw block device. This contradicts the project's stated read-only recovery model. Raw block-device write access is not necessary for the diagnostic or recovery scripts: both Python code and `diag.sh` only require read access. A mistaken shell command, compromised user process, parser defect, or unrelated application running under the same account could consequently write directly to filesystem metadata and data blocks. The permission change can also persist until the device node is recreated or its ownership and mode are manually restored. ### Attack Path 1. A user cannot initially read the recovery device. 2. The user follows the supplied instruction and runs: ```bash sudo chown "$USER":disk /dev/sdb1 sudo chmod 660 /dev/sdb1 ``` 3. The interactive user and members of the `disk` grou ...[truncated 967 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Remove every recommendation to use `chmod 660` or transfer ownership of a block device to an interactive user. 2. Use a narrowly scoped privileged invocation that preserves root ownership and opens the device read-only. 3. If an access-control change is unavoidable, grant read-only access through an appropriate temporary ACL or mode, for example: ```bash sudo setfacl -m "u:$USER:r--" /dev/sdb1 ``` Remove the ACL immediately after recovery: ```bash sudo setfacl -x "u:$USER" /dev/sdb1 ``` 4. Update `diag.sh` to treat write access as an error instead of a warning: ```bash if [ -w "$DEV" ]; then echo "Refusing to continue: the target device is writable." >&2 exit 1 fi ``` 5. Preserve and restore the original ownership, mode, and ACLs if the workflow modifies device permissions. 6. Apply the corrected guidance consistently in `SKILL.md`, `scripts/diag.sh`, and `references/tool-limits.md`. ]]>
