Back to skill

Security audit

Tianapi Barcode - 商品条形码查询

Security checks for vulnerabilities and agentic risk

Overview

This barcode lookup skill has a legitimate purpose, but it handles API keys unsafely and can print a key-bearing image URL.

Review before installing. Use only a dedicated TianAPI key with limited scope or quota, avoid passing the key on the command line, do not commit any .env file, and treat any printed image URL as sensitive because it may include the API key. The script should be fixed before use because it is currently syntactically invalid and inconsistent about the expected environment variable name.

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/fetch_barcode.py:94
Finding

API Key Disclosed Through an Unvalidated Image URL

Content
View full analysis
`. 4. The authenticated URL is printed into the terminal or agent output. 5. A user, browser, image renderer, crawler, or other automated component opens the URL. 6. The attacker receiv ...[truncated 707 chars]
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/fetch_barcode.py:21
Finding

API Key Exposed Through Command-Line Arguments

Content
View full analysis
--barcode 6976586902578 ``` The script also prints a command-line credential example when no key is available: ```python print("1. 命令行: python fetch_barcode.py YOUR_KEY --barcode 6976586902578") ``` ### Technical Analysis The implementation accepts the TianAPI key as a positional command-line argument, and the Skill documentation encourages users to place the credential directly in command invocations. Command-line arguments are not an appropriate secret transport mechanism. Depending on the host environment, they may be observable through process inspection utilities, process accounting, shell history, CI/CD logs, endpoint telemetry, debugging output, or AI-agent tool transcripts. The documentation is also inconsistent with the implementation: it shows a `--key` option, but the parser only defines a positional `key` argument. In addition, `SKILL.md` declares `TIANAPI_BARCODE_KEY`, while the script reads `TIANAPI_KEY`. This mismatch may cause users to fall back to the less secure command-line method. ### Attack Path 1. A user follows the Skill documentation and includes the TianAPI key in the command line. 2. The shell records the invocation in history, an agent records it in a tool transcript, or another local process observes the process argument list while the command runs. 3. An attacker or lower-privileged local user reads the exposed command. 4. The attacker extracts the API key ...[truncated 737 chars]
Remediation
View remediation
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
Findings (10)

Credential Access

High
Category
Privilege Escalation
Confidence
96% confidence
Finding

The skill instructs users to store the API key in a local .env file under the scripts directory, and nearby examples also encourage direct secret handling patterns. Without explicit guidance on file permissions, git exclusion, and safer secret-loading practices, this creates a realistic risk of accidental credential disclosure through source control, backups, or unintended file access.

Content

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

md
# 方式一:环境变量(推荐,一次配置永久生效)
    export TIANAPI_BARCODE_KEY=你的APIKey

    # 方式二:.env 文件(在脚本目录创建)
    echo "TIANAPI_BARCODE_KEY=你的APIKey" > scripts/.env

    # 方式三:每次命令行传入

Credential Access

High
Category
Privilege Escalation
Confidence
98% confidence
Finding

The documentation explicitly shows passing the API key on the command line, which can leak credentials via shell history, process listings, audit logs, or screenshots. This is a stronger and more immediate secret-exposure risk than environment-variable usage because many systems expose argv contents to other local users or tooling.

Content

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

md
export TIANAPI_BARCODE_KEY=你的APIKey

    # 方式二:.env 文件(在脚本目录创建)
    echo "TIANAPI_BARCODE_KEY=你的APIKey" > scripts/.env

    # 方式三:每次命令行传入
    python3 scripts/fetch_barcode.py --key 你的APIKey --barcode 6976586902578

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 · scripts/fetch_barcode.py (reported line 33)May include surrounding context.

python
return env_key
    
    # 检查项目根目录的.env文件
    dotenv_path = os.path.join(os.path.dirname(__file__), '.env')
    if os.path.exists(dotenv_path):
        with open(dotenv_path, 'r') as f:
            for line in f:

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 · scripts/fetch_barcode.py (reported line 44)May include surrounding context.

python
print("请通过以下任一方式配置密钥:", file=sys.stderr)
    print("1. 命令行: python fetch_barcode.py YOUR_KEY --barcode 6976586902578")
    print("2. 环境变量: export TIANAPI_KEY=YOUR_KEY")
    print("3. .env文件: 在脚本同目录创建 .env 写入 TIANAPI_KEY=YOUR_KEY")
    sys.exit(1)<websource>source_group_web_1</websource>

def validate_barcode(barcode):

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
94% confidence
Finding

The skill advertises executable behavior requiring environment access, file reads, and outbound network access, but it does not declare an explicit tool scope such as permissions or allowed-tools. This weakens security boundaries by making the skill's operational capabilities implicit rather than reviewable, increasing the chance that an agent or user invokes it with broader access than expected.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The documentation instructs users to pass an API key via CLI and send barcode queries to a third-party service without warning that command-line arguments may be exposed through shell history or process listings. It also omits a privacy notice that submitted barcodes and related query metadata are transmitted to an external provider, which can surprise users and lead to credential or data exposure.

Content

No source excerpt is available for this finding.

External Transmission

Medium
Category
Data Exfiltration
Confidence
50% 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 · SKILL.md (reported line 61)May include surrounding context.

md
规格: 50克
    商品分类: 营养补充剂
    生产商: 安徽谊康堂健康科技有限公司
    商品图片: https://api.tianapi.com/goodspic/?img=qhUnfmO4bzEH (3小时内有效)

### 直接调用 API(无需脚本)

External Transmission

Medium
Category
Data Exfiltration
Confidence
50% 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 · SKILL.md (reported line 92)May include surrounding context.

md
规格: 50克
    商品分类: 营养补充剂
    生产商: 安徽谊康堂健康科技有限公司
    商品图片: https://api.tianapi.com/goodspic/?img=qhUnfmO4bzEH (3小时内有效)

### 直接调用 API(无需脚本)

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

This Python code makes a network request to a third-party API and includes the user's API key in the request parameters. While the script documents how to supply the credential, it does not clearly warn the user at the point of use that the key and barcode data will be sent to an external service.

Content

No source excerpt is available for this finding.

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
84% confidence
Finding

The script accesses TIANAPI_KEY from the environment and parses a local .env file to retrieve the API credential. Although this is common behavior, the safety rule asks for some form of disclosure when sensitive environment variables or credentials are accessed, and this file lacks a clear warning beyond implementation comments.

Content

No source excerpt is available for this finding.

Static analysis

No suspicious patterns detected.