T09 · Insecure Skill Coding Practices
Warning
- Location
- __init__.py:123
- Finding
- Approval Mode Does Not Protect All Sensitive Operations<![CDATA[ ## Vulnerability Details **File Location**: `__init__.py:123-140`, `__init__.py:198-205`, `__init__.py:210-228`, and `__init__.py:348-380` **Vulnerability Type**: Incomplete authorization enforcement **Risk Level**: Medium ### 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) logger.debug(f"Scrolled {direction} {clicks} clicks") def key_down(self, key: str) -> None: """Press and hold a key without releasing.""" pyautogui.keyDown(key) logger.debug(f"Key down: '{key}'") def key_up(self, key: str) -> None: """Release a held key.""" pyautogui.keyUp(key) logger.debug(f"Key up: '{key}'") 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) logger.info(f"Screenshot saved to: {filename}") else: logger.debug(f"Screenshot captured (region={region})") return img def copy_to_clipboard(self, text: str) -> None: try: import pyperclip pyperclip.copy(text) logger.info(f"Copied to clipboard: '{text[:50]}...'") except ImportError: logger.error("pyperclip not installed. Run: pip install pyperclip") except Exception as e: logger.error(f"Error copying to clipboard: {e}") def get_from_clipboard(self) -> Optional[str]: try: import pyperclip text = pyperclip.paste() logger.debug(f"Got from clipboard: '{text[:50]}...'") return text except ImportError: logger.error("pyperclip not installed. Run: pip install pyperclip") return None except Exception as e: log ...[truncated 1997 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Apply `_check_approval()` before every state-changing or privacy-sensitive operation, including: - Screen and region capture - Clipboard reads and writes - Scrolling - `key_down()` and `key_up()` - Window enumeration and activation where relevant - Pixel inspection and image matching if screen confidentiality is expected 2. Introduce capability-specific permissions such as `allow_screen_capture`, `allow_clipboard_read`, `allow_clipboard_write`, and `allow_input_control`. 3. Default privacy-sensitive capabilities to denied when approval mode is enabled. 4. Ensure the approval prompt displays the operation and its scope, such as the screenshot region or clipboard access direction. 5. Add automated tests that enumerate every public controller method and verify that sensitive methods cannot execute after approval is declined. 6. Document precisely which methods are protected rather than describing approval mode as applying universally. ]]>
