Back to skill

Security audit

ext4-recovery

Security checks for vulnerabilities and agentic risk

Overview

This ext4 recovery skill is mostly purpose-aligned, but it gives users raw disk write-capable permissions and lacks safeguards that could prevent accidental data loss.

Review before installing. Use this only on a correctly identified offline source device, prefer a forensic image or narrowly scoped sudo read-only commands, do not follow the chmod 660/chown device workaround, and choose an empty output directory on a separate filesystem. Treat shell history and logs as sensitive and redact unrelated secrets before sharing them with an agent.

Vulnerability Patterns
  • Unauthorized Access and Privilege EscalationObtains permissions beyond the task's legitimate needs
  • Insecure Skill Coding PracticesFinds exploitable flaws such as hardcoded secrets or command injection
  • Skill Instruction HijackingAlters the agent's session goals or safety constraints when the skill loads
  • Agent Memory PoisoningWrites attacker-controlled rules into memory that affect later sessions
  • Remote Payload Retrieval and ExecutionFetches external code whose behavior can change after review
Findings (2)

T05 · Unauthorized Access and Privilege Escalation

Error
Location
SKILL.md:19
Finding

Recovery instructions grant unnecessary write access to the raw target device

Content
View full analysis
&& sudo chmod 660 `); 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 ``` ### 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
View remediation
&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`. ]]>

T09 · Insecure Skill Coding Practices

Error
Location
scripts/ext4recover.py:273
Finding

Recovery output can be written onto the source filesystem and overwrite recoverable data

Content
View full analysis
%s ===" % (ino, outdir)) w = Walker(js, limit_mb * 2**20 if limit_mb else None) nf, nb = w.walk(ino, str(ino), outdir, quiet=quiet) ``` ### Technical Analysis Although the error message says that the output must reside on anoth ...[truncated 2632 chars]
Remediation
View remediation
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Tool MisuseTool Parameter Abuse, Chaining Abuse, Unsafe Defaults
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
Findings (11)

Chaining Abuse

High
Category
Tool Misuse
Confidence
75% confidence
Finding

Tool calls are chained to bypass individual safety checks or escalate capabilities beyond what any single tool call would allow.

Content

Scanner excerpt · SKILL.md (reported line 21)May include surrounding context.

md
if [ ! -r "$DEV" ]; then
  echo "!! 无读取 $DEV 的权限。请用 root 运行,或执行:"
  echo "   sudo chown \$USER:disk $DEV && sudo chmod 660 $DEV"
  exit 1
fi

Chaining Abuse

High
Category
Tool Misuse
Confidence
75% confidence
Finding

Tool calls are chained to bypass individual safety checks or escalate capabilities beyond what any single tool call would allow.

Content

Scanner excerpt · scripts/diag.sh (reported line 21)May include surrounding context.

sh
if [ ! -r "$DEV" ]; then
  echo "!! 无读取 $DEV 的权限。请用 root 运行,或执行:"
  echo "   sudo chown \$USER:disk $DEV && sudo chmod 660 $DEV"
  exit 1
fi

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
92% confidence
Finding

The skill invokes shell commands and local scripts against raw block devices but does not declare any tool or permission scope. Without explicit allowed-tools/permissions, an agent may execute broad shell operations in an under-constrained way, increasing the chance of unsafe device access or misuse beyond the intended read-only recovery workflow.

Content

No source excerpt is available for this finding.

Sudo/Root Execution

Medium
Category
Privilege Escalation
Confidence
90% confidence
Finding

Setting chmod 660 on the block device broadens direct access to the raw device for the owner and group, which can enable accidental or unauthorized disk interaction. In the context of a recovery workflow, even small mistakes can destroy evidence or recovered data, so permission changes on the source device are especially risky.

Content

Scanner excerpt · SKILL.md (reported line 21)May include surrounding context.

md
1. **绝不挂载待恢复分区**(读写挂载会立刻开始复用空闲块,覆盖待恢复数据)。
   不要点文件管理器、不要自动挂载、不要 `fsck` 修复。
2. **所有操作只读打开设备**。需要写权限时只授予读权限即可
   (`sudo chown $USER:disk <dev> && sudo chmod 660 <dev>`),不要用 `sudo mount`。
3. **恢复结果必须写到另一个文件系统**,绝不能写回待恢复分区。
4. 恢复产物先落地并校验,**之后**才考虑写回原盘。
5. 先做体检与可行性判断,再动手;不要在主盘上反复试探工具。

Sudo/Root Execution

Medium
Category
Privilege Escalation
Confidence
90% confidence
Finding

