Back to skill

Security audit

Bailian Usage Proxy

Security checks for vulnerabilities and agentic risk

Overview

The skill’s purpose is coherent, but its implementation exposes powerful admin and credential functions without enough protection for a shared paid API proxy.

Treat this as a review-required service, not a plug-and-play skill. Before installing, add authentication and authorization to all admin endpoints, never expose admin routes or databases to untrusted networks, avoid local plaintext .env secrets where possible, hash or otherwise protect user API keys, remove default database credentials, and upgrade or lock dependencies with hashes.

Vulnerability Patterns
  • Unauthorized Access and Privilege EscalationObtains permissions beyond the task's legitimate needs
  • 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 (6)

T05 · Unauthorized Access and Privilege Escalation

Error
Location
app/api.py:111
Finding

Unauthenticated Administrative API Exposes and Issues Reusable API Keys

Content
View full analysis
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Error
Location
app/proxy.py:41
Finding

Non-Atomic and Incomplete Quota Enforcement Allows Cost-Control Bypass

Content
View full analysis
= user.daily_limit: raise HTTPException( status_code=status.HTTP_429_TOO_MANY_REQUESTS, detail=f"Daily limit exceeded: {daily_usage}/{user.daily_limit} tokens" ) ``` Streaming usage is estimated after the provider request completes: ```python # 解析用量(简化版,实际需要解析SSE格式) response_text = b"".join(full_response).decode('utf-8') # TODO: 准确解析token用量 # 估算token数(粗略估计) input_text = request_data.get("messages", [{}])[0].get("content", "") input_tokens = len(input_text) // 4 # 粗略估计 output_tokens = len(response_text) // 4 ``` The model defines a monthly limit, but the forwarding code never checks it: ```python class UserCreate(BaseModel): """创建用户请求""" name: str = Field(..., min_length=1, max_length=100, description="用户名称") department: Optional[str] = Field(None, max_length=100, description="部门") daily_limit: int = Field(default=1000000, ge=0, description="日限额") monthly_limit: int = Field(default=10000000, ge=0, description="月限额") ``` ### Technical Analysis Quota enforcement performs a read of existing usage before forwarding and writes actual usage only after the provider response completes. These operations are not enclosed in a transaction, lock, or atomic reservation mechanism. Multiple concurrent requests can therefore all observe usage below the limit and proceed. Each request may independently consume a large number of tokens, allowing total usage to substantially exceed the intended daily quota. Additional accounting weaknesses include: - `monthly_limit` is stored but never enforced. ...[truncated 1559 chars]
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Error
Location
app/models.py:17
Finding

Reusable API Keys Are Stored, Queried, and Printed in Plaintext

Content
View full analysis
Optional[User]: """通过API Key获取用户""" async with self.get_session() as session: result = await session.execute( select(User).where(User.api_key == api_key, User.is_active == 1) ) return result.scalar_one_or_none() ``` The startup script prints a high-quota credential: ```python if not users: print("创建默认管理员用户...") user = User( id=f"admin_{uuid.uuid4().hex[:8]}", name="管理员", department="IT", api_key=f"bl-admin-{uuid.uuid4().hex}", daily_limit=10000000, monthly_limit=100000000 ) await db.create_user(user) print(f"管理员 API Key: {user.api_key}") ``` ### Technical Analysis API keys are bearer credentials: possession is sufficient for authentication. Storing their complete value means that any read access to the application database, database backups, snapshots, or exported data immediately discloses every active credential. Printing the initial high-quota credential also exposes it to terminal capture, deployment logs, CI/CD logs, shell-session recording, an ...[truncated 1030 chars]
Remediation
View remediation

T08 · Insecure Dependencies

Warning
Location
start.sh:16
Finding

Startup Scripts Install Unconstrained Dependencies from the Active Package Index

Content
View full analysis
/dev/null ``` ### Technical Analysis The repository contains a version-pinned `requirements.txt`, but both startup scripts bypass it and request package names without version constraints or integrity hashes. The installed artifacts therefore depend on the package index state at deployment time. This creates several risks: - A newly compromised or malicious package release may be selected. - A malicious package can be supplied through an attacker-controlled pip index or mirror. - Future incompatible versions may silently alter security behavior. - Installation is not reproducible or auditable. - The scripts suppress useful installation output, especially in daemon mode. No specific dependency in the reviewed repository was confirmed to be malicious. The vulnerability is the unsafe installation mechanism. ### Attack Path 1. An operator invokes `start.sh` or `start_daemon.sh`. 2. The script executes `pip install` against the environment's configured package index. 3. Dependency versions are resolved at that moment without a lock file or required hashes. 4. If the index, mirror, DNS path, account, or selected package release is compromised, attacker-controlled package code is installed. 5. The package code executes during installation or when imported by the application. 6. It runs with the privileges of the account that launched the startup script and can access the Bailian key, database credentials, and application da ...[truncated 402 chars]
Remediation
View remediation

