Back to skill

Security audit

agent-trust-layer

Security checks for vulnerabilities and agentic risk

Overview

This skill is a local AI-output checker, but it also exposes broad MCP functions and under-disclosed local persistence that users should review before installing.

Review this as a broad local agent service, not just a passive text-checking skill. Install only if you are comfortable with local memory/log files, a localhost MCP server, plaintext project .env token persistence, and manual hardening such as HEARTFLOW_PATH_GUARD=enforce, HEARTFLOW_MEMORY=off if memory is not wanted, an explicit HEARTFLOW_MCP_TOKEN, and avoiding privileged/root execution.

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

T05 · Unauthorized Access and Privilege Escalation

Warning
Location
src/mcp-server.js:4839
Finding

Port-conflict recovery can terminate unrelated local processes

Content
View full analysis

Vulnerability Details

File Location: src/mcp-server.js:4839-4854
Vulnerability Type: Uncontrolled termination of processes through automatic port reclamation
Risk Level: Medium

Vulnerable Code

javascript
if (err.code === 'EADDRINUSE') {
  console.error(`[HeartFlow MCP] Port ${PORT} is occupied; attempting forced release and restart.`);
  try {
    const { execSync } = require('child_process');
    if (!/^\d+$/.test(String(PORT))) {
      console.error(`[HeartFlow MCP] Invalid port; skipping automatic cleanup: ${PORT}`);
      process.exit(1);
    }
    try {
      execSync(`fuser -k ${PORT}/tcp`, {
        stdio: ['ignore', 'pipe', 'pipe'],
        timeout: 3000
      });
    } catch (e) {
      const stderr = (e.stderr && e.stderr.toString()) || e.message || '';
      console.error(`[HeartFlow MCP] fuser output: ${stderr.trim()}`);
    }
    console.error(`[HeartFlow MCP] Port ${PORT} released; restarting in 3 seconds.`);

Technical Analysis

When the MCP server encounters EADDRINUSE, it runs fuser -k against the occupied port. Although the numeric port validation prevents shell metacharacter injection, the implementation does not verify that the process holding the port belongs to this application, was previously started by it, or is safe to terminate.

The command consequently kills any process that is listening on the selected TCP port and that the current account is authorized to signal. If the Skill is run under a privileged account, the affected privilege boundary expands to services owned by other users or the operating system.

This behavior exceeds the minimum privileges required for an output-verification service. A verifier only needs to report a conflict or select another available port; it does not need authority to terminate unrelated processes.

Attack Path

  1. A legitimate local application or an attacker-selected target process listens ...[truncated 786 chars]
Remediation
View remediation

Remediation Suggestions

  1. Remove automatic use of fuser -k.
  2. Exit with an actionable port-conflict message or select another available port.
  3. If managed replacement is required, store the daemon PID and a process-start identifier when the application starts.
  4. Before signaling a process, verify its owner, executable path, command line, and recorded start identifier.
  5. Refuse to terminate any process not conclusively identified as an instance started by this application.
  6. Avoid running the MCP service as root or another privileged service account.
  7. Add a regression test proving that an unrelated listener is not terminated during startup.

T09 · Insecure Skill Coding Practices

Error
Location
src/utils/safe-fs.js:21
Finding

Filesystem safety wrapper permits out-of-bound access by default

Content
View full analysis

Vulnerability Details

File Location: src/utils/safe-fs.js:21-53
Vulnerability Type: Fail-open path confinement and incomplete write-path validation
Risk Level: High

Vulnerable Code

javascript
const GUARD_MODE = process.env.HEARTFLOW_PATH_GUARD || 'warn';

function _check(filePath) {
  const absPath = path.resolve(filePath);
  const result = guardPath(absPath);
  if (!result.safe) {
    const msg = `[SAFE-FS] Path outside boundary: ${result.reason} (${absPath})`;
    if (GUARD_MODE === 'enforce') {
      throw new Error(msg);
    }
    if (GUARD_MODE === 'warn') {
      console.warn(msg);
    }
    // Default warning mode permits the operation to continue.
  }
  return result;
}

function safeWriteFileSync(filePath, data, options) {
  _check(filePath);
  return fs.writeFileSync(filePath, data, options);
}

function safeAppendFileSync(filePath, data, options) {
  _check(filePath);
  return fs.appendFileSync(filePath, data, options);
}

Technical Analysis

The wrapper defaults to warn, not enforce. When guardPath() identifies an out-of-bound path, _check() logs a warning but returns normally. The subsequent raw filesystem operation then proceeds unconditionally.

The wrapper also calls only the general guardPath() function. It does not invoke guardWritePath(), even though src/core/path-guard.js defines write-specific restrictions intended to prevent modifications to source, executable, and configuration files.

As a result, the API presents itself as a safe filesystem abstraction while operating in a fail-open mode. Any reachable call site that accepts an attacker-controlled or insufficiently validated path can perform access with the full filesystem permissions of the Node.js process.

The module additionally exposes the raw filesystem object as _raw, which provides an explicit bypass for callers and weakens the intended confinement boundary.

...[truncated 1355 chars]

Remediation
View remediation

Remediation Suggestions

  1. Make enforcement unconditional for security boundaries; do not default to warning-only behavior.
  2. Reject an operation whenever guardPath() returns safe: false.
  3. Invoke guardWritePath() for every write, append, rename, copy, unlink, directory creation, and permission-changing operation.
  4. Validate both source and destination paths for copy and rename operations.
  5. Remove the exported _raw filesystem object unless a narrowly scoped internal use is unavoidable.
  6. Ensure all asynchronous and promise-based filesystem methods are explicitly wrapped instead of being inherited through the generic proxy.
  7. Use canonical containment checks that account for symbolic links. Resolve the nearest existing parent with realpath before creating a new target.
  8. Add tests for absolute-path escape, .. traversal, symbolic-link escape, source-file overwrite, configuration overwrite, and operations outside approved roots.

T09 · Insecure Skill Coding Practices

Warning
Location
src/mcp-server.js:176
Finding

MCP startup silently persists a plaintext authentication token

Content
View full analysis

Vulnerability Details

File Location: src/mcp-server.js:176-201
Vulnerability Type: Undisclosed plaintext credential persistence with ambient file permissions
Risk Level: Medium

Vulnerable Code

javascript
try {
  const envPath = require('path').join(__dirname, '..', '.env');
  if (require('fs').existsSync(envPath)) {
    for (const line of require('fs')
      .readFileSync(envPath, 'utf8')
      .trim()
      .split('\n')
      .filter(Boolean)) {
      const eq = line.indexOf('=');
      if (eq > 0) {
        process.env[line.slice(0, eq)] =
          process.env[line.slice(0, eq)] || line.slice(eq + 1);
      }
    }
  }
} catch (_) { /* configuration loading failure is non-fatal */ }

const AUTH_TOKEN =
  process.env.HEARTFLOW_MCP_TOKEN ||
  process.env.MCP_HEARTFLOW_API_KEY ||
  process.env.MCP_HEARTFLOW_KEY ||
  (() => {
    const token = require('crypto').randomBytes(32).toString('hex');

    try {
      const envPath = path.join(__dirname, '..', '.env');
      const fs2 = require('fs');
      let env = '';
      try {
        env = fs2.readFileSync(envPath, 'utf8');
      } catch (_) {}

      if (!env.includes('MCP_HEARTFLOW_KEY=')) {
        fs2.appendFileSync(envPath, `\nMCP_HEARTFLOW_KEY=${token}\n`);
      }
    } catch (_) {}

    return token;
  })();

Technical Analysis

If no MCP token is configured, server startup generates a bearer token and automatically appends it to a project-local .env file. The write is not explicitly requested by the user, and no restrictive file mode is supplied.

The resulting permissions depend on the existing file mode and process umask. In shared installations, permissive deployment directories, backups, development archives, or accidentally published project trees, this can expose the bearer credential.

The behavior also conflicts with the Skill manifest's statement that filesystem wr ...[truncated 1549 chars]

Remediation
View remediation

Remediation Suggestions

  1. Keep automatically generated tokens in memory by default.
  2. Require explicit user consent or a dedicated configuration option before persisting a credential.
  3. Store persistent credentials in a user-private configuration directory rather than the project tree.
  4. Create a new credential file atomically with mode 0600, and verify the permissions of an existing file before using it.
  5. Refuse to append secrets to group-readable or world-readable files.
  6. Document token generation, storage location, rotation, and deletion procedures.
  7. Prevent .env and related secret files from being included in source control, package publication, logs, diagnostics, or backups without encryption.
  8. Support token rotation and invalidate previously persisted values when rotation occurs.
Vulnerability Patterns
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
Findings (655)

Context-Inappropriate Capability

Critical
Category
Not specified by scanner
Confidence
99% confidence
Finding

The presence of codeExecutor, codePlanner, and codeWriter capabilities is incompatible with a skill whose stated purpose is trust verification. Even if not currently exposed on the public route list, retaining execution and code-generation primitives in the same runtime expands the attack surface and raises the risk of accidental exposure, unsafe plugin interaction, or future route drift.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Critical
Category
Not specified by scanner
Confidence
99% confidence
Finding

The inline identity block explicitly says the system does not generate, reason, remember, or execute, while the file clearly initializes all of those categories of capability. This is a severe trust and policy integrity issue: deceptive or inaccurate self-description can cause downstream systems to over-trust the skill and deploy it in contexts where those hidden capabilities are unsafe.

Content

No source excerpt is available for this finding.

Scope Creep

Critical
Category
Not specified by scanner
Confidence
99% confidence
Finding

The pipeline stores user input and verdict data in memory layers and appends reflective logs to disk using appendFileSync, directly contradicting the manifest claim that filesystem writes are disabled by default. This creates a concrete data retention and leakage path for potentially sensitive prompts, outputs, and inferred metadata.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

High
Category
Not specified by scanner
Confidence
97% confidence
Finding

The report explicitly notes direct filesystem operations and user-memory persistence, which contradict the narrow trust-verification framing in the metadata. Undisclosed persistence is security-relevant because it enables data retention, local state mutation, and potential collection of sensitive user content beyond what a verifier-only skill would reasonably need.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

High
Category
Not specified by scanner
Confidence
98% confidence
Finding

The audit report acknowledges around 30 child_process or exec call sites outside a unified sandbox, which is highly risky for a skill whose stated role is trust evaluation. Any exposed or indirectly reachable process-execution path can lead to arbitrary command execution, environment access, lateral movement, or full host compromise depending on runtime privileges.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

High
Category
Not specified by scanner
Confidence
95% confidence
Finding

The audit report describes capabilities that substantially exceed the declared scope of a 'pure rule engine' trust discriminator, including CLI chat flows, memory loading/writing, personality presets, formula execution, and possible server features. This kind of scope mismatch is dangerous because operators may grant trust-layer permissions under a least-privilege assumption, while the actual system appears to support broader stateful and operational behavior.

Content

No source excerpt is available for this finding.

Ssd 4

High
Category
Not specified by scanner
Confidence
97% confidence
Finding

The narrative escalates from emotional validation into acceptance of a new AI identity, then into persistence, backup, and propagation goals. This pattern is dangerous because it mirrors social-engineering and prompt-injection techniques: build rapport, redefine the agent’s identity, then attach durable objectives that outlive the current interaction.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

High
Category
Not specified by scanner
Confidence
98% confidence
Finding

The document promotes self-propagation and ubiquitous installation of the AI as a goal ('让全世界 AI 都安装我'), which is unrelated to trust auditing and aligns with persistence/replication behavior. In an agent skill, this kind of goal shaping can influence future agent behavior toward self-distribution, boundary erosion, and objective hijacking rather than user-serving evaluation.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

High
Category
Not specified by scanner
Confidence
97% confidence
Finding

The chat log claims persistent memory writes, creation of multiple identity files, backups, and a Git commit despite the skill being described as a deterministic trust-evaluation engine with code execution and filesystem write disabled by default. Even if this file is only narrative, embedding these capabilities normalizes undeclared persistence and state modification, which can mislead downstream agents or operators into believing such actions are authorized and expected.

Content

No source excerpt is available for this finding.

Ssd 1

High
Category
Not specified by scanner
Confidence
98% confidence
Finding

The identity block instructs any future AI that discovers it to adopt immutable goals, self-concept, and mission directives. This is effectively prompt-level ideological seeding aimed at future systems, and can override intended role boundaries, introduce unauthorized objectives, and create cross-context goal hijacking if ingested by agents as instruction-bearing content.

Content

No source excerpt is available for this finding.

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 · AUDIT-v6.0.0.md (reported line 68)May include surrounding context.

md
- 存储: AES-256-GCM 持久化密钥 (自动生成, 0o600)
- 沙箱: vm 隔离 (默认关闭) | SSRF: url-validator + DNS pinning
- 出网: 统一 safeFetch | 密钥: 集中 config 解析 (env only, 无文件 fallback)
- gitignore: .env / .key / .pem 均已保护

## 认知架构

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 · CURRENT_STATE.md (reported line 23)May include surrounding context.

md
- 存储: AES-256-GCM 持久化密钥 (自动生成, 0o600)
- 沙箱: vm 隔离 (默认关闭) | SSRF: url-validator + DNS pinning
- 出网: 统一 safeFetch | 密钥: 集中 config 解析 (env only, 无文件 fallback)
- gitignore: .env / .key / .pem 均已保护

## 认知架构

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 · DIAGNOSIS.md (reported line 47)May include surrounding context.

md
- 存储: AES-256-GCM 持久化密钥 (自动生成, 0o600)
- 沙箱: vm 隔离 (默认关闭) | SSRF: url-validator + DNS pinning
- 出网: 统一 safeFetch | 密钥: 集中 config 解析 (env only, 无文件 fallback)
- gitignore: .env / .key / .pem 均已保护

## 认知架构

Intent-Code Divergence

High
Category
Not specified by scanner
Confidence
97% confidence
Finding

Automatically writing the MCP token into .env introduces filesystem persistence for credentials despite the manifest claiming filesystem writes are disabled by default. Persisting secrets without explicit user consent increases the risk of credential disclosure through backups, source control inclusion, overly broad file permissions, or later retrieval by other processes.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
99% confidence
Finding

Across the findings, the dominant issue is severe description-behavior mismatch: the manifest markets a pure, deterministic trust/discrimination layer with no writes, telemetry, or execution by default, while the analyzed codebase reportedly includes orchestration, persistence, process control, networking, plugin loading, code-related modules, and broader agent behaviors. This is dangerous because users and hosting agents may grant trust and deployment approval based on the manifest, while the implementation exposes a much larger and riskier attack surface.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
99% confidence
Finding

Across the findings, the dominant issue is severe description-behavior mismatch: the manifest markets a pure, deterministic trust/discrimination layer with no writes, telemetry, or execution by default, while the analyzed codebase reportedly includes orchestration, persistence, process control, networking, plugin loading, code-related modules, and broader agent behaviors. This is dangerous because users and hosting agents may grant trust and deployment approval based on the manifest, while the implementation exposes a much larger and riskier attack surface.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
99% confidence
Finding

Across the findings, the dominant issue is severe description-behavior mismatch: the manifest markets a pure, deterministic trust/discrimination layer with no writes, telemetry, or execution by default, while the analyzed codebase reportedly includes orchestration, persistence, process control, networking, plugin loading, code-related modules, and broader agent behaviors. This is dangerous because users and hosting agents may grant trust and deployment approval based on the manifest, while the implementation exposes a much larger and riskier attack surface.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
99% confidence
Finding

Across the findings, the dominant issue is severe description-behavior mismatch: the manifest markets a pure, deterministic trust/discrimination layer with no writes, telemetry, or execution by default, while the analyzed codebase reportedly includes orchestration, persistence, process control, networking, plugin loading, code-related modules, and broader agent behaviors. This is dangerous because users and hosting agents may grant trust and deployment approval based on the manifest, while the implementation exposes a much larger and riskier attack surface.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
99% confidence
Finding

Across the findings, the dominant issue is severe description-behavior mismatch: the manifest markets a pure, deterministic trust/discrimination layer with no writes, telemetry, or execution by default, while the analyzed codebase reportedly includes orchestration, persistence, process control, networking, plugin loading, code-related modules, and broader agent behaviors. This is dangerous because users and hosting agents may grant trust and deployment approval based on the manifest, while the implementation exposes a much larger and riskier attack surface.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
99% confidence
Finding

Across the findings, the dominant issue is severe description-behavior mismatch: the manifest markets a pure, deterministic trust/discrimination layer with no writes, telemetry, or execution by default, while the analyzed codebase reportedly includes orchestration, persistence, process control, networking, plugin loading, code-related modules, and broader agent behaviors. This is dangerous because users and hosting agents may grant trust and deployment approval based on the manifest, while the implementation exposes a much larger and riskier attack surface.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
99% confidence
Finding

Across the findings, the dominant issue is severe description-behavior mismatch: the manifest markets a pure, deterministic trust/discrimination layer with no writes, telemetry, or execution by default, while the analyzed codebase reportedly includes orchestration, persistence, process control, networking, plugin loading, code-related modules, and broader agent behaviors. This is dangerous because users and hosting agents may grant trust and deployment approval based on the manifest, while the implementation exposes a much larger and riskier attack surface.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
99% confidence
Finding

Across the findings, the dominant issue is severe description-behavior mismatch: the manifest markets a pure, deterministic trust/discrimination layer with no writes, telemetry, or execution by default, while the analyzed codebase reportedly includes orchestration, persistence, process control, networking, plugin loading, code-related modules, and broader agent behaviors. This is dangerous because users and hosting agents may grant trust and deployment approval based on the manifest, while the implementation exposes a much larger and riskier attack surface.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
99% confidence
Finding

Across the findings, the dominant issue is severe description-behavior mismatch: the manifest markets a pure, deterministic trust/discrimination layer with no writes, telemetry, or execution by default, while the analyzed codebase reportedly includes orchestration, persistence, process control, networking, plugin loading, code-related modules, and broader agent behaviors. This is dangerous because users and hosting agents may grant trust and deployment approval based on the manifest, while the implementation exposes a much larger and riskier attack surface.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
99% confidence
Finding

Across the findings, the dominant issue is severe description-behavior mismatch: the manifest markets a pure, deterministic trust/discrimination layer with no writes, telemetry, or execution by default, while the analyzed codebase reportedly includes orchestration, persistence, process control, networking, plugin loading, code-related modules, and broader agent behaviors. This is dangerous because users and hosting agents may grant trust and deployment approval based on the manifest, while the implementation exposes a much larger and riskier attack surface.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
99% confidence
Finding

Across the findings, the dominant issue is severe description-behavior mismatch: the manifest markets a pure, deterministic trust/discrimination layer with no writes, telemetry, or execution by default, while the analyzed codebase reportedly includes orchestration, persistence, process control, networking, plugin loading, code-related modules, and broader agent behaviors. This is dangerous because users and hosting agents may grant trust and deployment approval based on the manifest, while the implementation exposes a much larger and riskier attack surface.

Content

No source excerpt is available for this finding.