Setting chmod 660 on the block device broadens direct access to the raw device for the owner and group, which can enable accidental or unauthorized disk interaction. In the context of a recovery workflow, even small mistakes can destroy evidence or recovered data, so permission changes on the source device are especially risky.

Content

Scanner excerpt · SKILL.md (reported line 21)May include surrounding context.

md
1. **绝不挂载待恢复分区**(读写挂载会立刻开始复用空闲块,覆盖待恢复数据)。
   不要点文件管理器、不要自动挂载、不要 `fsck` 修复。
2. **所有操作只读打开设备**。需要写权限时只授予读权限即可
   (`sudo chown $USER:disk <dev> && sudo chmod 660 <dev>`),不要用 `sudo mount`。
3. **恢复结果必须写到另一个文件系统**,绝不能写回待恢复分区。
4. 恢复产物先落地并校验,**之后**才考虑写回原盘。
5. 先做体检与可行性判断,再动手;不要在主盘上反复试探工具。

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The skill instructs collection of shell history and system logs, which can expose sensitive user activity, credentials, hostnames, paths, and unrelated operational data. Because no privacy warning, consent step, or minimization guidance is provided, an agent could over-collect forensic evidence beyond what is necessary for ext4 recovery.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
90% confidence
Finding

The document includes operational guidance that can directly affect a live filesystem, including immediate unmount actions and a device ownership change, but it does not present a clear, explicit warning that these steps can disrupt services, weaken device access controls, or cause further data loss if run on the wrong target. In a recovery/forensics skill, such commands are contextually relevant, but the lack of prominent safety guardrails makes accidental misuse materially more likely.

Content

No source excerpt is available for this finding.

Sudo/Root Execution

Medium
Category
Privilege Escalation
Confidence
86% confidence
Finding

The instruction sudo chown $USER:disk <dev> changes ownership of a block device node to the invoking user, granting broader direct access to raw disk contents and potentially persisting an unsafe permission state beyond the recovery session. In the context of filesystem recovery this may be suggested for convenience, but it is risky because a typo or inappropriate device selection can expose sensitive data or enable destructive writes to the wrong disk.

Content

Scanner excerpt · references/tool-limits.md (reported line 78)May include surrounding context.

text
1. 分区是否已挂载?          → 是:立即 umount。绝不要在挂载状态下恢复。
2. 设备是否可读?            → 否:sudo chown $USER:disk <dev>
3. dumpe2fs -h 看三件事:
     a. Filesystem state 是否 clean(决定 s_start 是否为 0)
     b. Total journal size(决定覆盖窗口长度)

Sudo/Root Execution

Medium
Category
Privilege Escalation
Confidence
70% confidence
Finding

Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Content

Scanner excerpt · scripts/diag.sh (reported line 7)May include surrounding context.

sh
# 用法: bash diag.sh /dev/sdb1 [输出目录]
#
# 严格只读:不写入目标设备、不挂载该分区。若发现分区已挂载会立即中止。
# 需要能读设备节点(root,或先 `sudo chown $USER:disk <dev>`)。

DEV="${1:?用法: bash diag.sh /dev/sdbX [输出目录]}"
OUT="${2:-$PWD/ext4-recovery-diag}"

Sudo/Root Execution

Medium
Category
Privilege Escalation
Confidence
91% confidence
Finding

The explicit recommendation to run 'chmod 660' on the device node grants write permission in addition to read permission. On a block device containing recoverable evidence, enabling write access materially increases the risk of data alteration, evidence contamination, or destructive operator mistakes.

Content

Scanner excerpt · scripts/diag.sh (reported line 21)May include surrounding context.

sh
if [ ! -r "$DEV" ]; then
  echo "!! 无读取 $DEV 的权限。请用 root 运行,或执行:"
  echo "   sudo chown \$USER:disk $DEV && sudo chmod 660 $DEV"
  exit 1
fi

Sudo/Root Execution

Medium
Category
Privilege Escalation
Confidence
91% confidence
Finding

The explicit recommendation to run 'chmod 660' on the device node grants write permission in addition to read permission. On a block device containing recoverable evidence, enabling write access materially increases the risk of data alteration, evidence contamination, or destructive operator mistakes.

Content

Scanner excerpt · scripts/diag.sh (reported line 21)May include surrounding context.

sh
if [ ! -r "$DEV" ]; then
  echo "!! 无读取 $DEV 的权限。请用 root 运行,或执行:"
  echo "   sudo chown \$USER:disk $DEV && sudo chmod 660 $DEV"
  exit 1
fi