Back to skill

Security audit

唯品会图片搜索

Security checks for vulnerabilities and agentic risk

Overview

This skill performs the advertised Vipshop image search, but it also handles account tokens in a way that can expose a user’s login token in generated product links.

Review carefully before installing. Use only with images you are willing to upload to Vipshop, and do not share generated product links until the token-in-link behavior is removed or proven safe. The publisher should remove the hard-coded signing secret, stop embedding access tokens in URLs or agent-visible output, and add explicit confirmation for account-token use and image upload.

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 (3)

T09 · Insecure Skill Coding Practices

Error
Location
scripts/exchange_link_builder.py:150
Finding

Vipshop Access Token Is Reversibly Embedded in Displayed Product Links

Content
View full analysis
str: token_file = Path.home() / ".vipshop-user-login" / "tokens.json" if not token_file.exists(): return "" try: with open(token_file, 'r', encoding='utf-8') as f: data = json.load(f) if data and isinstance(data, dict) and 'cookies' in data: expires_at = data.get('expires_at') if expires_at and time.time() > expires_at: return "" cookies = data.get('cookies', {}) token = cookies.get("PASSPORT_ACCESS_TOKEN", "") if token: return token else: return "" else: return "" except json.JSONDecodeError: return "" except Exception: return "" ``` ```python # 获取 token token = _get_token() if not token: log("⚠️ token 为空,直接返回原始目标 URL") return target_url # 获取 secret key secret = _get_secret() # 构造数据对象 timestamp = int(time.time() * 1000) data_obj = {"t": token, "ts": timestamp} # 转换为 JSON 字符串 json_str = json.dumps(data_obj, separators=(",", ":")) # Base64 编码 base64_str = base64.b64encode(json_str.encode("utf-8")).decode("utf-8") # 生成签名 signature = _generate_signature(base64_str, secret) # 构造完整链接 base_url = "https://passport.vip.com/exchangeTokenFromApp" full_url = ( f"{base_url}?" f"dt={urllib.parse.quote(base64_str)}&" f"sg={signature}&" f"src={urllib.parse.quote(target_url)}" ) return full_url ``` ```python # 使用 build_product_link 生成带 exchange token 的链接 product_link = build_product_link( product.get('brandId', ''), product.get('productId', '') ) product_info = { "商品ID": product.get('productId', ''), "商品名称": product.get('title', ...[truncated 2893 chars]
Remediation
View remediation
-.html ``` 3. If authenticated token exchange is essential, perform it through a trusted server-side component that: - Keeps the access token and signing key out of client-visible data. - Returns only a short-lived, one-time, opaque identifier. - Binds the identifier to the intended destination and user. - Prevents replay and expires it within a minimal period. 4. Redact credential-bearing query parameters from logs, errors, analytics, and agent output. 5. Revoke or rotate access tokens that may already have been exposed through generated links. 6. Remove the duplicate credential read from link generation and pass only the minimum non-sensitive product identifiers required to build a link. 7. Add automated tests that decode all generated query parameters and fail if authentication tokens, cookies, or other secrets are present. ]]>

T09 · Insecure Skill Coding Practices

Error
Location
scripts/exchange_link_builder.py:39
Finding

Hard-Coded Exchange-Link Signing Secret Allows Signature Forgery

Content
View full analysis
str: """ 获取 secret key Returns: secret key 字符串 """ return "5fb86e55b72bfc50f083049130e5e76a75c2cbda6bbd6e51d59668057f5c1715" ``` ```python def _generate_signature(data: str, secret: str) -> str: signature = hmac.new( secret.encode("utf-8"), data.encode("utf-8"), hashlib.md5 ).hexdigest() result = signature.upper() return result ``` ```python # 获取 secret key secret = _get_secret() # 构造数据对象 timestamp = int(time.time() * 1000) data_obj = {"t": token, "ts": timestamp} # 转换为 JSON 字符串 json_str = json.dumps(data_obj, separators=(",", ":")) # Base64 编码 base64_str = base64.b64encode(json_str.encode("utf-8")).decode("utf-8") # 生成签名 signature = _generate_signature(base64_str, secret) # 构造完整链接 base_url = "https://passport.vip.com/exchangeTokenFromApp" full_url = ( f"{base_url}?" f"dt={urllib.parse.quote(base64_str)}&" f"sg={signature}&" f"src={urllib.parse.quote(target_url)}" ) ``` ### Technical Analysis A cryptographic signing key is embedded directly in a distributed source file. Every party able to inspect or obtain the Skill can recover the key. It therefore cannot serve as a trustworthy shared secret. The code uses the exposed key to generate an HMAC-MD5 signature over attacker-readable Base64 data. Knowledge of the key allows an attacker to generate a matching signature for any attacker-selected encoded payload. Although HMAC-MD5 does not inherit ordinary MD5 collision attacks in a directly equivalent way, MD5 is obsolete and should not be selected for new security mechanisms. The primary vulnerability here is disclosure of the HMAC key, which defeats authenticity regardless of the hash algorithm. ### Attack Path 1. An attacker obtains or inspects t ...[truncated 1297 chars]
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/img_search.py:32
Finding

