T09 · Insecure Skill Coding Practices
- Location
run.py:10- Finding
Documented Search Result Limit Is Not Enforced
- Content
View full analysis
Vulnerability Details
File Location:
run.py:10-14
Vulnerability Type: Missing input validation and resource-bound enforcement
Risk Level: MediumVulnerable Code
python 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],SKILL.md:11-13documents the intended constraint:markdown ## Inputs - query (string, required): e.g. "crypto", "здоровье", "ai agents" - limit (int, optional, default 10, max 50)Technical Analysis
The wrapper forwards the user-provided
limitdirectly to/usr/local/bin/tg_searchwithout parsing it as an integer or enforcing the documented maximum of 50. Arbitrary strings, negative numbers, zero, and excessively large integers therefore reach the external program.Argument-array execution prevents shell metacharacters from being interpreted by a shell, so this is not command injection. However, the wrapper relies entirely on an unaudited external executable to validate a security- and resource-relevant parameter.
Attack Path
- An attacker or untrusted caller invokes the Skill with a malformed or excessive limit, such as
1000000000,-1, or a non-numeric value. run.pystores the value as an unvalidated string.- The wrapper passes the value unchanged to
/usr/local/bin/tg_search. - If the external utility does not impose its own strict bounds, it may attempt excessive processing or Telegram API activity, fail unexpectedly, or consume disproportionate resources.
Impact Assessment
Exploitation does not directly grant additional operating-system or Telegram privileges. The likely scope is availability and resource consumption within the Skill worker and the authorized Telegram account's API quota. Consequences may include excessive requests, Telegram rate limiting, process instability, unexpected errors, and degraded service for other ca ...[truncated 6 chars]
- An attacker or untrusted caller invokes the Skill with a malformed or excessive limit, such as
- Remediation
View remediation
Remediation Suggestions
Parse and validate the limit before launching the subprocess:
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, )The underlying
tg_searchutility should independently enforce the same range as defense in depth. Add automated tests for zero, negative values, non-numeric input, values above 50, and valid boundary values.
