Back to skill

Security audit

threatbook-skills

Security checks for vulnerabilities and agentic risk

Overview

The skill is a coherent ThreatBook threat-intelligence integration, but it needs review because it can upload local files to a third party and one script exposes the API key through command-line and URL parameters.

Install only if you are comfortable sending selected file contents, hashes, domains, and IPs to ThreatBook. Avoid using the IP reputation script as written with a real API key unless it is fixed to read THREATBOOK_API_KEY and avoid placing the key in URLs; rotate any key previously used through --api_key.

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

Warning
Location
scripts/ip_reputation.py:43
Finding

ThreatBook API Key Exposed Through Command-Line Arguments and URL Query Parameters

Content
View full analysis

Vulnerability Details

File Location: scripts/ip_reputation.py, lines 43–47 and 89–98
Vulnerability Type: API credential exposure
Risk Level: Medium

Vulnerable Code

python
# Build request
url = "https://api.threatbook.cn/v3/scene/ip_reputation"
params = {
    "apikey": api_key,
    "resource": ip
}
python
parser.add_argument(
    "--api_key",
    required=True,
    help="ThreatBook API Key"
)

args = parser.parse_args()

try:
    result = get_ip_reputation(args.ip, args.api_key)

Technical Analysis

The script requires users to provide the ThreatBook API key as a command-line argument. Command-line secrets may be exposed through shell history, process inspection interfaces, endpoint monitoring, audit records, CI/CD output, and job-runner logs.

The script then places the same credential in the query parameters of an HTTP GET request. Although the destination uses HTTPS, TLS only protects the request in transit. The complete URL may still be recorded by client diagnostics, proxies, API gateways, monitoring products, or server access logs.

This implementation is also inconsistent with the rest of the project and with SKILL.md, which designate the THREATBOOK_API_KEY environment variable as the credential source.

Attack Path

  1. A user invokes the script and supplies the key through --api_key.
  2. The command, including the plaintext key, is retained in shell history or captured by local process-monitoring or job-logging systems.
  3. The script inserts the key into the request URL as the apikey query parameter.
  4. Infrastructure capable of recording request URLs may retain another copy of the credential.
  5. A local user or log reader with access to one of these records extracts the key.
  6. The attacker reuses the key against ThreatBook APIs until it is revoked or expires.

Impact Assessment

Successful exploitation exposes the privileges associated with the compromised ThreatBook API key. An attacker may make ...[truncated 379 chars]

Remediation
View remediation

Remediation Suggestions

  1. Remove the --api_key command-line option.
  2. Read the credential from THREATBOOK_API_KEY, consistently with the other scripts and project metadata:
python
api_key = os.getenv("THREATBOOK_API_KEY")
if not api_key:
    raise ValueError("THREATBOOK_API_KEY is not configured")
  1. If supported by the ThreatBook endpoint, transmit the key through an authorization header rather than a query parameter:
python
headers = {
    "Authorization": api_key
}
params = {
    "resource": ip
}
response = requests.get(url, headers=headers, params=params, timeout=30)
  1. If the API mandates a query parameter, configure clients, proxies, gateways, monitoring systems, and error handlers to redact apikey values and avoid logging complete request URLs.
  2. Prevent secrets from appearing in exception messages, debug output, telemetry, and CI/CD logs.
  3. Revoke and rotate any API keys that may already have been supplied through this command-line interface.
  4. Add automated tests verifying that credentials are not accepted through command-line arguments and do not appear in generated URLs or logs.
  5. Update usage documentation so that configuration exclusively references the environment variable.
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • Taint TrackingDirect Taint Flow, Variable-Mediated Taint Flow, Credential Exfiltration Chain
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
Findings (23)