T05 · Unauthorized Access and Privilege Escalation

Error
Location
docker-compose.yml:27
Finding

Docker Deployment Publishes MySQL and Unauthenticated Redis with Unsafe Defaults

Content
View full analysis
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Warning
Location
app/config.py:17
Finding

Network-Wide Default Binding Exposes Administrative Routes

Content
View full analysis
Remediation
View remediation
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Tool MisuseTool Parameter Abuse, Chaining Abuse, Unsafe Defaults
Findings (60)

Known Vulnerable Dependency: python-jose==3.3.0 — 5 advisory(ies): CVE-2024-33663 (python-jose algorithm confusion with OpenSSH ECDSA keys); CVE-2024-33664 (python-jose denial of service via compressed JWE content); CVE-2024-33663 (python-jose through 3.3.0 has algorithm confusion with OpenSSH ECDSA keys and ot) +2 more

Critical
Category
Supply Chain
Confidence
98% confidence
Finding

python-jose 3.3.0 is affected by multiple serious advisories including algorithm confusion and denial-of-service issues. For a multi-user proxy service that likely relies on JWTs for authentication and quota attribution, weaknesses in token verification can enable account bypass, impersonation, or service disruption.

Content

No source excerpt is available for this finding.

Known Vulnerable Dependency: jinja2==3.1.3 — 8 advisory(ies): CVE-2025-27516 (Jinja2 vulnerable to sandbox breakout through attr filter selecting format metho); CVE-2024-56201 (Jinja has a sandbox breakout through malicious filenames); CVE-2024-34064 (Jinja vulnerable to HTML attribute injection when passing user input as keys to ) +5 more

Critical
Category
Supply Chain
Confidence
94% confidence
Finding

Jinja2 3.1.3 is flagged for multiple sandbox breakout and injection-related issues. In a service that may generate admin dashboards, reports, or export views for usage statistics, template vulnerabilities can become dangerous if any user-controlled data influences template names, filters, or rendering context in unsafe ways.

Content

No source excerpt is available for this finding.

Credential Access

High
Category
Privilege Escalation
Confidence
84% confidence
Finding

The documentation tells users to create a .env file as part of setup, which is a common and convenient pattern but also a frequent source of credential leakage when files are committed or copied between systems. In this skill's context—a proxy for a shared LLM account—the exposed key could grant broad access to the upstream Bailian account and undermine usage segregation and quota controls.

Content

Scanner excerpt · README.md (reported line 13)May include surrounding context.

md
cd skills/bailian-usage-proxy

# 配置环境变量
cp .env.example .env
# 编辑 .env 填入你的阿里百炼 API Key

# 启动服务

Credential Access

High
Category
Privilege Escalation
Confidence
92% confidence
Finding

The README specifically instructs the user to edit .env and paste in the Bailian API key, directly encouraging storage of a sensitive credential in plaintext without any accompanying warning. If that file is leaked, an attacker could use the shared upstream account for unauthorized model access, consume quotas, incur cost, and potentially access usage patterns tied to multiple users.

Content

Scanner excerpt · README.md (reported line 14)May include surrounding context.

md
# 配置环境变量
cp .env.example .env
# 编辑 .env 填入你的阿里百炼 API Key

# 启动服务
./start.sh

Tp4

High
Category
MCP Tool Poisoning
Confidence
95% confidence
Finding

