Back to skill

Security audit

紫微斗数合盘配对

Security checks for vulnerabilities and agentic risk

Overview

The skill mostly does what it says, but a user-controlled rule version can make it read unintended local JSON files, so it needs review before use.

Install only if you trust the caller path to the CLI or can patch the rule_version handling first. A safe version should allowlist known rule versions such as compat/v1, reject traversal segments, avoid disclosing local paths in errors, and enforce an input-size limit before parsing stdin.

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 (2)

T09 · Insecure Skill Coding Practices

Warning
Location
hepan-cli/src/engine/computeCompat.js:15
Finding

Path Traversal in User-Controlled Rule Pack Resolution

Content
View full analysis

Vulnerability Details

File Location: hepan-cli/src/engine/computeCompat.js, lines 15–23
Vulnerability Type: Path traversal and unintended local file access
Risk Level: Medium

js
function loadRulePack(ruleVersion) {
  const segs = String(ruleVersion).split("/").filter(Boolean);
  if (segs.length < 1) throw new Error("rule_version empty");
  const fileName = `${segs[segs.length - 1]}.json`;
  const dirs = segs.slice(0, -1);
  const full = path.join(RULES_ROOT, ...dirs, fileName);
  if (!fs.existsSync(full)) {
    throw new Error(`unknown rule_version: ${ruleVersion} (path ${full})`);
  }
  return JSON.parse(fs.readFileSync(full, "utf8"));
}

Technical Analysis

The rule_version value originates from the JSON input supplied to the CLI. The function splits this value into path components and passes them to path.join() without rejecting .. components or verifying that the resolved path remains under RULES_ROOT.

Although path.join() normalizes the path, normalization does not enforce directory containment. An input containing traversal components can therefore resolve to a .json file outside the intended rules directory. The function then performs an existence check and reads the resulting file.

Exploitation is limited to files whose resolved names end in .json and which are readable by the Node.js process. To complete normal scoring, the loaded JSON must also resemble the expected rule-pack schema. However, even incompatible JSON files can be probed because missing files, malformed JSON, and schema-related failures produce distinguishable errors. The error for a missing rule also discloses the resolved filesystem path.

Attack Path

  1. An attacker obtains access to the CLI input channel or to an application that forwards requests to it.
  2. The attacker supplies otherwise acceptable chart_a and chart_b objects.
  3. The attacker sets rule_version to a traversal valu ...[truncated 1078 chars]
Remediation
View remediation

Remediation Suggestions

  • Prefer an explicit allowlist that maps supported identifiers such as compat/v1 to fixed rule-pack paths.
  • Reject absolute paths and any path segment equal to . or ...
  • Resolve the candidate with path.resolve() and verify that it remains below the canonical rules directory:
    js
    const rulesRoot = path.resolve(RULES_ROOT);
    const candidate = path.resolve(rulesRoot, ...dirs, fileName);
    
    if (!candidate.startsWith(`${rulesRoot}${path.sep}`)) {
      throw new Error("invalid rule_version");
    }
    
  • Validate rule_version against a restrictive pattern such as ^compat/v[0-9]+$ if that matches the intended versioning model.
  • Validate the loaded JSON against a strict rule-pack schema before using it.
  • Return generic client-facing errors and do not disclose resolved filesystem paths.
  • Add regression tests covering .., absolute paths, encoded traversal variants, empty segments, unsupported versions, and symlinks that point outside the rules directory.

T09 · Insecure Skill Coding Practices

Note
Location
hepan-cli/src/index.js:6
Finding

Unbounded Standard Input Buffering Enables Memory Exhaustion

Content
View full analysis

Vulnerability Details

File Location: hepan-cli/src/index.js, lines 6–10
Vulnerability Type: Uncontrolled resource consumption
Risk Level: Low

js
async function readStdin() {
  const chunks = [];
  for await (const c of process.stdin) chunks.push(c);
  return Buffer.concat(chunks);
}

