T09 · Insecure Skill Coding Practices
- Location
scripts/spapi.py:58- Finding
Configurable SP-API Endpoint Can Receive Amazon Access Tokens and Sensitive Payloads
- Content
View full analysis
dict: return {"x-amz-access-token": access_token(), "Content-Type": "application/json"} def request(method: str, url: str, body=None, params=None, retries: int = 6): if params: url += "?" + urllib.parse.urlencode(params) data = json.dumps(body).encode() if body is not None else None last: Exception | None = None for attempt in range(retries): req = urllib.request.Request(url, data=data, headers=headers(), method=method) try: with urllib.request.urlopen(req, timeout=40) as resp: raw = resp.read() return json.loads(raw) if raw else {} ``` ### Technical Analysis The base SP-API endpoint can be supplied through either the `SPAPI_ENDPOINT` environment variable or the `endpoint` property in `~/.config/sp-api/credentials.json`. The value is not validated to ensure that: - The scheme is HTTPS. - The destination belongs to an approved Amazon SP-API domain. - User information is not present in the URL. - Redirects do not move the request to an untrusted destination. Every request constructed from this endpoint includes the `x-amz-access-token` bearer credential. State-changing workflow requests can also include seller inventory, SKUs, source addresses, telephone numbers, email addresses, carrier selections, and shipment identifiers. Reading SP-API credentials and sending a derived access token to Amazon is necessary for the declared functionality. Allowing the authenticated destination to be an arbitrary host exceeds ...[truncated 1246 chars]- Remediation
View remediation
