T09 · Insecure Skill Coding Practices
Warning
- Location
- scripts/hwp_batch_convert.py:333
- Finding
- Global Dialog Watcher Can Approve Spoofed or Unrelated Security Prompts## Vulnerability Details **File Location**: `scripts/hwp_batch_convert.py`, lines 333–363 **Vulnerability Type**: Improper authorization of UI automation targets **Risk Level**: Medium ### Vulnerable Code ```python def _scan_once(self) -> bool: matched = False hwnds: list[int] = [] enum_proc = ctypes.WINFUNCTYPE( wintypes.BOOL, wintypes.HWND, wintypes.LPARAM, )(lambda hwnd, lparam: hwnds.append(hwnd) or True) USER32.EnumWindows(enum_proc, 0) for hwnd in hwnds: if hwnd in self._handled_hwnds or not USER32.IsWindowVisible(hwnd): continue title = USER32.GetWindowTextLengthW(hwnd) if title <= 0: continue window_title = ctypes.create_unicode_buffer(title + 1) USER32.GetWindowTextW(hwnd, window_title, title + 1) if window_title.value.strip() not in DIALOG_TITLE_WHITELIST: continue text_parts, allow_button_hwnd, allow_button_text = self._inspect_dialog(hwnd) window_text = ' '.join(part for part in text_parts if part).strip() reason = self._classify_candidate( window_title.value.strip(), window_text, allow_button_text, ) if reason != 'match': if window_text: self._record_event( AutoDialogEvent( window_title=window_title.value.strip(), window_text=window_text, button_text=allow_button_text, clicked=False, reason=reason, ) ) self._handled_hwnds.add(hwnd) continue clicked = False if allow_button_hwnd: USER32.SendMessageW(allow_button_hwnd, BM_CLICK, 0, 0) clicked = True ``` The application records newly created HWP process IDs in lines 403 and 429, but the dialog watcher does not use them: ```py ...[truncated 2659 chars]
- Remediation
- ## Remediation Suggestions 1. Use `GetWindowThreadProcessId` to retrieve the process ID of every candidate top-level window. 2. Pass the converter's verified process identity to `AutoAllowDialogWatcher` and reject any window whose owner is not in `RealHwpConverter.owned_pids`. 3. Verify the process image path and expected Hancom signature or installation path where feasible, rather than relying on the process name alone. 4. Fail closed when the HWP process cannot be uniquely identified. Do not enable automatic approval if process ownership cannot be established. 5. Bind eligible dialogs to the active conversion operation and, where possible, the specific document being opened. 6. Prefer a supported HWP automation security API or registered security module over generic desktop UI automation. 7. Require explicit user confirmation for ambiguous prompts or prompts belonging to pre-existing HWP processes. 8. Add negative tests that create matching dialogs from unrelated processes and verify that they are never clicked. 9. Update the documentation to clarify process-ownership guarantees and any remaining limitations of UI-based approval.
