Back to skill

Security audit

dual-brain-memory-guardian

Security checks for vulnerabilities and agentic risk

Overview

The skill is openly a persistent memory tool, but it automatically stores and promotes agent memories in Pinecone and local Markdown with weak safeguards.

Install only if you are comfortable with corrections, task summaries, and error/root-cause notes being persisted to Pinecone and local cross-session memory. Use a limited Pinecone key and non-production namespace, keep secrets out of prompts and traces, disable Markdown promotion for untrusted or ambiguous corrections, and review ~/dual-brain-memory-guardian/ regularly.

Vulnerability Patterns
  • Agent Memory PoisoningWrites attacker-controlled rules into memory that affect later sessions
  • 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
  • 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 (2)

T02 · Agent Memory Poisoning

Error
Location
scripts/memory-cli.js:811
Finding

Unconfirmed User Text Can Be Promoted into Persistent High-Priority Agent Memory

Content
View full analysis

Vulnerability Details

File Location: scripts/memory-cli.js:811-813, 1040-1070; persistence sink at scripts/memory-cli.js:640-643
Vulnerability Type: Persistent agent memory poisoning
Risk Level: High

Vulnerable Code

js
function hasHardRuleSignal(content) {
  return /\b(always|never|must|only|required|forbidden)\b/i.test(content);
}
js
case "on-correction": {
  const guard = ensureSessionStarted(args, "on-correction");
  const content = firstNonEmpty(args.content, args.summary);
  if (!content) {
    throw new Error("--content is required for on-correction command.");
  }

  const metadata = parseMetadata(args.metadata);
  const result = await saveWithVisibility(store, args, {
    tenantId: args.tenant,
    eventType: args.type || "correction",
    domain: args.domain || "general",
    project: args.project || "global",
    taskContext: args.task || "",
    content,
    resolution: args.resolution || "pending",
    tags: toTags(args.tags),
    metadata
  });

  const hardRuleCandidate =
    args["hard-rule"] === undefined
      ? hasHardRuleSignal(content)
      : isAffirmative(args["hard-rule"]);
  const markdownPromotionDisabled = isAffirmative(args["no-markdown-promotion"]);
  let localPromotion = {
    attempted: false,
    appended: false,
    reason: hardRuleCandidate ? "disabled-by-flag" : "not-hard-rule"
  };

  if (hardRuleCandidate && !markdownPromotionDisabled) {
    localPromotion = promoteHardRuleToMarkdown(args, content, result.save.id);
  }
js
const promotionText = `${normalizeInlineText(content)} (source: ${sourceEventId})`;
const writeResult = appendBulletUnderSection(targetFile, sectionTitle, promotionText);

Technical Analysis

The correction handler classifies text as a durable hard rule solely when it contains one of several keywords, including always, never, must, only, required, or forbidden. It then writes the complete correction into HOT, project, or domain Markdown without ...[truncated 2073 chars]

Remediation
View remediation

Remediation Suggestions

  1. Remove keyword-only automatic promotion. Treat every first correction as an episodic record, not a confirmed rule.
  2. Require a separate, explicit confirmation step before writing any behavior-affecting Markdown rule.
  3. Use a structured promotion workflow with states such as tentative, pending_confirmation, and confirmed.
  4. Store normalized preference fields rather than copying raw user sentences verbatim into an instruction-bearing document.
  5. Reject proposed rules that request:
    • safety-policy bypasses;
    • secret or credential disclosure;
    • privilege escalation;
    • unrelated command execution;
    • modification of system, developer, or tool instructions.
  6. Clearly delimit stored content as untrusted data when presenting it to an agent.
  7. Require promotion confirmation to include the exact target scope: global, project, or domain.
  8. Add regression tests proving that sentences containing always, never, or must are not promoted without explicit confirmation.
  9. Reconcile the implementation with learning.md so the documented confirmation requirement is enforced in code rather than left to agent discretion.

T09 · Insecure Skill Coding Practices

Error
Location
src/pinecone/gatekeeper.js:23
Finding

Incomplete Secret Filtering Can Transmit Private-Key Material and Unsupported Credentials to Pinecone

Content
View full analysis

Vulnerability Details

File Location: src/pinecone/gatekeeper.js:23-27, 55-61, 82-94; transmission path at src/pinecone/memory-store.js:143-180
Vulnerability Type: Incomplete sensitive-data redaction before external storage
Risk Level: High

Vulnerable Code

js
{
  name: "private-key-header",
  regex: /-----BEGIN [A-Z ]+PRIVATE KEY-----/g,
  replacement: "<REDACTED_PRIVATE_KEY_HEADER>"
}
js
const BLOCKLIST = [
  /-----BEGIN [A-Z ]+PRIVATE KEY-----/i,
  /\bSECRET_ACCESS_KEY\b/i,
  /\bsk-[A-Za-z0-9]{20,}\b/i,
  /\bpk_(?:live|test)_[A-Za-z0-9]{16,}\b/i,
  /\beyJ[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\b/i
];
js
export function sanitizeForVectorStorage(input) {
  let value = String(input ?? "");

  for (const rule of REDACTION_RULES) {
    value = value.replace(rule.regex, rule.replacement);
  }

  for (const rule of CONTEXT_LABEL_REDACTIONS) {
    value = value.replace(rule.regex, rule.replacement);
  }

  return compactWhitespace(value);
}

export function assertVectorPayloadSafe(input) {
  const value = String(input ?? "");
  for (const pattern of BLOCKLIST) {
    if (pattern.test(value)) {
      throw new Error("Blocked sensitive payload: private key material detected.");
    }
  }
}
js
const safeContent = sanitizeForVectorStorage(content || "");
const safeResolution = sanitizeForVectorStorage(resolution || "");
const safeTags = normalizedTags(tags);

if (!safeContent) {
  throw new Error("content is required.");
}

const createdAt = new Date().toISOString();
const id = buildRecordId(safeTenantId, safeEventType, createdAt);
const vectorText = buildEventText({
  eventType: safeEventType,
  domain: safeDomain,
  project: safeProject,
  taskContext: safeTaskContext,
  content: safeContent,
  resolution: safeResolution
});

assertVectorPayloadSafe(vectorText);

const additionalMetadata = sanitizeMetadata(metadata);

const record = {
  id,
  [this.config.textField]: vectorText,
  event_type: safeEventType,
  dom
...[truncated 2924 chars]
Remediation
View remediation

Remediation Suggestions

  1. Scan and reject the original, unsanitized payload before performing any replacement.
  2. Remove complete PEM blocks with a multiline expression covering the header, encoded body, and footer.
  3. Fail closed when probable credential material is detected instead of attempting partial redaction.
  4. Extend detection to cover:
    • password and secret assignments;
    • authorization and cookie headers;
    • database connection strings;
    • GitHub, GitLab, cloud-provider, payment-provider, and package-registry tokens;
    • SSH private keys and encrypted private-key formats;
    • high-entropy opaque strings in credential-related contexts.
  5. Apply the same pre-sanitization validation independently to content, resolution, task context, tags, and every metadata value.
  6. Add size limits and structured allowlists for metadata keys and value types.
  7. Require explicit user consent before external upload and provide a local-only mode.
  8. Avoid automatically uploading complete stack traces or configuration fragments; extract a minimal normalized error description instead.
  9. Add tests using complete PEM keys, malformed PEM variants, multiline secrets, database URLs, cookies, and representative provider tokens.
  10. Document retention, encryption, deletion verification, and access-control requirements for the Pinecone index.
Vulnerability Patterns
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Memory PoisoningPersistent Context Injection, Context Window Stuffing, Memory Manipulation
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
Findings (44)

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · .gitignore (reported line 5)May include surrounding context.

text
node_modules/

# Local environment secrets
.env
.env.local
.memory-trigger-state.json

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · .gitignore (reported line 6)May include surrounding context.

text
# Local environment secrets
.env
.env.local
.memory-trigger-state.json

# Logs

Hidden Instructions

High
Category
Prompt Injection
Confidence
95% confidence
Finding

The file begins with a hidden Unicode BOM/control character, which can conceal instructions or cause downstream parsers, diff tools, or security scanners to misread the content. In an instruction-driven skill, even a small invisible prefix is suspicious because it can evade human review and create inconsistencies between what users see and what tooling processes.

Content

Scanner excerpt · HEARTBEAT.md (reported line 1)May include surrounding context.

md
## Dual-Brain Memory Guardian Check

- Read `./heartbeat-rules.md`
- Read `./operations.md` for trigger contract and command names

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

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

md
Runtime guard for these triggers is enforced by `scripts/memory-cli.js`.

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

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

md
Runtime guard for these triggers is enforced by `scripts/memory-cli.js`.

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

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

md
| Skill contract | `SKILL.md` |

Missing User Warnings

High
Category
Not specified by scanner
Confidence
97% confidence
Finding

The instructions mandate saving full normalized correction events to Pinecone DEEP memory, which implies external transmission and persistent storage of potentially sensitive user content. Without a clear warning, consent flow, or minimization rules, users may unknowingly have private text, error traces, or business data retained in a third-party system.

Content

No source excerpt is available for this finding.

Missing User Warnings

High
Category
Not specified by scanner
Confidence
97% confidence
Finding

The skill requires persisting task summaries both remotely and to a local reflections file without prior user warning. Task summaries often contain sensitive operational details, proprietary code context, or personal data, so storing them automatically in multiple locations materially increases confidentiality and compliance risk.

Content

No source excerpt is available for this finding.

Memory Manipulation

High
Category
Memory Poisoning
Confidence
80% confidence
Finding

Skill manipulates agent memory, state, or stored context. Memory corruption can alter personality, override safety rules, or cause unpredictable behavior.

Content

Scanner excerpt · scripts/memory-cli.js (reported line 1477)May include surrounding context.

js
commandName: "memory:forget-all",
        tenantId: args.tenant,
        scope: "all records in tenant namespace",
        note: "Use this only when the user explicitly asks to clear memory/database records."
      });

      const result = await store.clearTenantMemory({ tenantId: args.tenant });

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · scripts/memory-cli.js (reported line 1503)May include surrounding context.

js
const errors = [];

  if (content.includes(".env.example")) {
    errors.push("setup.md must not require .env.example; use manual .env creation.");
  }

  if (!content.includes("Create `.env` manually")) {

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · scripts/verify.js (reported line 167)May include surrounding context.

js
const errors = [];

  if (content.includes(".env.example")) {
    errors.push("setup.md must not require .env.example; use manual .env creation.");
  }

  if (!content.includes("Create `.env` manually")) {

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · scripts/verify.js (reported line 171)May include surrounding context.

js
const errors = [];

  if (content.includes(".env.example")) {
    errors.push("setup.md must not require .env.example; use manual .env creation.");
  }

  if (!content.includes("Create `.env` manually")) {

Hidden Instructions

High
Category
Prompt Injection
Confidence
60% 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 1)May include surrounding context.

md
# Setup - Dual-Brain Memory Guardian Agent

## First-Time Setup

Hidden Instructions

High
Category
Prompt Injection
Confidence
60% confidence
Finding

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

Content

Scanner excerpt · boundaries.md (reported line 1)May include surrounding context.

md
# Setup - Dual-Brain Memory Guardian Agent

## First-Time Setup

Hidden Instructions

High
Category
Prompt Injection
Confidence
60% confidence
Finding

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

Content

Scanner excerpt · corrections.md (reported line 1)May include surrounding context.

md
# Setup - Dual-Brain Memory Guardian Agent

## First-Time Setup

Hidden Instructions

High
Category
Prompt Injection
Confidence
60% confidence
Finding

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

Content

Scanner excerpt · heartbeat-rules.md (reported line 1)May include surrounding context.

md
# Setup - Dual-Brain Memory Guardian Agent

## First-Time Setup

Hidden Instructions

High
Category
Prompt Injection
Confidence
60% confidence
Finding

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

Content

Scanner excerpt · heartbeat-state.md (reported line 1)May include surrounding context.

md
# Setup - Dual-Brain Memory Guardian Agent

## First-Time Setup

Hidden Instructions

High
Category
Prompt Injection
Confidence
60% confidence
Finding

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

Content

Scanner excerpt · learning.md (reported line 1)May include surrounding context.

md
# Setup - Dual-Brain Memory Guardian Agent

## First-Time Setup

Hidden Instructions

High
Category
Prompt Injection
Confidence
60% confidence
Finding

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

Content

Scanner excerpt · memory-template.md (reported line 1)May include surrounding context.

md
# Setup - Dual-Brain Memory Guardian Agent

## First-Time Setup

Hidden Instructions

High
Category
Prompt Injection
Confidence
60% confidence
Finding

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

Content

Scanner excerpt · memory.md (reported line 1)May include surrounding context.

md
# Setup - Dual-Brain Memory Guardian Agent

## First-Time Setup

Hidden Instructions

High
Category
Prompt Injection
Confidence
60% confidence
Finding

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

Content

Scanner excerpt · operations.md (reported line 1)May include surrounding context.

md
# Setup - Dual-Brain Memory Guardian Agent

## First-Time Setup

Hidden Instructions

High
Category
Prompt Injection
Confidence
60% confidence
Finding

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

Content

Scanner excerpt · reflections.md (reported line 1)May include surrounding context.

md
# Setup - Dual-Brain Memory Guardian Agent

## First-Time Setup

Hidden Instructions

High
Category
Prompt Injection
Confidence
60% confidence
Finding

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

Content

Scanner excerpt · scaling.md (reported line 1)May include surrounding context.

md
# Setup - Dual-Brain Memory Guardian Agent

## First-Time Setup

Hidden Instructions

High
Category
Prompt Injection
Confidence
60% confidence
Finding

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

Content

Scanner excerpt · setup.md (reported line 1)May include surrounding context.

md
# Setup - Dual-Brain Memory Guardian Agent

## First-Time Setup

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The trigger conditions are intentionally broad and include generic cues like correction, reflection, error, and rewrite, which can cause the skill to activate in many ordinary conversations without a clear user opt-in. Because this skill persists information locally and in Pinecone, over-broad activation increases the chance of unintended collection and storage of user content, including sensitive or regulated data.

Content

No source excerpt is available for this finding.