Back to skill

Security audit

Clarity Gate

Security checks for vulnerabilities and agentic risk

Overview

This skill is a disclosed document-review workflow with local helper scripts, though its hash verifier has a validation weakness users should not treat as strong authenticity protection.

Install only if you want a document clarity and RAG pre-ingestion review workflow. Treat its outputs as review assistance, not proof of truth, and do not rely on document_hash.py as a cryptographic signature or strict structural validator until the out-of-frontmatter hash acceptance issue is fixed.

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/document_hash.py:165
Finding

Document Hash Verification Accepts an Out-of-Scope Hash Value

Content
View full analysis

Vulnerability Details

File Location: scripts/document_hash.py:165-168
Vulnerability Type: Improper validation scope
Risk Level: Medium

Vulnerable Code

python
# Extract stored hash
match = re.search(r'^\s*document-sha256:\s*["\']?([a-f0-9]{64})["\']?', content, re.MULTILINE)
if not match:
    print("FAIL: No document-sha256 found")
    return False

Technical Analysis

The verify() function searches the entire document for a line matching document-sha256. It does not require the field to appear inside the document's YAML frontmatter.

This conflicts with the declared document format and the behavior of compute_hash(), which treats document-sha256 as a YAML-frontmatter field. Content after <!-- CLARITY_GATE_END --> is outside the hash window, but verify() still searches that content for the stored digest.

An attacker can therefore place a matching digest after the end marker. The verifier will compare this out-of-scope value with the computed digest and report PASS, even though the required hash field is absent from the YAML frontmatter. The regular expression also accepts the first matching line without detecting duplicate or conflicting hash fields.

Attack Path

  1. Prepare a CGD document that has no valid document-sha256 field in its YAML frontmatter.
  2. Run the hash computation mode to obtain the document's digest:
    bash
    python scripts/document_hash.py crafted.cgd.md
    
  3. Append the resulting digest outside the hash window, after the end marker:
    markdown
    <!-- CLARITY_GATE_END -->
    Clarity Gate: CLEAR | REVIEWED
    document-sha256: <computed-64-character-digest>
    
  4. Run verification:
    bash
    python scripts/document_hash.py --verify crafted.cgd.md
    
  5. verify() finds the appended digest anywhere in the file, while compute_hash() excludes the post-marker content.
  6. The values match, and the script incorrectly reports successful verification.

...[truncated 620 chars]

Remediation
View remediation

Remediation Suggestions

  1. Extract and parse only the YAML frontmatter bounded by the document's initial --- delimiters.
  2. Read document-sha256 exclusively from that parsed frontmatter rather than searching the complete file with a multiline regular expression.
  3. Require exactly one document-sha256 field whose value is a scalar containing exactly 64 lowercase hexadecimal characters.
  4. Reject missing, duplicate, multiline, conflicting, or out-of-frontmatter hash declarations.
  5. Ensure the opening frontmatter delimiter occurs at the valid document boundary after permitted BOM and newline normalization.
  6. Avoid unsafe general-purpose YAML object construction; use a safe loader or a narrow parser for the required metadata.
  7. Add negative regression tests covering:
    • A hash only in the document body
    • A hash only after <!-- CLARITY_GATE_END -->
    • Missing frontmatter
    • Duplicate hash fields
    • Conflicting hash fields
    • Quoted and multiline values
    • Hash-like text inside fenced code blocks
  8. Fail closed when structural parsing is ambiguous or invalid.
Vulnerability Patterns
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • 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
Findings (8)

Tp4

High
Category
MCP Tool Poisoning
Confidence
98% confidence
Finding

The declared description says this skill performs pre-ingestion epistemic verification for RAG documents, including clarity gating and SOT validation. The supplied code does none of that. It simply normalizes a claim's text and location, computes a SHA-256-based short identifier, and prints it. This is a materially different primary purpose: claim ID generation for tracking, not document qualification or verification. There are no checks for hallucination risk, clarity, equivocation, source-of-truth validation, or any document ingestion logic. Therefore the description does not accurately represent the code's behavior.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
95% confidence
Finding

The declared description presents this skill as an epistemic quality gate for RAG documents—reviewing clarity, hallucination risk, equivocation, and producing/validating CGD and SOT artifacts. The supplied code does something much narrower and materially different: it parses a CGD-like file structure, canonicalizes text, computes a SHA-256 hash, and verifies that a stored document-sha256 matches the computed value. While this may support one small aspect of CGD document integrity, it does not perform semantic or epistemic evaluation, does not assess LLM safety/readability, and contains no SOT-specific validation. Therefore the actual behavior is a subset focused on integrity hashing, not the declared primary purpose.

Content

No source excerpt is available for this finding.

Hidden Instructions

High
Category
Prompt Injection
Confidence
70% confidence
Finding

Hidden instructions were detected in comments or invisible text. These could contain malicious directives. Manual review is recommended.

Content

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

text

**Algorithm (per §2.2-2.4):**
1. Extract content between opening `---\n` and `<!-- CLARITY_GATE_END -->`
2. Remove `document-sha256` line from YAML frontmatter ONLY (with multiline continuation support)
3. Canonicalize:
   - Strip trailing whitespace per line

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
70% confidence
Finding

Without declared permissions the skill's intent is opaque and cannot be validated.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
90% confidence
Finding

Overly broad trigger phrases can cause the skill to activate during generic user review requests, creating prompt-scope hijacking risk and unintended workflow interception. In an agent ecosystem, ambiguous routing can make the model apply this skill to unrelated content, potentially suppressing better-matched safety or review behaviors.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
87% confidence
Finding

An ambiguous trigger increases unintended invocation and can be exploited by adversarial content to steer the agent into this skill's decision framework. Because this skill influences whether documents are considered safe for RAG ingestion, accidental activation could affect trust and downstream handling of unverified material.

Content

No source excerpt is available for this finding.

Autonomous Decision Making

Medium
Category
Excessive Agency
Confidence
75% confidence
Finding

Skill enables autonomous high-impact decisions without human-in-the-loop verification. Critical operations (destructive commands, financial transactions, data deletion) should require explicit user confirmation.

Content

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

md
| **TEMPORAL** | Date/time inconsistency detected | Verify and update |
| **VERIFIABLE** | Specific claim that could be fact-checked | Route to HITL or external search |
| **ROUND A** | Derived from witnessed source | Quick confirmation |
| **ROUND B** | Requires true verification | Cannot pass without confirmation |
| **PASS** | Clearly marked, no ambiguity, verified | No action needed |

---

Vague Triggers

Low
Category
Not specified by scanner
Confidence
83% confidence
Finding

Vague triggers that overlap with generic editing or review tasks can cause workflow collisions. The security impact is limited, but in multi-skill environments this can still produce misrouting, confusion, and improper application of ingestion-related judgments.

Content

No source excerpt is available for this finding.

Static analysis

No suspicious patterns detected.