The declared purpose is a usage-statistics proxy, but the described and inferred behavior includes user creation, API key issuance, request-header-based authentication, sensitive admin reporting, and an OpenAI-compatible proxy layer. This mismatch is dangerous because operators may deploy it under weaker assumptions while unintentionally exposing privileged management and authentication surfaces not clearly disclosed in the skill description.

Content

No source excerpt is available for this finding.

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

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

pip install -r requirements.txt

配置环境变量

cp .env.example .env

编辑 .env 填入阿里百炼主账号 Key 和数据库配置

text

Credential Access

High
Category
Privilege Escalation
Confidence
91% confidence
Finding

This line explicitly instructs operators to place the primary Alibaba Bailian account key into a .env file. In context, that is a sensitive upstream credential for a shared proxy service; if mishandled, leaked, or reused across environments, an attacker could consume paid API resources, access usage data, and operate the proxy as a trusted upstream client.

Content

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

配置环境变量

cp .env.example .env

编辑 .env 填入阿里百炼主账号 Key 和数据库配置

text

### 2. 数据库初始化

Context-Inappropriate Capability

High
Category
Not specified by scanner
Confidence
99% confidence
Finding

The administrative endpoints appear entirely unauthenticated: create_user, list_users, get_user, usage reports, and health all lack any admin auth dependency. This allows arbitrary callers to create users, enumerate users, retrieve usage data, and access organization-wide reporting, resulting in unauthorized credential issuance, privacy leakage, and abuse of shared upstream model resources.

Content

No source excerpt is available for this finding.

Known Vulnerable Dependency: fastapi==0.109.0 — 1 advisory(ies): CVE-2024-24762 (FastAPI is a web framework for building APIs with Python 3.8+ based on standard )

High
Category
Supply Chain
Confidence
85% confidence
Finding

Pinning FastAPI to 0.109.0 includes a version with a known security advisory (CVE-2024-24762). In a proxy service that exposes HTTP APIs for shared model-account usage tracking, a vulnerable web framework can increase exposure because it is directly internet- or intranet-facing and processes untrusted requests.

Content

No source excerpt is available for this finding.

Known Vulnerable Dependency: aiomysql==0.2.0 — 2 advisory(ies): CVE-2025-62611 (aiomysql allows arbitrary access to client files through vulnerability of a mali); CVE-2025-62611 (aiomysql allows arbitrary access to client files through vulnerability of a mali)

High
Category
Supply Chain
Confidence
82% confidence
Finding

Pinning aiomysql to 0.2.0 retains a version reported as vulnerable to arbitrary client file access via a malicious server. This skill is a usage-proxy service that connects to infrastructure components and may handle credentials and local configuration, so a database client flaw could expose sensitive files from the host if an attacker can influence the MySQL endpoint or traffic.

Content

No source excerpt is available for this finding.

Tool Parameter Abuse

High
Category
Tool Misuse
Confidence
80% confidence
Finding

The documentation exposes a destructive administrative endpoint for deleting users but does not describe any authorization constraints, role separation, confirmation requirements, or audit controls. In a multi-user quota-management proxy, insufficiently protected delete operations could allow unauthorized or accidental account removal, disrupting access and corrupting usage/accounting data.

Content

Scanner excerpt · references/api.md (reported line 99)May include surrounding context.

删除用户

text
DELETE /admin/users/{user_key}

用量查询

Known Vulnerable Dependency: fastapi==0.109.0 — 1 advisory(ies): CVE-2024-24762 (FastAPI is a web framework for building APIs with Python 3.8+ based on standard )

High
Category
Supply Chain
Confidence
95% confidence
Finding

Pinning FastAPI to 0.109.0 leaves the service exposed to a known vulnerable dependency per the cited advisory. Because this skill is an internet-facing API proxy for shared LLM usage accounting, framework-layer flaws can directly affect request handling, availability, and possibly security boundaries.

Content

No source excerpt is available for this finding.

Possible Typosquatting: 'uvicorn' resembles popular package 'gunicorn'

High
Category
Supply Chain
Confidence
70% confidence
Finding

Package name closely resembles a popular package, suggesting possible typosquatting. Attackers publish malicious packages with similar names to trick developers into installing them.

Content

No source excerpt is available for this finding.

Possible Typosquatting: 'uvicorn' resembles popular package 'gunicorn'

High
Category
Supply Chain
Confidence
70% confidence
Finding

