Skip to content

CodeQL XSS 경고 제거 — content-script.js img.src URL 파싱 강화 #128

@edwardkim

Description

@edwardkim

개요

CodeQL Code Scanning Alert #14 (js/xss-through-dom, severity: high) 대응.

현상

  • 위치: rhwp-chrome/content-script.js:67 — `img.src = dataUri`
  • 경고: DOM에서 읽은 텍스트(`data-hwp-thumbnail` 속성)를 HTML 컨텍스트에 재삽입
  • 현재 방어: `isSafeImageUrl()`로 `http:`/`https:` 프로토콜 검증 후 원본 문자열 그대로 사용
  • CodeQL 판단: 검증 결과(`true/false`)와 무관하게 원본 DOM 값이 그대로 `img.src`에 흘러들어감

수정 방향

`isSafeImageUrl()` 통과 후 원본 문자열 대신 `new URL(dataUri).href`로 재구성된 값을 사용.

// 변경 전
img.src = dataUri;  // 원본 DOM 문자열 직접 사용

// 변경 후
img.src = new URL(dataUri).href;  // URL 파싱 후 정규화된 값 사용

CodeQL은 "외부 입력 → URL 파싱 → .href 추출" 흐름을 안전한 변환으로 인식할 것으로 기대.

완료 기준

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions