← All issues

Untrusted image data restricted from ImageIO codec dispatch in WebExtension icon loading

b9c7a1b

Apple 플랫폼의 ImageIO는 입력 데이터 앞부분의 magic bytes를 검사하여 codec을 선택합니다. [NSImage initWithData]는 이 dispatch를 아무런 제약 없이 위임하기 때문에, 시스템에 등록된 모든 codec이 공격자가 제공한 bytes에 의해 호출될 수 있습니다. PSD, OpenEXR, raw TIFF 같은 희귀한 포맷도 예외가 아닙니다. WebExtension 아이콘은 UIProcess에서 로드되는데, UIProcess는 WebContent와 달리 sandbox 제한을 받지 않습니다. 따라서 이 경로에서 codec vulnerability가 발생하면 영향도가 더 높아집니다.

Source/WebKit/Platform/cocoa/CocoaImage.mm

+RetainPtr<CocoaImage> createCocoaImageRestrictedToSupportedTypes(NSData *data, double displayScale)
+{
+ RetainPtr imageSource = adoptCF(CGImageSourceCreateWithData((__bridge CFDataRef)data, nullptr));
+ if (!imageSource)
+ return nil;
+ RetainPtr type = CGImageSourceGetType(imageSource.get());
+ if (!type || !WebCore::isSupportedImageType(type.get()))
+ return nil;
+ RetainPtr image = adoptCF(CGImageSourceCreateImageAtIndex(imageSource.get(), 0, nullptr));
+ ...
+}

이번 수정은 [NSImage initWithData]를 3단계 방식으로 대체합니다. 먼저 CGImageSourceGetType으로 타입을 감지하고, WebCore::isSupportedImageType()(웹 콘텐츠에 적용되는 것과 동일한 allowlist)으로 통과 여부를 판별한 뒤, CGImageSourceCreateImageAtIndex로 디코딩합니다. SVG는 CoreGraphics 경로를 우회하여 macOS에서는 _NSSVGImageRep, iOS에서는 CoreSVG를 통해 별도로 처리됩니다.

가장 영향도가 높은 프로세스에서의 codec dispatch를 웹 콘텐츠와 동일한 allowlist로 제한함으로써, 공격자가 제어하는 magic bytes가 감사가 거의 이루어지지 않은 ImageIO decoder(PSD, OpenEXR, TIFF)를 sandbox 밖에서 호출하는 경로를 차단합니다.

🔒

The SVG routing path and the new type-gating mechanism both have properties that bypass protection researchers should examine.

더 확인하려면 구독해 주세요