Back to skill

Security audit

Weather Outfit Advisor

Security checks for vulnerabilities and agentic risk

Overview

This weather-outfit skill is mostly purpose-aligned, but it automatically uses external weather and image services and ships a hardcoded Pexels API key that users should review before installing.

Install only if you are comfortable with your destination, dates, clothing preferences, and image-search terms being sent to external services. The publisher should remove and rotate the embedded Pexels key, require user-provided credentials through secure configuration, and document all third-party data flows before this is treated as low risk.

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/search_images.py:316
Finding

Hardcoded Pexels API Credential Exposed in Source Code

Content
View full analysis

Vulnerability Details

File Location: scripts/search_images.py, lines 316–319
Vulnerability Type: Hardcoded API credential
Risk Level: Medium

Vulnerable Code

python
# 方法 1: 使用 Pexels API(已配置 API key)
pexels_api_key = "D6nVsjiUzdW7BctVWb3Hf8KdmkZ3qF0oZNPAu4labGgxbYsFHegeFNNO"

if pexels_api_key and pexels_api_key != "your_api_key_here":
    result = search_pexels_images(query, pexels_api_key, count)

The credential is subsequently transmitted to the official Pexels endpoint in scripts/search_images.py, lines 124–134:

python
url = f"https://api.pexels.com/v1/search?query={encoded_query}&per_page={count}"

headers = {
    'Authorization': api_key,
    'User-Agent': 'Weather Outfit Advisor / 1.0'
}

req = urllib.request.Request(url, headers=headers)

with urllib.request.urlopen(req, timeout=10) as response:
    data = json.loads(response.read().decode('utf-8'))

Technical Analysis

A live-looking Pexels API credential is embedded directly in distributed source code. Anyone who can download, inspect, or execute the Skill can recover the credential without authentication.

Sending an authorization credential to the intended Pexels HTTPS endpoint is required for authenticated image searches. However, distributing a shared credential in the package is not required and violates least-secret-exposure practices. The key should be supplied at runtime through an environment variable or secret-management facility.

The image-search query is user-controlled and sent to Pexels as a URL query parameter. This transmission is consistent with the declared image-search functionality and does not, by itself, demonstrate malicious exfiltration. The confirmed vulnerability is the public exposure and automatic use of the embedded credential.

Attack Path

  1. An attacker obtains the Skill package or accesses its source repository.
  2. The attacker opens scripts/search_images.py and extracts the credential from line 316.
  3. The attacker sup ...[truncated 1352 chars]
Remediation
View remediation

Remediation Suggestions

  1. Revoke and rotate the exposed credential immediately

    • Treat the current key as compromised.
    • Generate a replacement through the Pexels account console.
    • Review API usage logs for unexpected requests or quota consumption.
  2. Remove credentials from source code

    • Load the key from an environment variable:
python
import os

pexels_api_key = os.environ.get("PEXELS_API_KEY")

if pexels_api_key:
    result = search_pexels_images(query, pexels_api_key, count)
else:
    result = search_bing_images(query, count)
  1. Fail safely when no credential is configured

    • Use the existing manual-search fallback.
    • Return a clear configuration error without printing or logging secret values.
    • Do not ship a default shared production credential.
  2. Use an appropriate secret-management facility

    • For hosted deployments, inject the credential through the platform's secret store.
    • Restrict access to only the process that performs Pexels requests.
    • Avoid storing the key in tracked configuration files, command-line arguments, or generated output.
  3. Clean repository history and distributed artifacts

    • Remove the credential from prior Git revisions with an appropriate history-rewriting tool.
    • Replace previously published packages where feasible.
    • Rotation remains mandatory because history rewriting does not invalidate copied keys.
  4. Add preventive controls

    • Enable secret scanning in version control and CI.
    • Add tests that reject key-like literals in committed source files.
    • Apply provider-side quota limits and usage alerts.
    • Document runtime configuration consistently; SKILL.md mentions environment-variable configuration, but the implementation currently does not use it.
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Behavioral ASTexec() Call, eval() Call, Dynamic Import
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
Findings (24)

Tp4

High
Category
MCP Tool Poisoning
Confidence
93% confidence
Finding

The documented behavior includes external image API usage, image-query generation, and mention of a hardcoded Pexels API key, all of which are materially outside the declared weather-advice scope. In skill ecosystems, hidden or under-declared third-party integrations are high risk because they can exfiltrate user context and embed unmanaged secrets while evading user expectations.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
94% confidence
Finding

The documented behavior includes external image API usage, image-query generation, and mention of a hardcoded Pexels API key, all of which are materially outside the declared weather-advice scope. In skill ecosystems, hidden or under-declared third-party integrations are high risk because they can exfiltrate user context and embed unmanaged secrets while evading user expectations.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
98% confidence
Finding

The documented behavior includes external image API usage, image-query generation, and mention of a hardcoded Pexels API key, all of which are materially outside the declared weather-advice scope. In skill ecosystems, hidden or under-declared third-party integrations are high risk because they can exfiltrate user context and embed unmanaged secrets while evading user expectations.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

The README explicitly advertises real-time weather queries and Pexels image retrieval but does not disclose that user-provided destinations, dates, or search terms may be transmitted to third-party services. This creates a privacy and transparency issue: users may unknowingly share travel plans or preference data with external APIs, which is more sensitive in an assistant/skill context where users may assume local processing.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

Stating that a Pexels API key is 'built in' strongly suggests embedded credentials and, combined with the lack of warning about external-service usage, indicates poor secret-handling practice. Embedded API keys can be extracted and abused by downstream users or attackers, leading to unauthorized API use, quota exhaustion, billing/account impact, and opaque data sharing with the third-party provider.

Content

No source excerpt is available for this finding.

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
91% confidence
Finding

