Back to skill

Security audit

mitools-desensitize

Security checks for vulnerabilities and agentic risk

Overview

This looks like a real data-masking tool, but it automatically creates reversible plaintext mapping files that can expose the original sensitive data.

Install only if you are comfortable managing reversible mapping files as sensitive data. Use it in a private directory, protect or delete any .mapping.json files immediately, avoid sharing mappings with agents or third parties, and do not run file mode on highly sensitive data unless you accept the restoration risk.

Vulnerability Patterns
  • 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
  • Embedded Malicious CodeShips malicious scripts inside the skill and executes them locally
Findings (1)

T09 · Insecure Skill Coding Practices

Warning
Location
desensitize.py:438
Finding

Reversible Sensitive Data Is Written to a Predictable Plaintext Sidecar File

Content
View full analysis

Vulnerability Details

File Location: desensitize.py, lines 438–441
Vulnerability Type: Predictable plaintext storage of sensitive mappings and unsafe file creation
Risk Level: Medium

Vulnerable Code

python
mapping_file = args.output + ".mapping.json" if args.output else args.file + ".mapping.json"
with open(mapping_file, 'w', encoding='utf-8') as f:
    json.dump(mapping, f, indent=2, ensure_ascii=False)
print(f"📊 映射表已保存到: {mapping_file}")

Technical Analysis

The file-processing action automatically writes its reversible redaction mapping to either <output>.mapping.json or <input>.mapping.json. The mapping can contain original IP addresses, usernames, path usernames, wildcard matches, and digit sequences. Possession of this file can therefore disclose source values that the user intended to redact.

The sidecar is stored in plaintext and created using the process's default umask, without explicitly enforcing owner-only permissions. On a shared system, this can make the mapping readable by other users depending on the environment's permission configuration.

The destination is also predictable and opened with Python's normal write mode. This truncates an existing file and follows symbolic links. If an attacker can write to the destination directory before a more privileged user invokes the Skill, the attacker can create the expected mapping path as a symbolic link to another file writable by the victim. The subsequent invocation will follow that link and overwrite the target with JSON mapping data.

This issue does not independently bypass operating-system permissions: the process can only overwrite targets that its current account is already permitted to write. Exploitation of the symbolic-link condition also requires attacker write access to the directory containing the predictable sidecar path.

Attack Path

  1. A victim invokes the file-redaction action on a sensitive input file.
  2. The Skill derives a predictable ...[truncated 1299 chars]
Remediation
View remediation

Remediation Suggestions

  • Do not write reversible mappings automatically. Require explicit user consent and a separately specified protected destination.
  • Create mapping files with owner-only permissions, such as mode 0600, rather than relying on the ambient umask.
  • Use exclusive creation so an existing path cannot be silently truncated. For example, use os.open() with O_WRONLY | O_CREAT | O_EXCL and mode 0o600.
  • Where supported, add O_NOFOLLOW and verify with lstat() or fstat() that the destination is a regular file and not a symbolic link.
  • Write to a securely created temporary file in the same protected directory, flush and synchronize it, and atomically rename it into place after validating the destination.
  • Refuse shared or insecure destination directories unless their ownership and permissions have been verified.
  • Consider encrypting reversible mappings at rest with a user-supplied key or platform credential-storage mechanism.
  • Clearly warn users that mapping files contain sensitive, reversible source data and must be protected, transferred, retained, and deleted according to the same controls as the original input.
  • Avoid printing sensitive mapping contents to standard output in text mode unless the user explicitly requests them and the output channel is trusted.
Vulnerability Patterns
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
Findings (13)

Context-Inappropriate Capability

High
Category
Not specified by scanner
Confidence
98% confidence
Finding

The skill automatically writes a reversible mapping file alongside the processed data, which preserves the exact originals of masked values. That defeats the core privacy purpose of desensitization if the mapping file is accessible to other local users, backup systems, logs, or later exfiltration; anyone with both files can recover the sensitive data.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

High
Category
Not specified by scanner
Confidence
98% confidence
Finding

This tool explicitly provides a data re-identification path by restoring desensitized text from a mapping table, which directly conflicts with the stated purpose of a desensitization skill. In practice, this defeats privacy protections if the mapping is exposed, logged, or passed to untrusted agents, making sensitive data recoverable.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

High
Category
Not specified by scanner
Confidence
95% confidence
Finding

A desensitization tool is expected to reduce exposure of sensitive information, but this interface accepts both masked text and a mapping JSON that can reconstruct the original values. That makes the privacy control reversible by design without any visible justification or safeguards, enabling unauthorized re-identification of phone numbers, IDs, bank cards, emails, and other personal data.

Content

No source excerpt is available for this finding.

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
92% confidence
Finding

The skill advertises file-processing behavior ('脱敏文件') and automatic creation of a configuration file, but the manifest declares no explicit tool scope such as permissions or allowed-tools. That creates an authorization ambiguity where a runtime may grant broader file read/write capability than users expect, increasing the risk of unintended local file access or modification.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The restoration feature requires a mapping JSON that can contain original sensitive values, yet the documentation does not warn users that supplying or storing this mapping reintroduces highly sensitive data. If logged, shared, or persisted insecurely, the mapping can completely defeat desensitization by enabling reversal of masked data.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
88% confidence
Finding

The code persists configuration under the user's home directory and later reads local files, which exceeds a narrow 'text desensitization' expectation. This increases the attack surface and privacy risk because a user may supply sensitive content expecting in-memory masking, while the skill creates durable artifacts and depends on filesystem state.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

The skill is presented as a desensitization tool, but it also includes a full restore capability that can reconstruct original sensitive data from a provided mapping. In a privacy-focused skill, reversible restoration materially changes the security model: if mappings are exposed, logged, or reused, masking becomes only superficial and sensitive data can be recovered.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

The file mode writes output and a companion mapping file without a strong explicit warning or overwrite confirmation. In a security-sensitive tool, silent creation of output artifacts can leak sensitive data locations, overwrite user files, or leave recoverable restoration material on disk unexpectedly.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
87% confidence
Finding

This is a manifest file, so vague-trigger review applies. The description only says "对文件进行脱敏处理" (desensitize a file), which is a broad capability statement without any explicit trigger phrases, scope limits, or exclusion conditions, making it unclear when the skill should activate versus when other generic file-handling skills should.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

The description and argument descriptions require Chinese comprehension, but the manifest does not state that the skill is limited to Chinese-speaking users or offer any language choice. This can violate a language/locale policy when skills are expected to be accessible without forcing a specific language by default.

Content

No source excerpt is available for this finding.

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
89% confidence
Finding

The file desensitization instructions tell users to run the tool on a local path but do not warn that it will read local files and auto-generate a configuration file. This weakens informed consent and may lead users to expose sensitive local content or permit unexpected filesystem writes during normal use.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
80% confidence
Finding

All natural-language fields in the manifest are written only in Chinese, with no indication that the skill supports user language preference or provides an opt-in choice. This can violate language/locale policy when users are not given a choice or when the locale restriction is not documented as intentional and justified.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
90% confidence
Finding

The natural-language description is written only in Chinese ("根据映射表还原脱敏数据") with no indication that the user can choose another language or locale. Under the policy, forcing a specific language without user opt-in is a natural-language policy concern.

Content

No source excerpt is available for this finding.

Static analysis

No suspicious patterns detected.