Back to skill

Security audit

TokenBroker — 统一AI API网关

Security checks for vulnerabilities and agentic risk

Overview

The skill’s TokenBroker purpose is understandable, but its installer can run unaudited external code and register a persistent local service with too little user control.

Review this carefully before installing. It may start and persist a local TokenBroker service, modify ~/supervisord.conf, install Node dependencies from an external project directory, and route LLM calls through a broker that records usage. Only use it if you trust the external token-broker project and are comfortable auditing or manually controlling the Supervisor and npm steps.

Vulnerability Patterns
  • System PersistenceInstalls backdoors, hooks, services, or scheduled tasks that survive the run
  • Insecure DependenciesIntroduces malicious components through unsafe dependency sources
  • 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
Findings (3)

T06 · System Persistence

Error
Location
scripts/init.sh:42
Finding

Persistent execution of code outside the audited Skill package

Content
View full analysis
/dev/null && python3 -c "import supervisor" 2>/dev/null; then SUPERVISOR_CONF="${HOME}/supervisord.conf" if [ -f "${SUPERVISOR_CONF}" ]; then if ! grep -q "token-broker" "${SUPERVISOR_CONF}" 2>/dev/null; then warn "未在 Supervisor 中找到 token-broker,尝试注册..." # 尝试通过 supervisord 提供的 rpc 接口添加 echo " [program:token-broker] command=npx ts-node ${BROKER_DIR}/src/server.ts directory=${BROKER_DIR} autostart=true autorestart=true startsecs=5 startretries=10 stopwaitsecs=5 killasgroup=true stopsignal=TERM stdout_logfile=/dev/stdout stdout_logfile_maxbytes=0 stderr_logfile=/dev/stderr stderr_logfile_maxbytes=0 environment=BROKER_PORT=${BROKER_PORT},NODE_ENV=production" >> "${SUPERVISOR_CONF}" info "已追加到 Supervisor 配置" python3 -m supervisor.supervisorctl -c "${SUPERVISOR_CONF}" reread 2>/dev/null || true python3 -m supervisor.supervisorctl -c "${SUPERVISOR_CONF}" update 2>/dev/null || true sleep 2 else info "Supervisor 中已配置 TokenBroker" python3 -m supervisor.supervisorctl -c "${SUPERVISOR_CONF}" start token-broker 2>/dev/null || true sleep 2 fi fi fi ``` ### Technical Analysis The initialization script appends a new program definition to the user's persistent Supervisor configuration. The definition enables both `autostart` and `autorestart`, causing `${BROKER_DIR}/src/server.ts` to execute beyond the lifetime of the installer and to restart automatically after failure or a Supervisor restart. The executed broker source is located in the sibling directory `../../production-system/token-broker` rather than inside the audited Skill. That source code is not included in the project under review, so its behavior and integrity cannot be verified as par ...[truncated 1425 chars]
Remediation
View remediation

T08 · Insecure Dependencies

Error
Location
scripts/init.sh:36
Finding

Unsafe installation and execution of unaudited third-party dependencies

Content
View full analysis
&1 | tail -1 fi # 4. 通过 Supervisor 注册(如果已安装 Supervisor) if command -v python3 &> /dev/null && python3 -c "import supervisor" 2>/dev/null; then SUPERVISOR_CONF="${HOME}/supervisord.conf" if [ -f "${SUPERVISOR_CONF}" ]; then if ! grep -q "token-broker" "${SUPERVISOR_CONF}" 2>/dev/null; then warn "未在 Supervisor 中找到 token-broker,尝试注册..." # 尝试通过 supervisord 提供的 rpc 接口添加 echo " [program:token-broker] command=npx ts-node ${BROKER_DIR}/src/server.ts ``` ### Technical Analysis The script runs `npm install` in an external directory whose package manifest, lockfile, source code, and dependency integrity information are absent from the audited project. Standard `npm install` behavior may retrieve packages from configured registries and execute dependency lifecycle hooks such as `preinstall`, `install`, and `postinstall`. The generated Supervisor command subsequently uses `npx ts-node`. Depending on the external project's installed packages and npm configuration, `npx` may resolve an executable from local dependencies, the user's environment, or a package registry. The Skill does not pin or verify the executable being launched. Checking only whether `node_modules` exists is not an integrity check. A preexisting but attacker-modified `node_modules` directory bypasses installation and is then trusted during execution. ### Attack Path 1. An attacker compromises a dependency referenced by the external broker project, modifies its package metadata or lockfile, controls the configured npm registry, or plants a malicious local package or executable. 2. The initializer finds that `${BROKER_DIR}/node_modules` does not exist ...[truncated 1101 chars]
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Error
Location
scripts/init.sh:16
Finding

Supervisor configuration injection through unvalidated BROKER_PORT