Package name closely resembles a popular package, suggesting possible typosquatting. Attackers publish malicious packages with similar names to trick developers into installing them.

Content

No source excerpt is available for this finding.

Known Vulnerable Dependency: aiomysql==0.2.0 — 2 advisory(ies): CVE-2025-62611 (aiomysql allows arbitrary access to client files through vulnerability of a mali); CVE-2025-62611 (aiomysql allows arbitrary access to client files through vulnerability of a mali)

High
Category
Supply Chain
Confidence
91% confidence
Finding

aiomysql 0.2.0 is flagged for a vulnerability that may allow arbitrary access to client files under malicious server interaction. In a proxy service that likely connects to a backend MySQL instance for metering and quota data, this can become serious if database endpoints are compromised, spoofed, or attacker-controlled.

Content

No source excerpt is available for this finding.

Known Vulnerable Dependency: python-multipart==0.0.6 — 16 advisory(ies): CVE-2024-24762 (python-multipart vulnerable to Content-Type Header ReDoS); CVE-2024-53981 (Denial of service (DoS) via deformation `multipart/form-data` boundary); CVE-2026-53539 (python-multipart: Quadratic-time querystring parsing with semicolon separators c) +13 more

High
Category
Supply Chain
Confidence
97% confidence
Finding

python-multipart 0.0.6 has numerous advisories including ReDoS and malformed multipart parsing denial-of-service issues. Since this service uses FastAPI and may accept uploads or form-based admin requests, an attacker could exploit request parsing to exhaust CPU or memory and take the proxy offline.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
88% confidence
Finding

The README explicitly instructs users to copy a template into a local .env file and place a production API key there, but provides no guidance on secret handling, file permissions, git exclusion, or rotation. This increases the likelihood of accidental credential exposure through source control commits, backups, shell history, or insecure sharing in a multi-user setup.

Content

No source excerpt is available for this finding.

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
84% confidence
Finding

The skill documentation describes deployment and operation steps that inherently require environment access, file writes, and network connectivity, but it does not declare any tool scope or permissions boundaries. In an agent setting, missing scope declarations can cause over-broad execution privileges and reduce a reviewer's ability to assess whether the skill's actual capabilities are limited to the stated purpose.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
88% confidence
Finding

The instructions tell users to place a primary Alibaba Bailian account key into a local .env file without any explicit warning about secret handling, storage protections, rotation, or least-privilege usage. Because this is the master credential for a shared-account proxy, compromise could expose all upstream API usage, billing, and downstream impersonation through the proxy.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

The chat completion endpoint forwards the request payload to proxy.forward_request, which is a network transmission of user-supplied data to another service. This file includes no confirmation prompt, logging/print disclosure, or explanatory warning in comments/docstrings that user prompts and related data are being relayed upstream.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The file exposes administrative capabilities beyond simple usage proxying, including creation of users and issuance of API keys. In a shared-account usage tracking service, this materially expands the attack surface because anyone who can reach these endpoints can provision identities and credentials, enabling unauthorized use of the upstream LLM service and undermining quota/accountability controls.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
85% confidence
Finding

This code file defines administrative routes that create users and return detailed user identity and usage data, but the file contains no visible warning, comment, or docstring disclosing that these endpoints handle potentially sensitive account and activity information. Under the code-file criteria, sensitive operations should have some form of user disclosure unless clearly covered elsewhere in the skill description, which is not present in this file.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
83% confidence
Finding

The human-readable text in the module docstring and comments is entirely in Chinese, which can constitute a language/locale policy violation when no opt-in or justification is provided. There is no indication that the skill is region-specific or that users may choose another language.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
88% confidence
Finding

This code file uses Chinese-only natural-language descriptions in the module docstring and class docstring/comments, which indicates a fixed language/locale choice. Under the policy, forcing a specific language without user opt-in or documented justification is a natural-language policy violation.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

The user-facing Pydantic response model includes the raw api_key field, which can cause credentials to be returned by API endpoints, logged by clients, or exposed in generated API schemas. In this skill’s context—a shared-account usage proxy handling model API quotas and per-user attribution—exposing API keys directly could let one user impersonate another, consume quota, and access or manipulate usage on their behalf.

Content

No source excerpt is available for this finding.