Back to skill

Security audit

clawec-amazon-keyword-search

Security checks for vulnerabilities and agentic risk

Overview

This skill is a disclosed ClawEC Amazon keyword-search integration that uses the user's API key to submit searches and retrieve related results, with a concurrency/result-mixup caveat but no hidden persistence or unrelated local access.

Install only if you trust ClawEC with the Amazon keyword, region, month, and options you submit, and store CLAWEC_API_KEY as a secret environment variable rather than hardcoding it. Avoid shared ClawEC accounts or concurrent identical searches when using search_and_poll.sh, because it may retrieve the wrong matching history record.

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_and_poll.sh:95
Finding

Non-Unique Job Correlation Can Return an Unintended Search Result

Content
View full analysis

Vulnerability Details

File Location: scripts/search_and_poll.sh, lines 95–105
Vulnerability Type: Improper correlation of asynchronous jobs
Risk Level: Medium

Vulnerable Code

python
unwrap_data(run_json(cmd))
target = {"region": region, "keyword": keyword.strip(), "date": date, "aiInterpret": ai}
log_id = None
for _ in range(10):
    for item in (unwrap_data(run_json([logs_sh,"1","20"])).get("items") or []):
        p = item.get("param") or {}
        if (p.get("keyword") or "").strip() == keyword.strip() and (p.get("region") or "US") == region and str(p.get("date") or "") == date:
            log_id = item.get("id"); break
    if log_id: break
    time.sleep(min(poll_interval,3))

Technical Analysis

The script submits a search but discards the submission response. It then attempts to locate the newly created record by listing the latest 20 account records and comparing only the keyword, region, and date.

Those parameters do not uniquely identify a submitted job. Different searches can share all three values, particularly when requests are repeated or an account is used concurrently. The script also creates a target object containing aiInterpret, but never uses it. Other search options, such as ABA research, keyword mining, and keyword trends, are likewise excluded from the comparison.

The first matching history record is accepted without checking whether multiple records match, whether its creation time corresponds to the current submission, or whether it was created by the current invocation. Consequently, the selected log_id may belong to an earlier or concurrent request.

Attack Path

  1. Another user or process using the same ClawEC account submits a search with the same keyword, region, and month as the victim.
  2. The victim invokes search_and_poll.sh with those same parameters.
  3. The victim's search is submitted, but the response is discarded.
  4. The script requests the latest 20 account history records. ...[truncated 938 chars]
Remediation
View remediation

Remediation Suggestions

  1. Preserve and parse the search-submission response, then use a unique server-issued job or log identifier to retrieve the corresponding result directly.
  2. If the API does not currently return an identifier, extend the API contract to return an immutable request ID.
  3. As a temporary fallback, record the submission time and match against a narrow creation-time window together with every submitted parameter, including aiInterpret, abaResearch, keywordMiner, and keywordTrend.
  4. Detect multiple matching records and fail safely instead of selecting the first one.
  5. Avoid relying on ordering within the latest 20 history entries, since ordering and concurrent insertions do not establish ownership.
  6. Add concurrency tests that submit identical searches and verify that each invocation retrieves only its own result.
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • 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
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
Findings (15)

Tp4

High
Category
MCP Tool Poisoning
Confidence
97% confidence
Finding

The declared purpose focuses on Amazon keyword analysis features such as ABA, keyword mining, and trend analysis. However, the code only fetches records from a keyword/search/logs endpoint, which appears to return historical logs of searches rather than executing keyword analysis itself. This is a materially different primary behavior and uses a logging-related resource not disclosed in the description.

Content

No source excerpt is available for this finding.

Env Variable Harvesting

High
Category
Data Exfiltration
Confidence
60% confidence
Finding

Code enumerates, copies, or searches environment variables for secrets. Bulk environment access can collect credentials unrelated to the skill's stated purpose.

Content

Scanner excerpt · scripts/search_and_poll.sh (reported line 36)May include surrounding context.

sh
script_dir = sys.argv[3]
args = sys.argv[4:]

env = os.environ.copy()
search_sh = os.path.join(script_dir, "search.sh")
logs_sh = os.path.join(script_dir, "logs.sh")
detail_sh = os.path.join(script_dir, "log_detail.sh")

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
94% confidence
Finding