Tainted flow: 'headers' from os.getenv (line 40, credential/environment) → requests.get (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/dns_compromise.py (reported line 49)May include surrounding context.

python
try:
        # 发起请求
        response = requests.get(
            url,
            headers=headers,
            params=params,

Tainted flow: 'headers' from os.getenv (line 43, credential/environment) → requests.get (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/file_multiengines.py (reported line 52)May include surrounding context.

python
try:
        # 发起请求
        response = requests.get(
            url,
            headers=headers,
            params=params,

Tainted flow: 'headers' from os.getenv (line 43, credential/environment) → requests.get (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/file_report.py (reported line 52)May include surrounding context.

python
try:
        # 发起请求
        response = requests.get(
            url,
            headers=headers,
            params=params,

Tainted flow: 'headers' from os.getenv (line 43, credential/environment) → requests.post (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/file_upload.py (reported line 55)May include surrounding context.

python
}
            
            # 发起请求
            response = requests.post(
                url,
                headers=headers,
                files=files,

Tp4

High
Category
MCP Tool Poisoning
Confidence
97% confidence
Finding

该描述是一个较宽泛的多能力技能说明,但当前提供的代码块只实现了“失陷检测”中的一个具体场景:调用微步在线 v3/scene/dns 接口,检测域名或IP是否存在失陷风险。它没有实现文件上传、文件哈希/信誉查询、多引擎检测等声明中的其他核心能力,因此描述与实际代码行为不完全一致。虽然代码支持对IP进行检测,和声明中的‘失陷检测能力’部分一致,但其本质是针对域名/IP的失陷场景查询,而不是完整覆盖所声明的全部功能,因此应判定为描述与代码存在不匹配。

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
97% confidence
Finding

代码行为与声明存在范围不一致。实际代码只支持“文件多引擎检测”这一项能力:读取环境变量中的 ThreatBook API Key,校验传入的 MD5/SHA1/SHA256 哈希,向微步在线文件多引擎报告接口发起 GET 请求,并输出检测结果。声明则描述了更广泛的功能集合,包括文件上传分析、文件信誉查询、IP信誉查询和失陷检测,但这些能力在提供的代码片段中均未体现。未发现额外未声明的敏感能力;问题在于描述显著高估了该代码片段的实际功能覆盖范围。

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
96% confidence
Finding

声明描述的是一个覆盖多类威胁情报能力的综合技能,但提供的代码片段只实现了“文件信誉查询”这一子能力,且具体是按文件哈希查询报告。没有看到文件上传、IP 查询、主机失陷检测或多引擎检测相关逻辑。因此,代码实际行为明显窄于声明范围,描述不能准确代表该代码块的实际功能。虽然已实现的部分属于声明中的一项能力,但整体上存在显著能力不匹配。

Content

No source excerpt is available for this finding.

Missing User Warnings

High
Category
Not specified by scanner
Confidence
97% confidence
Finding

The skill advertises file upload analysis but does not clearly warn that the file contents will be transmitted to an external third-party service. In a security workflow, users may upload proprietary binaries, internal documents, or malware samples containing sensitive data; silent external transmission creates substantial confidentiality, compliance, and legal risk.

Content

No source excerpt is available for this finding.

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
94% confidence
Finding

The skill requires environment credentials and clearly instructs users to run scripts that call external APIs, but it does not declare any explicit tool scope such as permissions or allowed-tools. This weakens policy enforcement and reviewability, making it easier for a skill to access secrets and use network capabilities without transparent constraints.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
88% confidence
Finding

The trigger conditions are broad enough that an agent could invoke the skill for many loosely related security-analysis requests without clear user consent boundaries. In this skill's context, that matters because invocation may lead to outbound API calls and file submission to a third party, increasing the chance of over-collection or unintended data disclosure.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

This Python file contains its docstring, CLI description, help text, and runtime output entirely in Chinese. The policy for natural-language content requires avoiding a forced language unless the skill explicitly offers user choice or clearly documents a justified locale restriction, which this file does not do.

Content

No source excerpt is available for this finding.

External Transmission

Medium
Category
Data Exfiltration
Confidence
60% 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 · scripts/dns_compromise.py (reported line 39)May include surrounding context.

python
raise ValueError("域名或IP地址不能为空")
    
    # 构建请求
    url = "https://api.threatbook.cn/v3/scene/dns"
    headers = {
        "Authorization": api_key
    }

External Transmission

Medium
Category
Data Exfiltration
Confidence
60% 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 · scripts/file_multiengines.py (reported line 42)May include surrounding context.

python
raise ValueError("域名或IP地址不能为空")
    
    # 构建请求
    url = "https://api.threatbook.cn/v3/scene/dns"
    headers = {
        "Authorization": api_key
    }

External Transmission

Medium
Category
Data Exfiltration
Confidence
60% 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 · scripts/file_report.py (reported line 42)May include surrounding context.

python
raise ValueError("域名或IP地址不能为空")
    
    # 构建请求
    url = "https://api.threatbook.cn/v3/scene/dns"
    headers = {
        "Authorization": api_key
    }

External Transmission

Medium
Category
Data Exfiltration
Confidence
60% 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 · scripts/ip_reputation.py (reported line 44)May include surrounding context.

python
raise ValueError("域名或IP地址不能为空")
    
    # 构建请求
    url = "https://api.threatbook.cn/v3/scene/dns"
    headers = {
        "Authorization": api_key
    }

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The script's docstrings, CLI description, help text, status output, and error messages are all hard-coded in Chinese. This constitutes a locale/language policy issue because the skill does not provide any user opt-in, fallback, or documented justification for restricting interaction to Chinese.

Content

No source excerpt is available for this finding.

External Transmission

Medium
Category
Data Exfiltration
Confidence
90% confidence
Finding

The script performs external transmission of a local file to a remote service at api.threatbook.cn. In the context of a threat-intelligence upload skill, that behavior is expected, but it still carries real confidentiality and compliance risk because file contents leave the local environment and are sent to a third party.

Content

Scanner excerpt · scripts/file_upload.py (reported line 42)May include surrounding context.

python
raise ValueError(f"路径不是文件: {file_path}")
    
    # 构建请求
    url = "https://api.threatbook.cn/v3/file/upload"
    headers = {
        "Authorization": api_key
    }

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

This script transmits an arbitrary local file to a third-party cloud service for analysis, but the code does not present an explicit privacy or data-handling warning at execution time. In a security tooling context, users may upload sensitive, proprietary, or regulated material assuming only local analysis, so the lack of an explicit transmission notice increases the chance of unintended data disclosure.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The script accepts the API key via a command-line argument, which can expose the secret through shell history, process listings, job control logs, or orchestration telemetry. In a security tooling context, leaking a threat intelligence API key can enable unauthorized API use, quota exhaustion, and possible access to account-scoped data.

Content

No source excerpt is available for this finding.

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
83% confidence
Finding

The script sends the user-supplied file hash and API credential to an external third-party service, but the CLI flow does not provide an explicit user-facing notice or consent point at execution time. In threat-intelligence workflows, hashes can still be sensitive metadata because they may reveal what files an organization is investigating or possesses.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
92% confidence
Finding

The file-level description and all user-facing strings are written only in Chinese, and the script does not offer any language or locale selection. Under the stated policy, forcing a specific language without user opt-in is a natural-language policy violation unless the locale restriction is clearly justified.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
84% confidence
Finding

The docstring and user-facing help text are presented in Chinese, which effectively forces a specific language for understanding and operation. Under the stated policy, language-specific behavior should offer user choice or clearly justify the locale restriction.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
83% confidence
Finding

The file's docstrings, argument descriptions, and output messages are entirely in Chinese, which imposes a specific language on users without any opt-in or documented locale constraint. Under the language/locale policy, this is a natural-language policy issue unless the skill is explicitly documented as region- or language-specific.

Content

No source excerpt is available for this finding.

Static analysis

No suspicious patterns detected.