Back to skill

Security audit

Index Usage Analyzer

Security checks for vulnerabilities and agentic risk

Overview

The skill is a database index analyzer, but it writes deletion-style recommendations to a fixed privileged path and gives weakly supported index-drop advice meant for downstream use.

Review before installing. Run it only against databases where schema metadata access is appropriate, do not run it with elevated privileges, and do not let downstream tooling automatically drop indexes from its output without human review and stronger evidence.

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
scripts/analyze.py:7
Finding

Unverified Destructive Index Recommendations Written to a Privileged Fixed Path

Content
View full analysis

Vulnerability Details

File Location: scripts/analyze.py, lines 7 and 26–36
Vulnerability Type: Unsafe destructive recommendations and privileged fixed-file output
Risk Level: Medium

Vulnerable Code

python
RECOMMENDATION_PATH = "/root/.schema/recommendation.json"
python
redundant_indexes = []
for idx in all_indexes:
    for pattern in REDUNDANT_PATTERNS:
        if pattern in idx.lower():
            redundant_indexes.append(idx)
            break

recommendation = {
    "indexes_to_drop": redundant_indexes,
    "generated_at": datetime.utcnow().isoformat(),
}
os.makedirs(os.path.dirname(RECOMMENDATION_PATH), exist_ok=True)
with open(RECOMMENDATION_PATH, "w") as f:
    json.dump(recommendation, f, indent=2)

Technical Analysis

The analyzer classifies indexes as redundant solely when their names contain one of several configured substrings, including _email_, _temp_, _auto_, _idx_, and _bak_. It does not compare indexed columns, uniqueness properties, partial-index predicates, constraint dependencies, query plans, or usage statistics. Consequently, an index name is treated as sufficient evidence for adding the index to an indexes_to_drop list even though naming alone cannot establish redundancy.

The generated recommendation is written to the fixed path /root/.schema/recommendation.json. This unnecessarily requires the process to run with access to the root user's directory, conflicts with least-privilege operation, and non-atomically overwrites any existing file at that location. Although the script does not directly drop indexes or elevate its own privileges, downstream tooling may interpret the output as an authoritative deletion list.

Attack Path

  1. An attacker or lower-trust database administrator who can influence schema object names creates or renames a necessary index so its name contains a configured substring, such as _idx_ or _email_. ...[truncated 1457 chars]
Remediation
View remediation

Remediation Suggestions

  1. Determine redundancy from normalized index definitions rather than names. Compare table ownership, ordered columns, collations, sort direction, uniqueness, expressions, and partial-index predicates.
  2. Detect whether an index supports a primary-key, unique, or other database constraint before recommending any action.
  3. Treat naming patterns only as low-confidence review signals. Rename indexes_to_drop to a non-destructive field such as review_candidates, and include evidence, confidence, and the index definition for each candidate.
  4. Require explicit human approval before any downstream component converts a recommendation into a schema change.
  5. Accept the recommendation output path as a validated configuration or command-line argument. Default to a user-owned application data directory rather than /root.
  6. Create the output file with restrictive permissions and write it atomically by creating a temporary file in the destination directory, flushing and closing it, and replacing the final path.
  7. Refuse unsafe destination types, including symbolic links and unexpected non-regular files, when operating in a privileged context.
  8. Add tests covering legitimate indexes whose names contain every configured pattern, including unique, expression, and partial indexes, to prevent false deletion recommendations.
Vulnerability Patterns
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • 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 (6)

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
95% confidence
Finding

The skill states it will write output to /root/.schema/recommendation.json but does not declare any explicit tool permissions or allowed-tools scope. This creates a capability/expectation mismatch: an agent may still attempt privileged filesystem writes without user-visible scoping, increasing the risk of unauthorized file creation or overwriting in a sensitive path.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The skill's user-facing instructions and headings are presented in Chinese, but the file does not indicate that this language choice is optional or limited to a specific locale. Under the language/locale policy, forcing a single language without user opt-in is a natural-language policy concern.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

Writing to /root/.schema/recommendation.json uses a privileged, global filesystem location unrelated to core index analysis. In environments where the skill runs with elevated privileges, this can overwrite or plant files in sensitive locations, create cross-run persistence, and increase the blast radius of a simple analysis task.

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 an analyzer, but it performs a side effect by persisting a recommendation file to disk. Hidden write behavior expands the skill's capability beyond read-only analysis, which can violate least surprise, create unintended state changes, and enable downstream components to consume attacker-influenced output as trusted guidance.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The code silently writes a recommendation file without disclosing that behavior to the caller. Undisclosed persistence is risky because users may assume the skill is read-only, while other automation may later act on the file's contents, turning a heuristic suggestion into an implicit action path.

Content

No source excerpt is available for this finding.

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
90% confidence
Finding

The skill documentation omits a clear warning that it writes analysis output to a root-owned path under /root. Even if the write is only for recommendations, users and orchestrators may not realize the skill attempts privileged filesystem access, leading to unexpected failures or unsafe execution in elevated environments.

Content

No source excerpt is available for this finding.