Back to skill

Security audit

question-bank-api

Security checks for vulnerabilities and agentic risk

Overview

The skill mostly matches its stated purpose, but its API-key handling can expose the key if a custom API server or command-line key is used.

Review before installing. Use this only if you trust the API provider, keep QB_API_BASE on the official HTTPS endpoint unless you fully trust another gateway, prefer QB_API_KEY in the environment over --key, avoid sharing logs or commands containing the key, and choose Word export paths carefully because existing files may be overwritten.

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

Error
Location
scripts/qb.py:41
Finding

API Key Disclosure Through an Unrestricted API Base URL

Content
View full analysis
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/test_local.sh:19
Finding

API Key Exposure Through Command-Line Arguments

Content
View full analysis
--key [--py ] # 没传则回退到环境变量 QB_API_BASE / QB_API_KEY(避免 PowerShell→bash 环境变量继承丢失) BASE=""; KEY=""; PY="${PYTHON:-python3}" while [ $# -gt 0 ]; do case "$1" in --base) BASE="$2"; shift 2;; --key) KEY="$2"; shift 2;; --py) PY="$2"; shift 2;; *) echo "[忽略未知参数] $1"; shift;; esac done BASE="${BASE:-${QB_API_BASE:-}}" KEY="${KEY:-${QB_API_KEY:-}}" if [ -z "$BASE" ] || [ -z "$KEY" ]; then echo "[错误] 请提供 --base 和 --key 参数,或先设置 QB_API_BASE / QB_API_KEY 环境变量" >&2 exit 1 fi run() { echo echo "==================================================" echo "### $*" echo "==================================================" "$PY" "$(dirname "$0")/qb.py" "$@" --base "$BASE" --key "$KEY" } ``` The Python client explicitly accepts the secret as a command-line argument: ```python common.add_argument("--base") common.add_argument("--key") ``` ### Technical Analysis The documentation and test script support supplying the API key using `--key`. Secrets passed in command-line arguments can be exposed through several operating-system and operational channels: - Shell command history - Process listings and process inspection interfaces - Diagnostic and endpoint-monitoring tools - CI/CD command logs - Terminal session recording - Crash reports or support bundles that capture process arguments The test script increases exposure by reading the key into `KEY` and then forwarding it to every Python invocation as `--key "$KEY"`. Even when the key originally comes from `QB_API_KEY`, the script converts it into a visible child-process command-line argument. Quoting the argument prevents sh ...[truncated 1514 chars]
Remediation
View remediation
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Behavioral ASTexec() Call, eval() Call, Dynamic Import
  • Taint TrackingDirect Taint Flow, Variable-Mediated Taint Flow, Credential Exfiltration Chain
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
Findings (14)

Tainted flow: 'req' from os.environ.get (line 54, credential/environment) → urllib.request.urlopen (network output)

Critical
Category
Data Flow
Confidence
90% confidence
Finding

Credentials or environment variables flow to a network sink. This is a high-confidence indicator of credential exfiltration.

Content

Scanner excerpt · scripts/qb.py (reported line 61)May include surrounding context.

python
last = None
    for attempt in range(3):
        try:
            with urllib.request.urlopen(req, timeout=timeout) as r:
                if raw or out_path:
                    data = r.read()
                    if out_path:

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
92% confidence
Finding

The skill invokes a Python script that uses environment variables and performs outbound network requests to a third-party API, but the manifest does not declare any tool scope or allowed tools. This creates an authorization and review gap: an agent may run code with broader-than-expected capabilities, including reading sensitive env vars or making unintended external requests, without explicit policy constraints.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The CLI help text, warnings, and printed output are presented in Chinese throughout the parser and runtime messages, which effectively forces a specific language for users. There is no visible option to select another locale or an explicit statement that the tool is region-specific and intentionally Chinese-only.

Content

No source excerpt is available for this finding.

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
86% confidence
Finding

This markdown file tells users to configure QB_API_KEY for the skill, which is a sensitive credential, but provides no warning about keeping the key secret or avoiding sharing it in logs, screenshots, or prompts. Under the markdown variant of SQP-2, omission of warnings about privacy- or data-affecting behavior is a valid finding.

Content

No source excerpt is available for this finding.

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
89% confidence
Finding

This markdown file documents that the script saves the binary DOCX stream to a local file via --out, which is a file-write operation. Under the markdown-specific warning rule, the description should disclose behaviors that affect user data or the local system, but no caution or warning is provided around overwriting or creating local files.

Content

No source excerpt is available for this finding.

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
84% confidence
Finding

