T09 · Insecure Skill Coding Practices
- Location
run.py:10- Finding
Unvalidated Search Limit Passed to External Telegram Utility
- Content
View full analysis
Vulnerability Details
File Location:
run.py, lines 10–14
Vulnerability Type: Improper input validation
Risk Level: Lowpython query = sys.argv[1] limit = sys.argv[2] if len(sys.argv) >= 3 else "10" p = subprocess.run( ["/usr/local/bin/tg_search", query, limit], capture_output=True, text=True )Technical Analysis
The documentation defines
limitas an integer with a maximum value of 50, but the wrapper neither converts it to an integer nor enforces an allowed range. Consequently, arbitrary strings, negative values, zero, and excessively large numeric values are forwarded unchanged to/usr/local/bin/tg_search.Exploitability and resulting behavior depend on how the external utility validates this argument. That utility is outside the audited project, so its implementation could not be verified. This is not shell-command injection:
subprocess.runreceives an argument list and does not enableshell=True.Attack Path
- Invoke the skill with a malformed, negative, or excessively large second argument, such as
run.py crypto 999999999. run.pyaccepts the value without type or range validation.- The value is passed unchanged as an argument to
/usr/local/bin/tg_search. - If the external utility does not enforce its own limits, it may perform an excessive search operation, consume unnecessary resources, or return an operational error.
Impact Assessment
A caller may be able to cause errors, excessive Telegram requests, unexpectedly large result processing, or local resource consumption. The issue does not directly grant additional operating-system privileges, expose credentials, or permit shell-command execution. Its scope is limited by validation and authorization controls implemented in the external
tg_searchexecutable and by Telegram-side restrictions.- Invoke the skill with a malformed, negative, or excessively large second argument, such as
- Remediation
View remediation
Remediation Suggestions
Parse
limitas an integer before invoking the external utility and enforce the documented range of 1 through 50. Reject non-numeric, zero, negative, and oversized values with a stable JSON error response.python try: limit = int(sys.argv[2]) if len(sys.argv) >= 3 else 10 except ValueError: print(json.dumps({"error": "limit must be an integer"})) sys.exit(1) if not 1 <= limit <= 50: print(json.dumps({"error": "limit must be between 1 and 50"})) sys.exit(1) p = subprocess.run( ["/usr/local/bin/tg_search", query, str(limit)], capture_output=True, text=True, timeout=30, check=False, )Retain list-based subprocess invocation without
shell=True. Consider adding a timeout and output-size controls to limit resource consumption if the external process stalls or emits unexpectedly large output. The external utility should independently enforce the same range as defense in depth.
