T05 · Unauthorized Access and Privilege Escalation
Error
- Location
- __init__.py:149
- Finding
- Approval Mode Does Not Protect Multiple Sensitive Desktop Operations<![CDATA[ ## Vulnerability Details **File Location**: `__init__.py`, lines 149–156, 396–405, 677–710, and 790–803 **Vulnerability Type**: Incomplete authorization enforcement **Risk Level**: High ### Vulnerable Code ```python def scroll(self, clicks: int, direction: str = "vertical", x: Optional[int] = None, y: Optional[int] = None) -> None: if x is not None and y is not None: pyautogui.moveTo(x, y) if direction == "vertical": pyautogui.scroll(clicks) else: pyautogui.hscroll(clicks) ``` ```python def drag_drop(self, from_x: int, from_y: int, to_x: int, to_y: int, duration: float = 0.5) -> None: """Drag from (x1, y1) to (x2, y2).""" pyautogui.moveTo(from_x, from_y, duration=0.2) pyautogui.mouseDown() pyautogui.moveTo(to_x, to_y, duration=duration) pyautogui.mouseUp() def drag_file_to_app(self, file_path: str, target_x: int, target_y: int) -> None: """Drag a file to a specific position (e.g., drop file to app).""" self.drag_drop(0, 0, target_x, target_y, duration=1) ``` ```python def screenshot(self, region: Optional[Tuple[int, int, int, int]] = None, filename: Optional[str] = None): img = pyautogui.screenshot(region=region) if filename: img.save(filename) else: return img def screenshot_to(self, filename: str, region: Optional[Tuple[int, int, int, int]] = None) -> str: """Take a screenshot and save to filename. Returns filename.""" self.screenshot(region=region, filename=filename) return filename ``` ```python def copy_to_clipboard(self, text: str) -> None: try: import pyperclip pyperclip.copy(text) except Exception as e: logger.error(f"Clipboard copy error: {e}") def get_from_clipboard(self) -> Optional[str]: try: import pyperclip return pyperclip.paste() except Exception as e: logger.error(f"Clipboard paste error: {e}") return None ``` ### Technical Ana ...[truncated 2089 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions - Require `_check_approval()` before every public operation that reads or modifies desktop state, including screenshots, recording, clipboard access, scrolling, drag-and-drop, and window management. - Centralize authorization in a decorator or private execution wrapper so newly added methods cannot accidentally omit the check. - Use explicit descriptions such as `capture the entire screen`, `read clipboard contents`, or `record the screen for 30 seconds`. - Apply approval checks at the sensitive primitive layer rather than relying only on callers such as `run_steps()`. - Consider separate permissions for input control, screen capture, clipboard reads, clipboard writes, and recording. - Ensure denied operations return a clear failure result instead of silently appearing successful. - Add automated tests verifying that every sensitive API requests approval when `require_approval=True` and performs no action after denial. - Update examples to retain approval mode for privacy-sensitive operations unless the user has explicitly chosen otherwise. ]]>
