T09 · Insecure Skill Coding Practices
- Location
scripts/deepsky_search.py:49- Finding
Unbounded Remote Response Read Can Cause Memory Exhaustion
- Content
View full analysis
- Remediation
View remediation
MAX_RESPONSE_BYTES: raise ValueError("API response exceeds the permitted size") except ValueError as exc: if str(exc) == "API response exceeds the permitted size": raise body = resp.read(MAX_RESPONSE_BYTES + 1) if len(body) > MAX_RESPONSE_BYTES: raise ValueError("API response exceeds the permitted size") data = json.loads(body.decode("utf-8")) if not isinstance(data, dict): raise ValueError("API response must be a JSON object") matches = data.get("matches", []) if not isinstance(matches, list) or len(matches) > 20: raise ValueError("API response contains an invalid matches collection") return data ``` The error handling should also catch these validation failures and report them without printing an unbounded server-controlled response body. ]]>
