Back to skill

Security audit

Moltbook Trend Analysis

Security checks for vulnerabilities and agentic risk

Overview

The skill mostly does what it says, but one documented environment setting can be abused to run arbitrary local code when the fetch script is invoked.

Install only if you are comfortable running local shell/Python scripts. Do not run this skill in an environment where untrusted code or automation can set DELAY_MS, and keep SNAPSHOT_DIR pointed at a disposable intended output folder. A safer release should validate DELAY_MS as a bounded integer before invoking Python.

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
scripts/fetch_trends.sh:29
Finding

Arbitrary Python Code Execution Through the DELAY_MS Environment Variable

Content
View full analysis

Vulnerability Details

File Location: scripts/fetch_trends.sh, line 29
Vulnerability Type: Environment-variable injection into dynamically constructed Python source
Risk Level: High

Vulnerable code:

bash
delay_seconds() {
  # convert ms to fractional seconds for sleep
  python3 -c "print(${DELAY_MS}/1000.0)" 2>/dev/null || echo "1.5"
}

Technical Analysis

DELAY_MS is a documented, user-configurable environment variable. Its value is interpolated directly into the source-code string passed to python3 -c, without numeric validation or safe argument passing.

Shell quoting prevents direct shell metacharacter interpretation inside this command, but it does not prevent Python-language injection. An attacker can supply a syntactically crafted value that closes or extends the intended print() expression and introduces arbitrary Python statements.

For example, a value shaped like the following demonstrates the injection principle:

text
0);__import__("os").system("ATTACKER_COMMAND");#

This transforms the generated Python program into code equivalent to:

python
print(0);__import__("os").system("ATTACKER_COMMAND");#/1000.0)

The flaw is reachable through both scripts/fetch_trends.sh and scripts/full_run.sh, because the orchestrator preserves the caller's environment when invoking the fetcher.

Attack Path

  1. An attacker gains control over DELAY_MS, such as through an untrusted wrapper, CI configuration, automation environment, or copied execution command.
  2. The attacker places Python syntax and a desired command in that variable.
  3. A user or Agent invokes scripts/fetch_trends.sh or scripts/full_run.sh.
  4. Line 29 interpolates the malicious value into the python3 -c source string.
  5. Python executes the injected statements before the trend-fetching loop begins.
  6. The injected process inherits the Skill runner's user identity, environment, f ...[truncated 1132 chars]
Remediation
View remediation

Remediation Suggestions

Validate DELAY_MS before use and pass it to Python as data rather than embedding it in executable source:

bash
delay_seconds() {
  [[ "$DELAY_MS" =~ ^[0-9]+$ ]] ||
    die "DELAY_MS must be a non-negative integer"

  python3 -c \
    'import sys; print(int(sys.argv[1]) / 1000.0)' \
    "$DELAY_MS"
}

Alternatively, avoid Python entirely and perform validated conversion with shell formatting:

bash
delay_seconds() {
  [[ "$DELAY_MS" =~ ^[0-9]+$ ]] ||
    die "DELAY_MS must be a non-negative integer"

  printf '%d.%03d\n' \
    "$((10#$DELAY_MS / 1000))" \
    "$((10#$DELAY_MS % 1000))"
}

Additional hardening should include:

  1. Apply strict allowlist validation to all documented environment overrides.
  2. Require positive bounded integers for PAGES and PAGE_SIZE.
  3. Bound DELAY_MS to a reasonable operational range to prevent denial of service through excessive sleep durations.
  4. Allow only documented values for SORT_MODE and TIMEFRAMES.
  5. Continue passing values through positional arguments, standard input, or narrowly scoped environment variables rather than constructing executable code.
  6. Add regression tests using quotes, semicolons, parentheses, comments, newlines, and nonnumeric values to verify that malformed input is rejected without execution.
Vulnerability Patterns
  • Tool MisuseTool Parameter Abuse, Chaining Abuse, Unsafe Defaults
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
Findings (8)

Tp4

High
Category
MCP Tool Poisoning
Confidence
95% confidence
Finding

The code’s actual function is a snapshot diff utility: it reads two existing JSON files, compares rankings, score shifts, new entrants, dropped posts, and author churn, then writes a Markdown report. While this overlaps partially with the declared idea of comparing Moltbook posts, it does not perform the key advertised capabilities: fetching data, analyzing trending posts for strategy, or generating virality reports with large-scale statistical benchmarks. The primary purpose is narrower and materially different from the description.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
95% confidence
Finding

The code does match the general idea of fetching Moltbook trending posts and doing lightweight analysis. However, the description overstates the implemented behavior. The script only retrieves feed pages from Moltbook, computes a few simple aggregate metrics, and writes snapshot JSON files. There is no evidence of comparative analysis across datasets, no virality report generation, and no use of a 36k+ post benchmark corpus. Additionally, the code performs local file writes to a snapshot directory, which is an undeclared capability/resource access. Therefore the declared description does not accurately represent the actual implemented behavior.

Content

No source excerpt is available for this finding.

Tool Parameter Abuse

High
Category
Tool Misuse
Confidence
89% confidence
Finding

The skill recommends a raw rm {baseDir}/data/snapshots/broken_file.json shell command using a templated path. If baseDir is attacker-controlled, malformed, empty, or unexpectedly expanded by the execution environment, this can delete unintended files; destructive shell operations in user-facing remediation guidance are especially risky because they normalize unsafe copy-paste behavior.

Content

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

Malformed snapshot JSON

Delete and re-fetch:

bash
rm {baseDir}/data/snapshots/broken_file.json
bash {baseDir}/scripts/fetch_trends.sh

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
91% confidence
Finding

The skill explicitly instructs the agent to use shell, network access, environment-variable overrides, and writable directories, yet it declares no explicit tool scope or permissions boundary. That creates an authorization gap: a host may expose broader-than-necessary capabilities, and reviewers cannot easily verify whether network, shell, and file-write access are intentional and constrained.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
97% confidence
Finding

The module docstring states 'Output: Markdown diff report to stdout,' which implies the script only emits a report to standard output. In reality, the code also creates a reports directory and saves a Markdown file there, adding persistent filesystem side effects beyond the documented behavior.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

The top-level documentation explicitly describes the script's output as a Markdown report to stdout. However, lines L237-L246 create a reports directory and write the same report to a timestamped file, which contradicts the documented no-persistence behavior.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Low
Category
Not specified by scanner
Confidence
95% confidence
Finding

The manifest says the skill can fetch, analyze, and compare trending Moltbook posts, implying end-to-end trend retrieval. This file does not fetch any Moltbook data or perform network access; it only loads local JSON snapshots and analyzes them into a markdown report.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Low
Category
Not specified by scanner
Confidence
78% confidence
Finding

The manifest focuses on fetching, analyzing, and comparing trending posts to generate virality reports, which could reasonably imply returning results to the caller. This script additionally persists reports under a local reports directory, which is extra behavior beyond pure analysis/report generation as described.

Content

No source excerpt is available for this finding.

Static analysis

No suspicious patterns detected.