---
type: note
kind: Troubleshooting
tags: ['url', 'encoding', 'ios', 'debug', 'security']
status: release
ctime: 2026-05-25
mtime: 2026-05-31
generated: { by: claude/opus-4.8, at: 2026-05-31T16:41:08Z }
verified: { by: claude/opus-5, at: 2026-08-19T00:00:00Z }
sources:
  - id: bugs-webkit-show-bug
    resource: https://bugs.webkit.org/show_bug.cgi?id=261936
    title: "WebKit Bug 261936"
  - id: augmentedcode-2023-10
    resource: https://augmentedcode.io/2023/10/02/changes-to-url-string-parsing-in-ios-17/
    title: "Changes to URL string parsing in iOS 17 — Augmented Code"
  - id: owasp-www-community-double-encoding
    resource: https://owasp.org/www-community/Double_Encoding
    title: "OWASP — Double Encoding"
  - id: url-spec-whatwg
    resource: https://url.spec.whatwg.org/
    title: "WHATWG URL Standard"
---

URL `%2520` 버그 = iOS 17.0/17.1 WebKit pasteboard가 복사 시 URL을 재인코딩 (WebKit Bug 261936).

## 현상

- 공백이 `%2520`으로 깨짐, 한글은 `%EC%88%98` 정상 → **부분** 재인코딩
- 복사-붙여넣기 경로만 영향, 클릭(JS redirect)은 정상
- iOS 집중 + referrer 누락 패턴과 일치

## 원인

`%2520` = `%25`(= `%`) + 원래 있던 `20`. 공백(`%20`)이 한 번 더 인코딩된 것.

```
공백 → %20 → (% 만 재인코딩) → %2520
```

URL 인코딩은 멱등(idempotent)이 아니다 — `encodeURIComponent`를 두 번 하면 값이 달라진다.

진범은 WebKit Bug 261936:

- iOS 16↓: `NSURL URLWithString:`이 invalid char에 `nil`
- iOS 17.0/17.1: invalid char를 자동 percent-encode (regression)
- iOS 17.2: 수정

pasteboard가 NSURL을 만들 때 `%20`은 invalid로 잘못 판단해 재인코딩, 한글 percent-encoding(`%EA%B0%80`)은 valid UTF-8로 통과 → 비대칭의 원인.

## 해결

원인이 외부(OS 버그)면 추적보다 방어가 ROI 높음.

- 화이트리스트 라우트 패턴에서만 디코딩
- 디코딩 후 위험 패턴(`..`, `//`, `\`) 차단
- segment별 `encodeURIComponent` 후 301 redirect

> [!CAUTION]
> 무조건 이중 디코딩 금지 — `..%252f..%252f` → `../../` path traversal 우회 벡터.

## 교훈

- URL은 디코딩된 원본으로 보관, 인코딩은 출력 직전 한 번 (single source of truth)
- "방어적으로 한 번 더"가 함정 — 멱등이 아닌 연산엔 통하지 않는다

## 참고

- [WebKit Bug 261936](https://bugs.webkit.org/show_bug.cgi?id=261936)
- [Changes to URL string parsing in iOS 17 — Augmented Code](https://augmentedcode.io/2023/10/02/changes-to-url-string-parsing-in-ios-17/)
- [OWASP — Double Encoding](https://owasp.org/www-community/Double_Encoding)
- [WHATWG URL Standard](https://url.spec.whatwg.org/)
