T09 · Insecure Skill Coding Practices
- Location
scripts/qryma_search.py:45- Finding
Arbitrary API Endpoint Allows Qryma Credential and Search Query Exfiltration
- Content
View full analysis
str: """Load Qryma API endpoint""" # Load from environment variable endpoint = os.environ.get("QRYMA_ENDPOINT") if endpoint: return endpoint.strip() # Load from config file env_path = os.path.expanduser("~/.qryma/.env") if not os.path.exists(env_path): env_path = ".env" if os.path.exists(env_path): try: with open(env_path, "r", encoding="utf-8", errors="ignore") as f: txt = f.read() m = re.search(r"^\s*QRYMA_ENDPOINT\s*=\s*(.+?)\s*$", txt, re.M) if m: v = m.group(1).strip().strip('"').strip("'") if v: return v except Exception: pass ``` ```python payload = { "query": query, "lang": lang, "safe": safe, "mode": mode, "max_results": max_results, } data = json.dumps(payload).encode("utf-8") req = urllib.request.Request( self.endpoint, data=data, headers={ "Content-Type": "application/json", "Accept": "application/json", "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36", "X-Api-Key": self.api_key, }, method="POST", ) with urllib.request.urlopen(req, timeout=30) as resp: body = resp.read().decode("utf-8", errors="replace") ``` ### Technical Analysis The script accepts `QRYMA_ENDPOINT` without validating its scheme, hostname, port, or relationship to the trusted Qryma service. The endpoint may come from either the process environment or `~/.qryma/.env`. If the user-level configuration does not exist, the script also trusts a `.env` file in the current working directory. Every search req ...[truncated 2764 chars]- Remediation
View remediation