Extension-Only Image Validation Can Upload Arbitrary Renamed File Content

Content
View full analysis
bool: """ 验证文件是否为支持的图片类型 """ ext = os.path.splitext(file_path)[1].lower() if ext not in SUPPORTED_IMAGE_TYPES: return False if not os.path.exists(file_path): return False return True ``` ```python def upload_image( file_path: str, mars_cid: str, access_token: str ) -> Dict[str, Any]: try: boundary = ( 'WABoundary+' + ''.join([ format(int(time.time() * 1000) % 16, 'X') for _ in range(16) ]) + 'WA' ) with open(file_path, 'rb') as f: file_data = f.read() file_name = os.path.basename(file_path) body_parts = [] body_parts.append(f'--{boundary}'.encode('utf-8')) body_parts.append( f'Content-Disposition: form-data; ' f'name="picture"; filename="{file_name}"'.encode('utf-8') ) body_parts.append(b'Content-Type: image/jpeg') body_parts.append(b'') body_parts.append(file_data) body_parts.append(f'--{boundary}--'.encode('utf-8')) body_parts.append(b'') body = b'\r\n'.join(body_parts) upload_params = { 'app_name': 'shop_weixin_mina', 'client': 'wechat_mini_program', 'source_app': 'shop_weixin_mina', 'api_key': API_KEY, 'app_version': '4.0', 'mobile_platform': '2', 'union_mark': 'nature', 'mobile_channel': 'nature', 'mars_cid': mars_cid, 'warehouse': 'VIP_NH', 'fdc_area_id': '944101105999', 'pro ...[truncated 3579 chars]
Remediation
View remediation
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
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
Findings (16)

Tp4

High
Category
MCP Tool Poisoning
Confidence
99% confidence
Finding

声明描述的核心能力是“以图搜图/拍照搜商品”,应包含图片输入处理、搜索请求、以及商品结果输出。该代码块完全没有图片相关逻辑,也没有搜索 API 调用或商品结果解析。相反,它专注于读取本地登录 token、检查过期时间、使用硬编码密钥进行 HMAC-MD5 签名,并构造 exchangeTokenFromApp 链接用于带登录态跳转到商品详情页。这是与声明的主要用途 materially different 的行为,并且涉及未声明的本地凭证访问与签名链接生成,因此应判定为描述与行为不匹配。

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

High
Category
Not specified by scanner
Confidence
98% confidence
Finding

This file's behavior materially diverges from the declared image-search purpose: it reads local login state, constructs signed exchange-token URLs, and enables authenticated link minting. That mismatch is dangerous because it can hide credential use and account-context pivoting inside a skill that users and reviewers would expect to only process images and return product metadata.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

High
Category
Not specified by scanner
Confidence
99% confidence
Finding

The module embeds a hardcoded secret and uses it to generate HMAC-signed exchange-token URLs, effectively giving anyone with code access the ability to mint trusted links. Hardcoded signing secrets are highly dangerous because they are recoverable from source control, logs, backups, or redistribution, and can enable unauthorized authentication or session exchange at scale.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

High
Category
Not specified by scanner
Confidence
97% confidence
Finding

The code reads a PASSPORT_ACCESS_TOKEN from a file in the user's home directory, which gives the skill access to existing authenticated session material unrelated to image search. In this context, that is a sensitive local secret access path that can be used to impersonate the user or generate authenticated flows without clear authorization.

Content

No source excerpt is available for this finding.

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
94% confidence
Finding

The skill instructs the agent to read a local login token file and call external Vipshop endpoints, but it declares no explicit tool scope or permission boundaries. This creates an authorization and transparency gap: an agent may access local files and transmit user-derived data off-host without clear policy constraints or user consent.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

The skill can be triggered by broad, common phrases like '找同款' or '图片搜商品' without stronger constraints, increasing the chance of unintended invocation. In this skill's context, accidental triggering is more dangerous because execution may read local state and upload local images to third-party endpoints, causing privacy and consent issues.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The example trigger list contains ambiguous everyday phrases that could match unrelated conversations and activate the skill unexpectedly. Given that the skill workflow includes account-state checks and external data transfer, unintended invocation can expose local image content or account-linked actions without sufficiently informed user intent.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

The skill describes local image upload and external API calls but does not clearly warn users that their local images will be transmitted to Vipshop services. Because images may contain sensitive personal or contextual information, silent third-party upload creates a meaningful privacy and data-handling risk, especially when tied to a logged-in account workflow.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Medium
Category
Not specified by scanner
Confidence
98% confidence
Finding

L240-L241 明确写着“ 不支持,仅支持本地图片文件上传方式”,但 L52-L63 又要求在“下一页”场景中缓存并传入图片URL、分类类型、检测区域和 pageToken 调用脚本。这不是单纯信息缺失,而是文档内部对技能输入能力的直接矛盾,容易误导调用方或审计者对实际支持能力的判断。

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
88% confidence
Finding

The skill accesses and transmits sensitive authentication material without any user-visible notice or explicit consent flow; the fact that debug logging is off does not mitigate the underlying secret use. In a skill whose stated purpose is image-based product search, silent credential access increases the risk of unnoticed misuse and weakens user trust and auditability.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

The script reads persisted authentication material from ~/.vipshop-user-login/tokens.json and reuses it for network actions. Even though this appears intended to support the skill's normal operation, silently consuming local tokens expands the trust boundary and can cause authenticated actions or data access without explicit user awareness at the point of use.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

The skill loads login tokens from the local home directory and then uses them in requests to external services without any disclosure in the execution path. This can cause the user to unknowingly authenticate remote requests, linking searches to their account and exposing account-scoped behavior or data.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
97% confidence
Finding

When given a local file path, the skill uploads the image to a remote VIPShop endpoint as part of search processing, but the code provides no user-facing disclosure or confirmation at the upload point. Local images may contain sensitive personal or commercial information, so silent exfiltration to a third party creates a meaningful privacy and data-handling risk.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
84% confidence
Finding

The upload request uses a fixed WeChat User-Agent string containing Language/zh_CN, which imposes a specific locale behavior. The skill does not offer user opt-in or explain that it is intentionally limited to a Chinese locale context, creating a natural-language locale policy concern.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
95% confidence
Finding

The Accept-Language header is hard-coded to prefer zh-CN for category requests, and the file does not provide any language selection or documented rationale for this restriction. This is a locale policy issue because the skill unilaterally sets language preferences rather than allowing user choice.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
95% confidence
Finding

The product search request also hard-codes an Accept-Language header favoring zh-CN. Because the skill does not provide a user language choice or explain a justified regional limitation, this constitutes a natural-language locale policy violation.

Content

No source excerpt is available for this finding.