Bug 237100 - Restrict supported image decoding types when in CaptivePortal mode
Summary: Restrict supported image decoding types when in CaptivePortal mode
Status: RESOLVED INVALID
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit Misc. (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Brent Fulgham
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2022-02-23 11:53 PST by Brent Fulgham
Modified: 2022-02-23 16:22 PST (History)
5 users (show)

See Also:


Attachments
Patch (2.89 KB, patch)
2022-02-23 12:02 PST, Brent Fulgham
no flags Details | Formatted Diff | Diff
Patch (2.88 KB, patch)
2022-02-23 13:39 PST, Brent Fulgham
darin: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Brent Fulgham 2022-02-23 11:53:53 PST
Adopt the CGImageSourceSetAllowableTypes SPI to prevent CoreGraphics from running image decoders for riskier image types.
Comment 1 Radar WebKit Bug Importer 2022-02-23 11:54:15 PST
<rdar://problem/89369518>
Comment 2 Brent Fulgham 2022-02-23 12:02:30 PST
Created attachment 453010 [details]
Patch
Comment 3 Brent Fulgham 2022-02-23 13:39:22 PST
Created attachment 453023 [details]
Patch
Comment 4 Darin Adler 2022-02-23 15:01:29 PST
Comment on attachment 453023 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=453023&action=review

> Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm:248
> +#if HAVE(CGIMAGESOURCE_WITH_SET_ALLOWABLE_TYPES)
> +static NSArray *UTITypes()
> +{
> +    return @[@"public.jpeg",
> +        @"public.png",
> +        @"org.webmproject.webp",
> +        @"com.compuserve.gif",
> +    ];
> +}
> +#endif

Does not seem like we need a separate function for this.

    NSArray *types = @[
        @"public.jpeg",
        @"public.png",
        @"org.webmproject.webp",
        @"com.compuserve.gif",
    ];
    auto status = CGImageSourceSetAllowableTypes(bridge_cast(types));

Could even use auto or constexpr.

> Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm:255
> +#if HAVE(CGIMAGESOURCE_WITH_SET_ALLOWABLE_TYPES)

I think we should format the #if differently. Strange to just check the boolean and then do nothing, so maybe we can put more of the function inside the #if, or put the #if at the call site too.
Comment 6 Brent Fulgham 2022-02-23 15:58:13 PST
See Bug 237120 for the actual issue.
Comment 7 Brent Fulgham 2022-02-23 16:22:18 PST
After reviewing this with the CoreGraphics/ImageIO team, we don't need to do this, as we have already adopted the necessary entitlements to limit decoders in Captive Portal mode.

The cause of PDF images still appearing is a separate issue, which requires a different fix (see Bug 237120).