Back to skill

Security audit

Second Brain Growth

Security checks for vulnerabilities and agentic risk

Overview

The skill is mostly purpose-aligned for analyzing a local second-brain repository, but one documented command can turn a user-supplied question into unsafe shell input.

Install only if you intend the agent to read your Hbrain/second-brain files. Before using the dry-routing command with arbitrary questions, change it to pass the question as a literal argument through an argument-array API or otherwise robustly escape it; do not let agents paste raw user text into that shell example. Use the cron/report features only when you deliberately want persistent scheduled reports.

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

Error
Location
SKILL.md:86
Finding

Potential Shell Command Injection Through Unsafe User-Question Interpolation

Content
View full analysis

Vulnerability Details

File Location: SKILL.md, lines 86-90
Vulnerability Type: Shell command injection
Risk Level: High

Vulnerable Code

markdown
- If the user gives a specific question, run dry routing only:

```bash
python3 /Users/jianghaidong/.agents/skills/hbrain-cognitive-loop/scripts/hbrain_loop.py route --query "<user question>"
text

### Technical Analysis

The skill instructs the agent to place a user-supplied question inside a double-quoted shell argument. It does not require an argument-array execution API, escaping, validation, or another mechanism that preserves the question strictly as data.

If an implementation performs literal placeholder substitution and then invokes the resulting text through a shell, an attacker can include a double quote to terminate the argument and append shell operators or command substitutions. Double quotes do not prevent command substitution, and an injected closing quote can expose additional shell syntax.

The vulnerability depends on the agent or runtime translating this documentation example into a shell command through unsafe textual interpolation. Passing the question directly as an argument without a shell would prevent this exploitation path.

### Attack Path

1. An attacker asks the agent to evaluate or route a specially crafted “specific question.”
2. The question contains syntax that escapes the intended quoted argument, such as a closing double quote followed by a shell operator and an attacker-selected command.
3. The agent replaces `<user question>` verbatim in the documented command.
4. The agent executes the constructed command through a shell.
5. The shell interprets the injected syntax and runs the attacker-selected command with the agent process's permissions.

For example, unsafe substitution of a payload shaped like the following would alter shell parsing:

```text
"; ATTACKER_SELECTED_COMMAND; #

Impact Assessment

Successful exploitation could execute arbitrar ...[truncated 628 chars]

Remediation
View remediation

Remediation Suggestions

  1. Execute the Python program through an argument-array API rather than constructing a shell command. For example, equivalent implementations should pass separate arguments:

    python
    subprocess.run(
        [
            "python3",
            "/Users/jianghaidong/.agents/skills/hbrain-cognitive-loop/scripts/hbrain_loop.py",
            "route",
            "--query",
            user_question,
        ],
        shell=False,
        check=True,
    )
    
  2. Amend the skill instructions to explicitly prohibit verbatim interpolation into shell command strings and prohibit shell=True.

  3. If only a shell interface is available, apply robust platform-appropriate quoting such as Python's shlex.quote; argument-array execution should still be preferred.

  4. Treat the full question as untrusted data. Do not interpret embedded command substitutions, redirections, newlines, or shell operators.

  5. Add tests containing quotes, command substitutions, semicolons, newlines, pipes, and redirection characters to verify that the complete input reaches --query as one literal argument.

  6. Consider replacing the executable example with a structured tool-call example so an agent is less likely to reproduce it using textual shell interpolation.

Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
Findings (3)

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
97% confidence
Finding

The skill sets a default user-facing language of Chinese without checking the user's preference. This can cause confusing or inaccessible output for users who do not read Chinese, leading to misunderstandings in advice or automation reports, but it does not directly enable code execution, privilege escalation, or data exfiltration.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

The Codex interactive mode explicitly instructs the agent to answer in Chinese, again overriding likely user preference. In an interactive setting this increases the chance of user misunderstanding and incorrect decisions based on untranslated operational or analytical details, though the security impact remains limited.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The default invocation phrase is broad and can trigger this skill in many loosely related contexts, causing the agent to activate without clear user intent. In a multi-agent environment spanning Codex, Hermes, and OpenClaw, overbroad routing increases the chance of unintended access to note-analysis workflows, data exposure, or incorrect autonomous handoff.

Content

No source excerpt is available for this finding.

Static analysis

No suspicious patterns detected.