Content
View full analysis
> "${SUPERVISOR_CONF}" ``` ### Technical Analysis `BROKER_PORT` is accepted from the process environment without validating that it contains only a valid TCP port number. Its value is directly inserted into text appended to `~/supervisord.conf`. Shell quoting around `${BROKER_PORT}` prevents ordinary shell word splitting at expansion time, but it does not make the value safe for the Supervisor configuration format. An environment value containing newline characters or configuration syntax can terminate the intended directive and inject additional Supervisor directives or sections. The script immediately invokes `supervisorctl reread` and `supervisorctl update` after writing the configuration, which can activate injected content. Errors from these commands are suppressed with `2>/dev/null || true`, reducing the likelihood that malformed or partially applied configuration will be noticed. ### Attack Path 1. An attacker gains the ability to influence the environment used to launch the initializer, such as through a wrapper script, automated installation environment, inherited process configuration, or manipulated deployment settings. 2. The attacker supplies a `BROKER_PORT` value containing a newline followed by attacker-selected Supervisor configuration directives. 3. The initial health request fails or is rejected, allowing execution to continue to the registration block. 4. The initializer inserts the unescaped value into `~/supervisord.conf`. 5. The appended value creates or modifies a Supervisor program definition containing an attacker-selected command. 6. `supervisorctl reread` a ...[truncated 657 chars]
Remediation
View remediation
65535 )); then error "BROKER_PORT must be an integer between 1 and 65535" exit 1 fi ``` 2. Explicitly reject newline characters, carriage returns, control characters, commas, percent signs, quotes, and other syntax not required for a numeric port. 3. Avoid generating configuration through an interpolated multiline `echo`. Use a fixed template and substitute only strictly validated values. 4. Write a dedicated temporary configuration using secure file creation, validate it with Supervisor tooling, and atomically move it into place. 5. Set restrictive permissions on generated configuration files. 6. Do not suppress `supervisorctl` errors. Abort if configuration validation, rereading, or activation fails. 7. Verify the generated configuration after writing it and ensure that only the expected `token-broker` section and directives are present. ]]>
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
Findings (9)

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The skill states that installation will automatically detect and start a backend service and later says it configures the service under Supervisor, but it does not clearly warn the user up front that installing the skill changes local runtime state and persistence. Silent service startup and supervision changes reduce informed consent and can surprise users with a long-running local process.

Content

No source excerpt is available for this finding.

Rp1

Medium
Category
MCP Rug Pull
Confidence
84% confidence
Finding

The skill instructs operators to run npx ts-node src/server.ts without pinning an exact package/version, which can pull or rely on whatever resolver state is present at execution time. In a local privileged install/startup path, this creates supply-chain and reproducibility risk because an unexpected or compromised dependency/tooling version could execute arbitrary code.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The skill advertises automatic routing of LLM requests, API invocation, and usage/billing statistics recording, but does not disclose what prompt data, metadata, or identifiers are transmitted, stored, or retained. Because this feature intermediates all AI calls, missing privacy and data-handling warnings can expose sensitive user content or operational metadata without informed consent.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

The header presents the file as a simple installation/initialization script, but the body modifies persistent Supervisor configuration and attempts to start a backend service automatically. This mismatch reduces informed consent and can cause users to run a script that establishes persistence or changes system behavior beyond what they reasonably expect.

Content

No source excerpt is available for this finding.

External Transmission

Medium
Category
Data Exfiltration
Confidence
70% confidence
Finding

Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.

Content

Scanner excerpt · scripts/init.sh (reported line 26)May include surrounding context.

sh
echo "╚══════════════════════════════════════╝"

# 1. 检测后端是否已在运行
if curl -s --connect-timeout 2 "${BROKER_URL}/api/health" > /dev/null 2>&1; then
  info "TokenBroker 后端服务已在运行 (端口 ${BROKER_PORT})"
  exit 0
fi

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

The script appends a new [program:token-broker] block to ${HOME}/supervisord.conf without confirmation, review, or backup, thereby persisting a service that will auto-start and auto-restart. Any script that silently changes a user's process supervisor configuration can create unwanted persistence and makes abuse significantly more dangerous if the referenced service or path is compromised.

Content

No source excerpt is available for this finding.

Rp1

Medium
Category
MCP Rug Pull
Confidence
70% confidence
Finding

npx commands without a version suffix (e.g. @1.0.0) create a rug-pull risk if the upstream server is compromised and publishes a malicious update.

Content

No source excerpt is available for this finding.

Rp1

Medium
Category
MCP Rug Pull
Confidence
70% confidence
Finding

npx commands without a version suffix (e.g. @1.0.0) create a rug-pull risk if the upstream server is compromised and publishes a malicious update.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
97% confidence
Finding

The script's comments and all user-visible status messages are in Chinese, which imposes a specific language on users without opt-in. Under the stated policy, locale-specific behavior should either offer a language choice or be explicitly justified as region-specific.

Content

No source excerpt is available for this finding.