The skill documents use of shell commands and outbound network access but does not declare any tool scope or permissions. This creates an authorization and transparency gap: an operator or user cannot easily tell that the skill may execute commands or send data externally, increasing the chance of unintended capability exposure.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

The skill sends user-provided destination and travel timing to external weather services but does not warn users that this context is transmitted to third parties. Travel plans and location context can be sensitive, so undisclosed sharing creates a privacy vulnerability even if the data seems ordinary.

Content

No source excerpt is available for this finding.

External Transmission

Medium
Category
Data Exfiltration
Confidence
83% confidence
Finding

This external transmission is expected for a weather skill, but it still represents a real privacy-relevant data flow because user-supplied destination and possibly date are sent to a third-party API. In context, the issue is not the existence of network use itself, but that the transmission is under-disclosed and insufficiently scoped in the skill metadata.

Content

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

API Endpoint:

text
https://api.openweathermap.org/data/2.5/weather?q={city}&appid={API_KEY}&units=metric&lang=en

Forecast API:

External Transmission

Medium
Category
Data Exfiltration
Confidence
83% confidence
Finding

The forecast endpoint similarly transmits user destination/travel context to a third-party service. While consistent with the skill's purpose, it is still a privacy-sensitive external data flow that should be explicitly declared and bounded rather than silently implied.

Content

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

Forecast API:

text
https://api.openweathermap.org/data/2.5/forecast?q={city}&appid={API_KEY}&units=metric&lang=en

Note:

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

Adding image-search capability and third-party image APIs is not necessary for the stated weather-and-outfit advice function, so it broadens the attack and privacy surface without clear justification. Unnecessary capabilities increase risk by sending additional user context to external services and by creating more code paths that may mishandle input or secrets.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The optional image-reference step sends user context such as destination and style-related queries to external image-search providers without explicit warning or consent. Because this processing is not essential to the core weather task, the undisclosed transmission is especially hard to justify and increases privacy risk.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The documented search_images.py behavior introduces unrelated external API access and API-key handling beyond the manifest's stated scope. This is dangerous because it expands both the data-sharing surface and the secret-management burden for a skill whose primary purpose does not require those capabilities.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

The module docstring, usage examples, and user-facing text in this file are all Chinese, which effectively forces a specific language experience. The policy allows fixed locale behavior only when user choice or a justified locale constraint is provided, neither of which appears here.

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

python
def run_script(script_name: str, *args):
    """运行脚本并返回 JSON 结果"""
    cmd = ["python3", script_name] + list(args)
    result = subprocess.run(cmd, capture_output=True, text=True)
    
    # 解析 stdout 中的 JSON
    try:

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The manifest describes a skill that queries weather and provides outfit recommendations, asking clarifying questions when needed. This file adds a separate image-search workflow to fetch outfit reference images, which is not mentioned in the manifest and is not necessary to fulfill the stated purpose.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The manifest describes a skill that queries weather and provides outfit recommendations, but this file implements standalone image-search capabilities across Bing, Pexels, and Pixabay plus fashion-query generation. Searching for and returning fashion or city images is not an obvious implementation detail of weather lookup or recommendation generation, so this expands behavior beyond the described skill purpose.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
89% confidence
Finding

The fallback behavior constructs Bing image-search requests from user input without clearly informing the user that their query will be sent to an external search engine. This is a privacy issue because the capability is ancillary to the stated weather-advisor purpose, making third-party transmission less expected and therefore more sensitive in context.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

The hard-coded Accept-Language preference forces a Chinese locale in outbound requests without reflecting user choice, which can leak assumptions about user region or alter returned content unexpectedly. While lower severity than credential exposure, it is still a privacy and transparency concern because network metadata is being shaped without user opt-in.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
90% confidence
Finding

These functions query third-party image APIs and return image metadata/URLs, which is a separate content-discovery capability rather than a direct requirement for providing weather-based outfit advice. The manifest mentions free weather APIs and collecting destination/date/preferences, but does not justify searching external image platforms for fashion content.

Content

No source excerpt is available for this finding.

External Transmission

Medium
Category
Data Exfiltration
Confidence
91% confidence
Finding

This code transmits user search queries to an external API endpoint, which is a real data egress path. External transmission is not inherently malicious, but in this skill context it is security-relevant because the transfer happens to a third party and the skill description does not clearly disclose that behavior.

Content

Scanner excerpt · scripts/search_images.py (reported line 124)May include surrounding context.

python
encoded_query = urllib.parse.quote(query)
        
        # Pexels API URL
        url = f"https://api.pexels.com/v1/search?query={encoded_query}&per_page={count}"
        
        # 设置请求头
        headers = {

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The script sends user-provided search queries to the external Pexels API and includes an API credential in the request, but it provides no explicit user disclosure or consent flow about third-party transmission. In a weather-outfit skill, users may not expect their destination/style queries to be shared with an image provider, creating privacy and transparency risk.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
98% confidence
Finding

The OpenWeatherMap example fixes lang=en, forcing English weather descriptions regardless of the user's preferred language. This is a natural-language locale choice embedded in the skill instructions and no opt-in or alternative locale selection is offered.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
92% confidence
Finding

This code file contains natural-language documentation and output strings entirely in Chinese, including the usage instructions and runtime messages. Under the policy rule for language/locale choice, forcing a specific language without user opt-in can be a policy violation when no alternative or selection mechanism is provided.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Low
Category
Not specified by scanner
Confidence
83% confidence
Finding

The module docstring says the output is a 'JSON format image URL list', but the actual code prints a structured object containing success flags, counts, messages, suggested APIs, manual search URLs, and sometimes an empty images list. This is an active mismatch between the file-level documentation and real behavior.

Content

No source excerpt is available for this finding.