T09 · Insecure Skill Coding Practices
- Location
scripts/query_ccdb.py:18- Finding
Unrestricted API Endpoint Override Enables SSRF and Search-Query Disclosure
- Content
View full analysis
Vulnerability Details
File Location:
scripts/query_ccdb.py:18-21, 412-420, 492
Vulnerability Type: Server-Side Request Forgery (SSRF) and data redirection
Risk Level: MediumVulnerable Code
python DEFAULT_BASE_URL = os.environ.get( "CCDB_API_BASE_URL", "https://gateway.carbonstop.com/management/system/website/queryFactorListClaw", )python def query_api(base_url: str, name: str, lang: str) -> dict: payload = {'sign': make_sign(name), 'name': name, 'lang': lang} body = json.dumps(payload, ensure_ascii=False).encode('utf-8') headers = { 'Accept': 'application/json, text/plain, */*', 'Content-Type': 'application/json', 'User-Agent': 'OpenClaw-CCDB-Skill/1.0', } req = Request(base_url, data=body, headers=headers, method='POST') try: with urlopen(req, timeout=30) as resp: raw = resp.read().decode('utf-8', errors='replace')python parser.add_argument('--base-url', default=DEFAULT_BASE_URL)Technical Analysis
The script allows the API destination to be replaced through either the
CCDB_API_BASE_URLenvironment variable or the--base-urlcommand-line option. The supplied URL is passed directly tourllib.request.Requestandurlopenwithout validating its scheme, hostname, port, resolved IP address, path, or redirect destination.This exceeds the minimum network privilege required for the declared functionality. CCDB factor lookup only requires access to the documented Carbonstop HTTPS endpoint, whereas the implementation can issue POST requests to arbitrary Internet or internal-network destinations.
The request body contains the user-derived search term, language, and an MD5-derived signature:
json { "sign": "<derived signature>", "name": "<user-derived search term>", "lang": "<language>" }The default Carbonstop request is necessary and documented. The vulnerability arises specifically from allowing unrestricted destina ...[truncated 1762 chars]
- Remediation
View remediation
Remediation Suggestions
- Remove
--base-urlandCCDB_API_BASE_URLfrom production builds unless custom endpoints are an explicit operational requirement. - Allowlist the exact destination:
- Scheme:
https - Host:
gateway.carbonstop.com - Port:
443 - Approved API path or paths only
- Scheme:
- Reject URLs containing user information, fragments, unexpected ports, non-HTTPS schemes, or malformed hostnames.
- Resolve the hostname and reject loopback, private, link-local, multicast, reserved, and unspecified IP ranges for both IPv4 and IPv6.
- Disable redirects, or validate every redirect target using the same scheme, hostname, path, and IP-address controls.
- Ensure endpoint configuration can only be changed by a trusted administrator and cannot be derived from user prompts or untrusted task input.
- Document that search terms are transmitted to Carbonstop and advise callers not to include complete BOMs, supplier identities, credentials, personal data, or unrelated confidential content.
- Add automated tests covering malicious destinations such as localhost, private IP addresses, link-local addresses, HTTP URLs, alternate ports, credential-bearing URLs, and cross-host redirects.
- Remove
