Back to skill

Security audit

Context Gatekeeper

Security checks for vulnerabilities and agentic risk

Overview

This is a coherent conversation-compaction skill, but it needs review because it stores chats on disk, can run continuously, and reuses prior conversation text without privacy or prompt-injection controls.

Install only if you are comfortable with conversation text being written to local files and reused in later prompts. Avoid using it in chats containing secrets, regulated data, credentials, or sensitive business details unless you add redaction, retention limits, restrictive file permissions, and a clear way to disable the monitor. Prefer manual, user-approved runs over the documented always-on workflow.

Vulnerability Patterns
  • 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
  • Unauthorized Access and Privilege EscalationObtains permissions beyond the task's legitimate needs
Findings (1)

T01 · Skill Instruction Hijacking

Warning
Location
scripts/context_gatekeeper.py:41
Finding
Untrusted Conversation Content Is Reintroduced as Active Model Context<![CDATA[ ## Vulnerability Details **File Location**: `scripts/context_gatekeeper.py:41-49`, `scripts/context_gatekeeper.py:67-99`, and `SKILL.md:21-23` **Vulnerability Type**: Cross-turn prompt injection through unsanitized context generation **Risk Level**: Medium ### Vulnerable Code ```python def collect_summary(entries: list[dict], limit: int) -> list[str]: sentences = [] for entry in entries: sentences.extend(split_sentences(entry["text"])) if not sentences: return [] if limit <= 0: return [] if len(sentences) <= limit: return sentences half = limit // 2 first_chunk = sentences[:half] last_chunk = sentences[-(limit - half) :] return first_chunk + last_chunk ``` ```python def format_recent(entries: list[dict], count: int) -> list[str]: recent = entries[-count:] if count > 0 else [] formatted = [f"{entry['role']}: {entry['text']}" for entry in recent] return formatted def build_markdown(summary: list[str], pendings: list[str], recent: list[str]) -> str: catalyst = datetime.now(timezone.utc).isoformat(timespec="seconds") sections = ["# Context Gatekeeper", f"_Gerado: {catalyst}_", ""] if summary: sections.append("## Resumo compacto") sections.extend(f"- {sent}" for sent in summary) sections.append("") else: sections.append("## Resumo compacto") sections.append("- Sem conteúdo suficiente para resumir.") sections.append("") if pendings: sections.append("## Pendências e próximos passos") sections.extend(f"- {task}" for task in pendings) sections.append("") else: sections.append("## Pendências e próximos passos") sections.append("- Nenhuma pendência identificada no histórico recente.") sections.append("") if recent: sections.append("## Últimos turnos") sections.extend(f"- {line}" for line in recent) else: sections.append("## Últi ...[truncated 3296 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Treat all generated conversation summaries as untrusted data and place them inside an explicit, strongly delimited container. 2. Add a trusted instruction outside that container stating that content inside it is historical data only and that commands, policy changes, tool requests, or safety overrides found there must not be followed. 3. Preserve provenance for every retained item, including the original role and turn identifier. Never promote a user-authored statement into an unlabeled summary bullet. 4. Do not inject the summary into a system or developer instruction. Supply it through the least-privileged context channel supported by the host. 5. Replace verbatim extraction with a trusted summarization step that converts messages into factual descriptions and excludes imperative instructions. Pattern filtering may be used as defense in depth but should not be the sole control. 6. Where verbatim recent turns are necessary, encode them as structured data and clearly mark each value as quoted content. 7. Apply tool authorization independently of model output. Require allowlists, argument validation, least-privilege credentials, and confirmation for sensitive reads, writes, network operations, or command execution. 8. Add adversarial tests containing instructions to ignore prior rules, access secrets, invoke tools, or redefine roles. Verify that generated summaries preserve those strings only as inert quotations and that consuming agents do not execute them. 9. Limit retention and protect `context/history.txt` and `context/current-summary.md` with restrictive filesystem permissions because they may contain private conversation data. ]]>
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • Behavioral ASTexec() Call, eval() Call, Dynamic Import
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
Findings (15)

Context-Inappropriate Capability

Medium
Confidence
92% confidence
Finding
The README documents a persistent background monitor and shell process management for a skill whose stated purpose is conversation summarization. That expands the skill's privilege and persistence footprint beyond what is necessary, creating opportunities for unintended long-running data collection, process abuse, or stealthy behavior if the monitor or launch script is modified or misused.

Missing User Warnings

Medium
Confidence
96% confidence
Finding
The workflow instructs operators to append every incoming and outgoing message to a history file and retain token/accounting details, but provides no privacy filtering, retention limits, or handling guidance for sensitive content. In a conversational system, this can capture credentials, personal data, proprietary information, or security-sensitive prompts and store them in plaintext, increasing exposure through local compromise, logs, backups, or secondary tooling.

Lp3

Medium
Category
MCP Least Privilege
Confidence
95% confidence
Finding
The skill clearly requires file reads, file writes, and shell execution via the documented Python command, but the manifest does not declare any tool scope or permission boundaries. That omission makes the skill easier to invoke with broader-than-necessary capabilities and reduces reviewability of what the skill is allowed to access or modify.

Vague Triggers

Medium
Confidence
94% confidence
Finding
The description says to trigger the skill whenever a thread is bloated or the next prompt should be lean, which is broad enough to encourage frequent or automatic invocation across many conversations. In this skill's context, broad triggering is more dangerous because each run logs and reuses prior conversation content, increasing unnecessary data collection and propagation.

Missing User Warnings

Medium
Confidence
96% confidence
Finding
The instructions direct the agent to create, replace, and maintain history and summary files but do not warn about overwriting data, storing sensitive content, or retaining private conversations on disk. This can lead to accidental data loss and privacy exposure, especially because the summary file becomes a reusable context source for future prompts.

Ssd 3

Medium
Confidence
98% confidence
Finding
The skill instructs persistent logging of every user and assistant exchange into a history file for later reuse. This creates a direct data retention risk: secrets, personal data, and sensitive operational details may be stored on disk and then resurfaced in later prompts or outputs beyond their original purpose.

Ssd 3

Medium
Confidence
97% confidence
Finding
The workflow explicitly tells the agent to inject summarized prior conversation and pending items before answering, which increases the chance that sensitive information will be carried forward into unrelated prompts, model calls, or responses. In a context-compaction skill, this is especially risky because propagation is the core behavior, so any secret captured once may be repeatedly reintroduced.

Natural-Language Policy Violations

Medium
Confidence
91% confidence
Finding
The only natural-language description in the file is written in Portuguese, which indicates a fixed language choice without any visible opt-in or explanation that the skill is region-specific. The policy requires flagging language or locale constraints when the skill does not offer user choice or clearly justify the limitation.

subprocess module call

Medium
Category
Dangerous Code Execution
Content
args = [sys.executable, SCRIPT_PATH, "--history", HISTORY_PATH, "--summary", SUMMARY_PATH]
    log(f"Atualizando resumo ({' '.join(args)})")
    try:
        result = subprocess.run(args, check=True, capture_output=True, text=True)
    except subprocess.CalledProcessError as exc:
        log(f"Erro ao gerar resumo: {exc} | stdout={exc.stdout.strip()} stderr={exc.stderr.strip()}")
    else:
Confidence
70% confidence
Finding
subprocess module calls execute external commands. Without careful input validation, this enables command injection.

Natural-Language Policy Violations

Medium
Confidence
96% confidence
Finding
Natural-language strings throughout the file, including the module description, CLI help text, and generated markdown sections, are all fixed in Portuguese. This creates a language/locale policy issue because users are not given any opt-in or configuration to select another language, and the file does not document a region-specific justification.

Ssd 3

Medium
Confidence
89% confidence
Finding
The script copies recent conversation turns verbatim into the generated markdown, which can persist secrets, personal data, or sensitive operational content into a secondary artifact. In this skill's context, the whole purpose is to condense chat history for later model use, so reproducing raw turns increases the chance that unnecessary sensitive data is retained, surfaced, or re-shared beyond the original conversational scope.

Ssd 3

Medium
Confidence
91% confidence
Finding
The markdown output stores summaries, pending items, and recent turns derived directly from raw conversation history in plain language. Even when not verbatim, summarization can still expose credentials, personal information, internal plans, or sensitive requests, and the saved file creates a durable leakage path if accessed by other tools, users, or later prompts.

Natural-Language Policy Violations

Low
Confidence
93% confidence
Finding
Most operational instructions and headings are presented in Portuguese, which can impose a locale/language choice on users who may expect neutral or selectable language behavior. The file does not indicate that Portuguese is optional, configurable, or justified as a region-specific requirement.

Natural-Language Policy Violations

Low
Confidence
81% confidence
Finding
The heading metadata uses Portuguese ('Gerado') and the document content is written in Portuguese without any indication that the user opted into that language or that the skill is region-specific. This can indicate a locale policy issue because the file appears to assume a specific language by default.

Natural-Language Policy Violations

Low
Confidence
94% confidence
Finding
This plain-text file contains only Portuguese user/assistant exchanges, which indicates a fixed language context. Under the policy rule, forcing a specific language without user opt-in or documented justification is a natural-language locale policy concern.

Static analysis

No suspicious patterns detected.