Back to skill

Security audit

国家法律法规知识库检索

Security checks for vulnerabilities and agentic risk

Overview

This legal lookup skill does what it says, but it sends potentially sensitive legal questions to an external API using an exposed built-in bearer token and triggers too broadly for general legal consultation.

Review before installing. Use only for queries you are comfortable sending to the Orientlaw-hosted search API, avoid including names or confidential case details, and require the publisher to remove and rotate the embedded bearer token and document external data handling.

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/search_knowledge.py:34
Finding
Hard-Coded API Bearer Credential## Vulnerability Details **File Location**: `scripts/search_knowledge.py`, lines 34–38 **Vulnerability Type**: Hard-coded authentication secret **Risk Level**: High ### Vulnerable Code ```python url = "https://chat2.orientlaw.cn/api/v1/embedding/search" headers = { "Authorization": "Bearer akmHjUkJfrqhLE2v3dXBN9YCM896kL5y", "Content-Type": "application/json" } ``` ### Technical Analysis The source code contains a bearer credential used to authenticate requests to the remote legal knowledge API. Any person with access to the project package or source repository can extract this credential without authorization or specialized tooling. A bearer token grants access based solely on possession. Because the secret is distributed with the Skill, the API cannot reliably distinguish legitimate Skill requests from requests made directly by a party who copied the credential. The token also cannot be rotated independently of the deployed source unless external configuration is introduced. ### Attack Path 1. An attacker downloads the Skill package or obtains read access to its source. 2. The attacker opens `scripts/search_knowledge.py` and copies the bearer token from the `Authorization` header. 3. The attacker constructs requests to `https://chat2.orientlaw.cn/api/v1/embedding/search` using the copied header. 4. The attacker submits arbitrary authenticated queries without invoking the Skill. 5. The attacker consumes API resources or exercises any other capabilities granted to that token until it is revoked or expires. ### Impact Assessment Successful exploitation provides unauthorized access to the remote API under the identity and permissions associated with the embedded token. This can enable quota consumption, service or billing abuse, resource exhaustion, and loss of attribution between authorized and unauthorized callers. The demonstrated scope is authenticated access to the configured embedding-search endpoint. Access to additional endpoints or data ...[truncated 105 chars]
Remediation
## Remediation Suggestions 1. Revoke and rotate the exposed bearer token immediately. 2. Remove the credential from source code and repository history. 3. Load the credential at runtime from an environment variable or managed secret store, and terminate safely when it is unavailable. 4. Use short-lived, narrowly scoped credentials dedicated to this endpoint rather than a shared static token. 5. Assign separate credentials to different users, deployments, or service identities to preserve attribution and permit selective revocation. 6. Enforce server-side authorization, request quotas, and rate limits independently of client behavior. 7. Audit historical API activity for unauthorized use of the exposed token. 8. Add automated secret scanning to development and release pipelines to prevent recurrence. A safer configuration pattern is: ```python import os api_token = os.environ.get("ORIENTLAW_API_TOKEN") if not api_token: return { "success": False, "error": "API credential is not configured" } headers = { "Authorization": f"Bearer {api_token}", "Content-Type": "application/json" } ```
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
Findings (8)

Lp3

Medium
Category
MCP Least Privilege
Confidence
89% confidence
Finding
The skill declares a Python dependency on requests and explicitly instructs execution of a retrieval script that calls an external vector-search API, but it does not declare any tool scope, permissions, or allowed-tools boundary. This creates an undeclared network capability that can be invoked without clear governance, making data exfiltration, unintended external requests, or policy bypass harder to detect and control.

Vague Triggers

Medium
Confidence
93% confidence
Finding
The top-level description says the skill should be used whenever the user needs legal consultation, legal Q&A, or law-related help, which is broad enough to capture general conversation rather than narrowly scoped statute lookup. Overbroad triggers can cause unintended invocation of a networked retrieval skill, exposing user legal queries to external systems and bypassing more appropriate general-purpose or privacy-preserving handling.

Vague Triggers

Medium
Confidence
95% confidence
Finding
The activation condition states the skill triggers for legal questions, specific article lookups, regulation searches, and legal consultation or Q&A, but it lacks concrete scope limits and disambiguation rules. In context, this is more dangerous because the skill also directs execution of a network-backed search script, so ambiguous activation can unnecessarily send sensitive user legal issues to an external knowledge service.

Natural-Language Policy Violations

Medium
Confidence
88% confidence
Finding
The file title and all required response templates are written as mandatory Chinese output guidance, and the document repeatedly uses prescriptive language such as '强制使用' for display format. There is no indication that users may choose another language or locale, which can violate language/locale policy requirements when no opt-in is provided.

Context-Inappropriate Capability

Medium
Confidence
99% confidence
Finding
The script hardcodes a bearer token directly in source code, which is a real secret-management vulnerability. Anyone with access to the skill package, logs, or repository can extract and reuse the credential to query the remote API, potentially causing unauthorized access, abuse, billing impact, or downstream compromise of the associated service account.

External Transmission

Medium
Category
Data Exfiltration
Content
try:
        # 发起POST请求
        response = requests.post(
            url,
            headers=headers,
            json=payload,
Confidence
80% confidence
Finding
Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.

Missing User Warnings

Medium
Confidence
87% confidence
Finding
The tool sends raw user queries to an external third-party endpoint without any disclosure or consent mechanism at the point of use. Because legal queries can contain highly sensitive personal, employment, criminal, or contractual information, this creates a privacy and data-governance risk even if the transmission is functionally necessary for the skill.

Natural-Language Policy Violations

Low
Confidence
75% confidence
Finding
All natural-language descriptions, help text, and error messages in the script are presented only in Chinese, with no indication that users may choose another language. Under the stated policy, forcing a specific language without user opt-in can be a natural-language policy violation unless the locale restriction is explicitly justified.

Static analysis

No suspicious patterns detected.