T05 · Unauthorized Access and Privilege Escalation
Error
- Location
- scripts/dev_executor.py:190
- Finding
- Declared Telegram sender and group authorization is not enforced<![CDATA[ ## Vulnerability Details **File Location**: `scripts/dev_executor.py:190-221` **Vulnerability Type**: Missing authorization enforcement **Risk Level**: High ### Vulnerable Code ```python def handle_line(line: str) -> tuple[bool, str]: line = line.strip() if not line.startswith("DEV "): return False, "SKIP" parts = shlex.split(line) # parts[0] = DEV if len(parts) < 2: return False, "ERR: missing command" cmd = parts[1] rest = parts[2:] if cmd == "skill": return handle_skill(rest) if cmd == "cron": return handle_cron(rest) return False, f"ERR: unknown command: {cmd}" def main(): ap = argparse.ArgumentParser() ap.add_argument("--group", required=True, help="Allowed Telegram group chat id") ap.add_argument("--pm-from", required=True, help="Allowed PM bot numeric from.id") ap.add_argument("--stdin", action="store_true", help="Read commands from stdin (for testing)") args = ap.parse_args() if args.stdin: for line in sys.stdin: ok, msg = handle_line(line) if msg != "SKIP": print(msg) return ``` ### Technical Analysis The executor accepts trusted Telegram group and sender identifiers through `--group` and `--pm-from`, but these values are never used to authorize commands. The command handler receives only an unstructured text line, so it has no access to the originating `chat.id` or `from.id`. Consequently, every input source that can write to the process's standard input is treated as authorized as long as the line begins with `DEV ` and contains an allowlisted command type. This contradicts the security contract in `SKILL.md`, which requires commands to be accepted only when both the Telegram group and sender match configured identifiers. Although the script is described as a scaffold, any wrapper that forwards Telegram text without independently and correctly enforcing identity checks would expose ...[truncated 1394 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Replace raw text input with a structured event containing at least: - `chat.id` - `from.id` - message text - a trustworthy indication that the event came from the configured Telegram integration 2. Before calling `handle_line()`, reject every event for which: - `chat.id` does not equal the configured group identifier. - `from.id` does not equal the configured PM bot identifier. - The message is not a single-line command beginning with the exact required prefix. 3. Parse numeric identifiers once and compare them using consistent types rather than loosely comparing strings. 4. Treat stdin mode as testing-only. Require an explicit development flag and refuse to enable it in production configurations. 5. Ensure the Telegram wrapper does not trust sender or group identifiers supplied inside message text. 6. Add tests proving that wrong-group, wrong-sender, missing-metadata, malformed-event, and forwarded-message cases are rejected before any subprocess is started. 7. Apply least privilege to the executor account and restrict filesystem permissions on the OpenClaw workspace. ]]>
