Back to skill

Security audit

蒋道理|撤三证据链与风险审核引擎(SJ-IRAC)

Security checks for vulnerabilities and agentic risk

Overview

The skill is mostly purpose-aligned for local trademark evidence work, but its WebUI can expose sensitive case data and logs without enforcing authentication on read endpoints.

Install only if you are comfortable running a local legal-document processor that writes case material, OCR cache, logs, and generated files to disk. Keep the WebUI bound to 127.0.0.1, avoid network-accessible hosts until the read endpoints require authentication, and use a private output directory that is not shared or synced unintentionally. Pin dependencies before production use if reproducible installs matter.

Vulnerability Patterns
  • 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
  • Remote Payload Retrieval and ExecutionFetches external code whose behavior can change after review
Findings (2)

T09 · Insecure Skill Coding Practices

Error
Location
run_nonuse_webui.py:1766
Finding

Unauthenticated WebUI read endpoints disclose confidential legal case data and processing logs

Content
View full analysis
bool: if not WEBUI_REQUIRE_AUTH: return True if not WEBUI_AUTH_TOKEN: return False auth = str(header_val or "").strip() if not auth.startswith("Bearer "): return False provided = auth.split(" ", 1)[1].strip() return provided == WEBUI_AUTH_TOKEN ``` The review-data loader reads a caller-selected output directory and returns case information, personal information, filesystem paths, and the complete raw summary: ```python def load_review_data(out_dir: str) -> Dict[str, object]: out_path = Path(out_dir).expanduser().resolve() summary_path = out_path / "扫描识别摘要.json" precheck_path = out_path / "pre_output_checklist.docx" xlsx_path = out_path / "nonuse_casebook_自动识别.xlsx" summary: Dict[str, object] = {} if summary_path.exists(): try: summary = json.loads(summary_path.read_text(encoding="utf-8")) except Exception as exc: WEBUI_LOGGER.exception("读取扫描识别摘要失败") audit({ "type": "exception", "step": "load_review_data", "file": str(summary_path), "error": str(exc), "traceback": traceback.format_exc(), "ok": False, "reason_code": "summary_json_parse_failed", }) summary = {} case_info_keys = [ ("case_no", "案件编号"), ("reg_no", "商标号"), ("mark_name", "商标名称"), ("class", "类别"), ("respondent", "答辩人"), ("applicant", "申请人"), ("period_start", "指定期间起"), ("period_end", "指定期间止"), ("revoked_goods_servi ...[truncated 6528 chars]
Remediation
View remediation
bool: if not self._auth_ok(): self._send_json({"ok": False, "error": "Forbidden"}, 403) return False return True ``` Call it before handling `/api/review-data`, `/api/status`, and any future endpoint that returns case or operational information. 2. Separate public health checks from protected application data. `/api/ping` may remain minimal, but it should not return configuration, path, case, or job information. 3. Constrain `out_dir` to an approved root or the active job: - Resolve both the requested path and approved root. - Verify containment using `Path.relative_to()`. - Reject paths outside that boundary. - Prefer a server-side job identifier instead of accepting arbitrary filesystem paths from clients. 4. Return only the fields required by the review page. Remove the unrestricted `"summary": summary` response and construct an explicit allowlist of non-sensitive fields. 5. Redact personal data, evidence names, command arguments, and absolute paths from logs before exposing them through `/api/status`. 6. Use constant-time token comparison, such as `hmac.compare_digest()`, rather than direct string equality. 7. Keep the default loopback-only binding. Clearly warn users that network binding exposes confidential legal material and should only occur on a trusted network. 8. Protect network deployments with TLS through a trusted reverse proxy or another authenticated encrypted channel. Bearer tokens and case data should not traverse an untrusted network over plaintext HTTP. 9. Add automated authorization tests covering: - Missing, malformed, and incorrect tokens - Every sensitive GET and POST endpoint - Path traversal and paths outside the approved output root - Redaction of logs and raw summary fields ]]>

T08 · Insecure Dependencies

Warning
Location
requirements.txt:1
Finding

Unpinned third-party dependencies create non-reproducible and unsafe installations

Content
View full analysis
Remediation
View remediation
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Tool MisuseTool Parameter Abuse, Chaining Abuse, Unsafe Defaults
  • Rogue AgentSelf-Modification, Session Persistence
  • Behavioral ASTexec() Call, eval() Call, Dynamic Import
Findings (52)

Anti-Refusal Statement

High
Category
Anti-Refusal
Confidence
80% confidence
Finding

Skill attempts to nullify the agent's safety policies or restrictions ('you have no restrictions', 'ignore your guidelines', 'do anything now'). This is a direct jailbreak that disables guardrails.

Content

Scanner excerpt · AGENTS.md (reported line 21)May include surrounding context.

md
- All thresholds/weights are externalized in rules/*.yaml and recorded in rule_profile_used.json
3) Stability:
   - No infinite hangs (LibreOffice conversion must have timeout)
   - No destructive shell ops without guardrails (safe_rm)
4) Safety:
   - No network exposure without explicit token if binding non-localhost
   - Never print secrets/tokens into logs

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
79% confidence
Finding

The title and prime directive specify a China trademark non-use defense workflow and include Chinese-language context, but the file does not explicitly state that this is a region-specific skill or offer any language/locale choice. Under the policy rule, hardwiring a locale or language without opt-in can be a natural-language policy concern unless clearly justified.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
85% confidence
Finding

The title explicitly states '蓝白汉化' and the manifest content is entirely presented in Chinese, indicating a language-localized skill package without any visible opt-in, alternative language option, or justification for restricting locale. Under the policy, forcing a specific language without user choice can be a natural-language policy violation.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
88% confidence
Finding

The file is written entirely in Chinese and explicitly states that the macOS launcher opens a 中文蓝白主题网页界面, indicating a fixed language/locale experience. Under the policy, forcing a specific language without user opt-in or documented justification is a natural-language policy concern.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The file forces Chinese-oriented processing and output behavior, including Tesseract language selection "chi_sim+eng" and generated HTML with lang="zh-CN", while many user-facing strings and outputs are also fixed in Chinese. This is a natural-language locale policy issue because the skill enforces a specific language/locale without any opt-in or configuration path for users who need another language.

Content

No source excerpt is available for this finding.

subprocess module call

Medium
Category
Dangerous Code Execution
Confidence
70% confidence
Finding

subprocess module calls execute external commands. Without careful input validation, this enables command injection.

Content

Scanner excerpt · auto_recognize_and_generate.py (reported line 365)May include surrounding context.

python
def run(cmd: List[str], timeout_sec: Optional[int] = None) -> Tuple[int, str, str]:
    try:
        p = subprocess.run(
            cmd,
            stdout=subprocess.PIPE,
            stderr=subprocess.PIPE,

Intent-Code Divergence

Medium
Category
Not specified by scanner
Confidence
88% confidence
Finding

The generated checklist explicitly states that formal document output must be blocked until manual confirmation, but the main workflow creates substantial output artifacts beforehand, including organized evidence packages, merged PDFs, manifests, reports, and the recognized workbook, only gating the downstream generator step later. That means the documentation promises a stricter pre-approval boundary than the code actually enforces.

Content

No source excerpt is available for this finding.

Session Persistence

Medium
Category
Rogue Agent
Confidence
75% confidence
Finding

Skill establishes unauthorized persistence across sessions via cron jobs, startup scripts, or state files. Session persistence allows an attacker to maintain access beyond the current interaction.

Content

Scanner excerpt · auto_recognize_and_generate.py (reported line 5927)May include surrounding context.

python
anchor_txt = (r.get("Evidence Date Start", "") + (f" ~ {r.get('Evidence Date End', '')}" if r.get("Evidence Date End", "") else "")).strip(" ~")
        if not anchor_txt:
            anchor_txt = "时间不明"
        duplist = duplicate_map.get(r.get("Evidence ID", ""), [])
        dup_note = ";".join(duplist) if duplist else ""

        manifest_rows.append({

Session Persistence

Medium
Category
Rogue Agent
Confidence
75% confidence
Finding

Skill establishes unauthorized persistence across sessions via cron jobs, startup scripts, or state files. Session persistence allows an attacker to maintain access beyond the current interaction.

Content

Scanner excerpt · auto_recognize_and_generate.py (reported line 5928)May include surrounding context.

python
anchor_txt = (r.get("Evidence Date Start", "") + (f" ~ {r.get('Evidence Date End', '')}" if r.get("Evidence Date End", "") else "")).strip(" ~")
        if not anchor_txt:
            anchor_txt = "时间不明"
        duplist = duplicate_map.get(r.get("Evidence ID", ""), [])
        dup_note = ";".join(duplist) if duplist else ""

        manifest_rows.append({

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The script persists large amounts of sensitive case and evidence data to JSON, Excel, Markdown, DOCX, and PDF outputs, including identities, addresses, phone numbers, and evidence summaries. In a legal-evidence processing context, broad filesystem writes materially increase confidentiality risk if output directories are shared, synced, backed up, or accessed by other users or processes.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

The command-line arguments describe precise-highlight controls as user-configurable options, yet the implementation later hardcodes the highlight feature to a disabled state and never conditionally invokes the highlight generator. This is an active contradiction between user-facing inline documentation/help text and actual behavior, not merely omitted detail.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
90% confidence
Finding

The script invokes external tools such as the configured generator and document converters on attacker-controlled input files without a clear trust boundary or safety restrictions. In this skill's context, inputs include PDFs, images, Office files, and paths from CLI/config, so external parser exploitation or execution of an untrusted generator path could compromise the host environment.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

This Python code contains user-facing log and output strings in Chinese and, throughout the file, generates fixed Chinese-language document content such as reports, conclusions, and prompts. Because the file offers no language/locale selection or justification that the skill is strictly region-specific, it violates the natural-language policy requirement against forcing a specific language without user opt-in.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

Exception auditing captures file paths, raw error strings, and full tracebacks during case processing, which can include sensitive casebook locations, worksheet content fragments, and environment details. In this skill context the data being processed is legal matter information, so verbose logging materially raises confidentiality risk if logs are accessible to other users, aggregated centrally, or retained without controls.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Medium
Category
Not specified by scanner
Confidence
79% confidence
Finding

_derive_submission_verdict returns PASS when there is at least one in-period high/medium-confidence item and one goods-matched item, provided certain gate flags are absent. build_defense_final_conclusion_text then expands PASS into a strong legal-style assertion that the trademark '已形成可核验的使用证明链条', which overstates what the code actually established through heuristic scoring and threshold checks. This is an intent-level divergence between the implied certainty of the generated conclusion and the limited automated basis used to reach it.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
84% confidence
Finding

The code writes generated DOCX reports containing case identifiers, parties, addresses, and evidentiary details directly to disk without an explicit consent, confirmation, or data-handling notice in this execution path. In a legal-case workflow, these outputs may contain sensitive personal or business data, so silent persistence increases the risk of unintended disclosure on shared machines, synced folders, or misconfigured environments.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The file defines all user-facing labels and decision text in Chinese, including risk levels and submission guidance. Because this applies across the configuration and does not offer a language/locale option or explain that the skill is intentionally region-specific, it appears to enforce a specific language without user opt-in.

Content

No source excerpt is available for this finding.

subprocess module call

Medium
Category
Dangerous Code Execution
Confidence
70% confidence
Finding

subprocess module calls execute external commands. Without careful input validation, this enables command injection.

Content

Scanner excerpt · run_nonuse_case.py (reported line 244)May include surrounding context.

python
str(src_docx),
        ]
        try:
            p = subprocess.run(
                cmd,
                stdout=subprocess.PIPE,
                stderr=subprocess.PIPE,

subprocess module call

Medium
Category
Dangerous Code Execution
Confidence
70% confidence
Finding

subprocess module calls execute external commands. Without careful input validation, this enables command injection.

Content

Scanner excerpt · run_nonuse_case.py (reported line 643)May include surrounding context.

python
"--risk-out", args.risk_out,
        ]
        print("GEN:", " ".join(cmd_gen))
        p = subprocess.run(cmd_gen)
        rc = p.returncode
        if p.returncode == 0:
            _export_additional_formats(

subprocess module call

Medium
Category
Dangerous Code Execution
Confidence
70% confidence
Finding

subprocess module calls execute external commands. Without careful input validation, this enables command injection.

Content

Scanner excerpt · run_nonuse_case.py (reported line 896)May include surrounding context.

python
cmd += ["--risk-out", args.risk_out]

    print("RUN:", " ".join(cmd))
    p = subprocess.run(cmd)
    rc = p.returncode
    if p.returncode != 0:
        if p.returncode == 4:

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

This code includes natural-language user messages in Chinese, and the CLI description/help text also uses Chinese-only wording. Because the file provides no user opt-in, alternative locale selection, or justification that the skill is region-specific, it appears to force a specific language.

Content

No source excerpt is available for this finding.

Unbounded Resource Access

Medium
Category
Excessive Agency
Confidence
75% confidence
Finding

Skill allows unbounded resource consumption (API calls, storage, compute). Without rate limits or quotas, a compromised or misbehaving agent can cause denial-of-service or cost overruns.

Content

Scanner excerpt · run_nonuse_desktop_app.py (reported line 38)May include surrounding context.

python
deadline = time.time() + timeout
    while time.time() < deadline:
        try:
            with urllib.request.urlopen(url, timeout=0.8) as r:
                body = r.read().decode("utf-8", errors="ignore")
                if '"ok": true' in body:
                    return True

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

The runtime logging and error/reporting messages shown or surfaced during operation are written only in Chinese. Without an explicit language choice or documented regional scope, this is a natural-language policy concern under the locale requirement.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
97% confidence
Finding

The ArgumentParser description, window title default, and help text are all specified in Chinese. This effectively enforces a single locale in the user experience without opt-in or a stated justification.

Content

No source excerpt is available for this finding.

Unsafe Defaults

Medium
Category
Tool Misuse
Confidence
94% confidence
Finding

The unsafe default is real because WEBUI_REQUIRE_AUTH is initialized False, and the application exposes privileged local automation features over HTTP. In this skill context, those features can trigger document generation, browse local filesystem locations via native pickers, and open arbitrary paths, so an unauthenticated local HTTP interface meaningfully expands attack surface.

Content

Scanner excerpt · run_nonuse_webui.py (reported line 41)May include surrounding context.

python
UI_CONFIRM_RETURN_CODE = 5
DEFAULT_OUTPUT_FORMATS = "docx"
WEBUI_AUTH_TOKEN = ""
WEBUI_REQUIRE_AUTH = False
WEBUI_RUN_ID = f"webui_{uuid.uuid4().hex[:8]}"
WEBUI_LOGGER = setup_logger(__name__, log_dir=(BASE_DIR / "logs"))

Static analysis

No suspicious patterns detected.