The post() helper serializes payloads and sends them to a remote vendor API, including user-provided query content and identifiers, and may attach an API key header. While the module docstring describes the API client generally, the code path itself provides no confirmation prompt or user-facing disclosure when transmitting potentially sensitive user input to the external service.

Content

No source excerpt is available for this finding.

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
90% confidence
Finding

When out_path is provided, the code opens the path in write-binary mode and saves remote response data, overwriting any existing file at that location. Although the save is part of the command purpose, there is no pre-write warning, confirmation, or overwrite notice near the file-write operation itself.

Content

No source excerpt is available for this finding.

Dynamic attribute access via getattr()

Low
Category
Dangerous Code Execution
Confidence
50% confidence
Finding

Dynamic getattr() with a non-literal attribute name can access arbitrary object attributes, potentially bypassing access controls.

Content

Scanner excerpt · scripts/qb.py (reported line 159)May include surrounding context.

python
def build_knowledge_payload(knowledgeId, args, page):
    p = {"knowledgeId": knowledgeId, "page": page or 1}
    for k in ("qtypeId", "paperType", "diff", "gradeId", "year"):
        v = getattr(args, k, None)
        if v is not None:
            p[k] = v
    return p

Dynamic attribute access via getattr()

Low
Category
Dangerous Code Execution
Confidence
50% confidence
Finding

Dynamic getattr() with a non-literal attribute name can access arbitrary object attributes, potentially bypassing access controls.

Content

Scanner excerpt · scripts/qb.py (reported line 208)May include surrounding context.

python
def cmd_chapter_tree(args, c):
    p = {"pharseId": args.pharseId}
    for k in ("subjectId", "editionId", "gradeId"):
        v = getattr(args, k)
        if v:
            p[k] = v
    d = post(*c, "/api/v1/chapterApi", p)

Dynamic attribute access via getattr()

Low
Category
Dangerous Code Execution
Confidence
50% confidence
Finding

Dynamic getattr() with a non-literal attribute name can access arbitrary object attributes, potentially bypassing access controls.

Content

Scanner excerpt · scripts/qb.py (reported line 223)May include surrounding context.

python
def cmd_chapter_tree(args, c):
    p = {"pharseId": args.pharseId}
    for k in ("subjectId", "editionId", "gradeId"):
        v = getattr(args, k)
        if v:
            p[k] = v
    d = post(*c, "/api/v1/chapterApi", p)

Dynamic attribute access via getattr()

Low
Category
Dangerous Code Execution
Confidence
50% confidence
Finding

Dynamic getattr() with a non-literal attribute name can access arbitrary object attributes, potentially bypassing access controls.

Content

Scanner excerpt · scripts/qb.py (reported line 240)May include surrounding context.

python
def cmd_chapter_tree(args, c):
    p = {"pharseId": args.pharseId}
    for k in ("subjectId", "editionId", "gradeId"):
        v = getattr(args, k)
        if v:
            p[k] = v
    d = post(*c, "/api/v1/chapterApi", p)

Dynamic attribute access via getattr()

Low
Category
Dangerous Code Execution
Confidence
50% confidence
Finding

Dynamic getattr() with a non-literal attribute name can access arbitrary object attributes, potentially bypassing access controls.

Content

Scanner excerpt · scripts/qb.py (reported line 256)May include surrounding context.

python
def cmd_chapter_tree(args, c):
    p = {"pharseId": args.pharseId}
    for k in ("subjectId", "editionId", "gradeId"):
        v = getattr(args, k)
        if v:
            p[k] = v
    d = post(*c, "/api/v1/chapterApi", p)

Dynamic attribute access via getattr()

Low
Category
Dangerous Code Execution
Confidence
50% confidence
Finding

Dynamic getattr() with a non-literal attribute name can access arbitrary object attributes, potentially bypassing access controls.

Content

Scanner excerpt · scripts/qb.py (reported line 278)May include surrounding context.

python
def cmd_chapter_tree(args, c):
    p = {"pharseId": args.pharseId}
    for k in ("subjectId", "editionId", "gradeId"):
        v = getattr(args, k)
        if v:
            p[k] = v
    d = post(*c, "/api/v1/chapterApi", p)

Dynamic attribute access via getattr()

Low
Category
Dangerous Code Execution
Confidence
50% confidence
Finding

Dynamic getattr() with a non-literal attribute name can access arbitrary object attributes, potentially bypassing access controls.

Content

Scanner excerpt · scripts/qb.py (reported line 357)May include surrounding context.

python
def cmd_chapter_tree(args, c):
    p = {"pharseId": args.pharseId}
    for k in ("subjectId", "editionId", "gradeId"):
        v = getattr(args, k)
        if v:
            p[k] = v
    d = post(*c, "/api/v1/chapterApi", p)