T09 · Insecure Skill Coding Practices
- Location
scripts/hwp_batch_convert.py:333- Finding
Global Dialog Watcher Can Approve Spoofed or Unrelated Security Prompts
- Content
View full analysis
Vulnerability Details
File Location:
scripts/hwp_batch_convert.py, lines 333–363
Vulnerability Type: Improper authorization of UI automation targets
Risk Level: MediumVulnerable 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 = TrueThe 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
View remediation
Remediation Suggestions
- Use
GetWindowThreadProcessIdto retrieve the process ID of every candidate top-level window. - Pass the converter's verified process identity to
AutoAllowDialogWatcherand reject any window whose owner is not inRealHwpConverter.owned_pids. - Verify the process image path and expected Hancom signature or installation path where feasible, rather than relying on the process name alone.
- Fail closed when the HWP process cannot be uniquely identified. Do not enable automatic approval if process ownership cannot be established.
- Bind eligible dialogs to the active conversion operation and, where possible, the specific document being opened.
- Prefer a supported HWP automation security API or registered security module over generic desktop UI automation.
- Require explicit user confirmation for ambiguous prompts or prompts belonging to pre-existing HWP processes.
- Add negative tests that create matching dialogs from unrelated processes and verify that they are never clicked.
- Update the documentation to clarify process-ownership guarantees and any remaining limitations of UI-based approval.
- Use