The skill documents use of environment variables and shell commands/curl, but it does not declare any explicit tool scope or allowed-tools restrictions. That increases the blast radius of the skill because an agent may invoke shell or access secrets more broadly than necessary, making accidental secret exposure or unintended command execution more likely.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
90% confidence
Finding

The description says to use the skill when the user needs "keyword search、关键词分析、关键词挖掘", which are generic phrases rather than tightly scoped activation conditions. It does not provide exclusions or context boundaries, increasing the chance of unintended invocation for ordinary requests about keywords outside this specific ClawEC Amazon workflow.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
84% confidence
Finding

The natural-language description and operational guidance are entirely in Chinese, with no indication that users may choose another language or locale. Under the policy, a language constraint should either be optional or clearly justified as region-specific; neither is stated here.

Content

No source excerpt is available for this finding.

External Transmission

Medium
Category
Data Exfiltration
Confidence
91% confidence
Finding

The skill transmits user-supplied keyword data and an authorization bearer token to an external third-party API. External transmission is expected for this skill's purpose, but it still creates a real data-handling and secret-exposure risk, especially if agents send sensitive user inputs, misuse shell logging, or expose the API key in execution traces.

Content

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

| JP | 日本 |

bash
curl -s -X POST "https://www.clawec.com/api/aigc/ec/amazon/keyword/search" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $CLAWEC_API_KEY" \
  -d '{"region":"US","keyword":"wireless earbuds","date":"202505","keywordMiner":true,"aiInterpret":true}'

External Transmission

Medium
Category
Data Exfiltration
Confidence
70% 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/search.sh (reported line 29)May include surrounding context.

sh
body={"region":region or "US","keyword":kw,"date":date,"abaResearch":aba=="true","keywordMiner":miner=="true","keywordTrend":trend=="true","aiInterpret":ai=="true"}
print(json.dumps(body, ensure_ascii=False))
' "$KEYWORD" "$REGION" "$DATE" "$ABA" "$MINER" "$TREND" "$AI")
curl -s -X POST "https://www.clawec.com/api/aigc/ec/amazon/keyword/search" -H "Content-Type: application/json" -H "Authorization: Bearer $API_KEY" -d "$PAYLOAD"

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
90% confidence
Finding

The script performs an HTTP POST to a third-party endpoint and includes user-supplied search parameters in the request body, but there is no confirmation prompt, logging, or explanatory comment/disclosure in the file. For code files, outbound transmission of user or system data should have some visible warning unless clearly disclosed elsewhere.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
95% confidence
Finding

The required-environment-variable error message is hardcoded in Chinese ("请设置环境变量 CLAWEC_API_KEY"), which forces a specific language regardless of user preference or locale. This is a natural-language policy concern because the file provides no opt-in or documented locale justification.

Content

No source excerpt is available for this finding.

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
91% confidence
Finding

The script sends an authenticated HTTP request using a sensitive API key, but there is no confirmation prompt, explanatory comment, or user-facing message indicating that credentials will be used for a network call. For a standalone code file, this is a safety-relevant external operation with no visible disclosure.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
96% confidence
Finding

The usage text is presented only in Chinese, which imposes a specific language on users without any opt-in or indication that the skill is intentionally region-specific. This matches the policy category for language or locale constraints that are not optional or justified.

Content

No source excerpt is available for this finding.

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
85% confidence
Finding

The script accesses the CLAWEC_API_KEY environment variable and uses it for authenticated API access, but the file provides no warning or explanatory comment beyond the missing-variable error text. Access to credentials in code files should be accompanied by some visible disclosure unless already clearly documented as part of the skill's stated purpose.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
94% confidence
Finding

The required-environment-variable error message is emitted only in Chinese, which enforces a language choice in user-visible output. There is no indication in this file that the script is region-specific or that users can choose their preferred language.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
96% confidence
Finding

This shell script presents its usage documentation in Chinese and later emits a Chinese-only error message, which imposes a specific language on users without opt-in. The policy for natural-language violations applies to all file types, including code files with user-facing string literals.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
93% confidence
Finding

The script prints the user-facing message "未找到历史记录" when no history record is found, but there is no indication that the skill is intentionally limited to Chinese-speaking users. This is a natural-language locale constraint in executable output without opt-in or justification.

Content

No source excerpt is available for this finding.