Technical Analysis

The CLI reads the entire standard-input stream into an array and then creates another contiguous buffer with Buffer.concat(). No maximum request size is enforced.

An attacker who can control stdin can continuously provide data, causing memory consumption to grow with the input size. Buffer concatenation can temporarily increase memory pressure further because it allocates a new buffer for the complete payload. JSON decoding and parsing then require additional memory.

Attack Path

  1. An attacker accesses the CLI input channel directly or through a service that forwards request bodies to the process.
  2. The attacker sends a very large payload or continuously streams data without closing the input.
  3. The process retains every received chunk in memory.
  4. If the stream ends, Buffer.concat() allocates another buffer for the accumulated input.
  5. The process experiences excessive memory consumption, garbage-collection pressure, termination, or host-level resource degradation.

Impact Assessment

The issue can cause denial of service for the CLI process. If multiple instances are launched concurrently, it can also exhaust memory for the surrounding service or host.

The vulnerability does not grant additional privileges, filesystem access, or code execution. Its practical scope depends on whether untrusted users can reach the stdin boundary and whether an upstream component already enforces request-size and execution-time limits.

Remediation
View remediation

Remediation Suggestions

  • Enforce a strict byte limit while consuming stdin and abort as soon as the limit is exceeded.
  • Choose a limit based on the largest legitimate pair of chart objects, with a small documented safety margin.
  • Avoid retaining input after the limit is reached.
  • Return a generic structured error such as input exceeds maximum allowed size.
  • Apply request-body limits, process timeouts, memory limits, and concurrency controls in any API or Agent wrapper.
  • Add automated tests confirming rejection of oversized input and streams that exceed the limit incrementally.

Example hardening:

js
async function readStdin(maxBytes = 2 * 1024 * 1024) {
  const chunks = [];
  let total = 0;

  for await (const chunk of process.stdin) {
    total += chunk.length;
    if (total > maxBytes) {
      throw new Error("input exceeds maximum allowed size");
    }
    chunks.push(chunk);
  }

  return Buffer.concat(chunks, total);
}
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
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
Findings (6)

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

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

md
仓库内完整示例载荷(由 fixture 生成,体积较大):[examples/sample-compat-payload.json](examples/sample-compat-payload.json)。在 `hepan-cli` 目录下可执行:

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

This JSON payload contains user-facing natural-language values almost entirely in Chinese, including dates, labels, and astrological terms such as "命宫", "夫妻", and "一九九三年闰三月十二", with no indication that language selection is configurable. Because SQP-3 applies to all file types, this constitutes a locale-policy issue when the file implicitly fixes output/content to one language without documenting user choice or region-specific justification.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
92% confidence
Finding

The package description is entirely in Chinese and presents the skill's purpose only in that language. Under the policy rule, forcing a specific language without user opt-in can be a natural-language policy violation, and this manifest does not indicate any language choice or region-specific justification.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
88% confidence
Finding

The inline comment is written only in Chinese ("兼容 Windows PowerShell 通过管道传 UTF-16LE JSON 的情况。"), which reflects a language-specific instruction in the file without offering an alternative language or documenting that the skill is region- or locale-specific. Under the stated policy, language constraints should be optional or clearly justified.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
83% confidence
Finding

This file contains numerous Chinese-only category labels such as "辅星", "机月同梁", and "紫微" in data keys, with no indication that the skill is intentionally region- or locale-specific. For a file applicable to all types under the natural-language policy rule, this can indicate a language/locale constraint without user opt-in or documented justification.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
83% confidence
Finding

This JSON fixture includes numerous natural-language values such as zodiac, palace names, and calendar strings exclusively in Chinese, but provides no indication that the skill is China/Chinese-locale-specific or that users can opt into this language. Under the policy, forcing a specific language without user choice can be a locale-policy issue even in config or data files.

Content

No source excerpt is available for this finding.