Bug 165824 - [Mac][WK2] Stop using file* rules in WebProcess sandbox profiles
Summary: [Mac][WK2] Stop using file* rules in WebProcess sandbox profiles
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit2 (show other bugs)
Version: WebKit Nightly Build
Hardware: Mac All
: P2 Normal
Assignee: Brent Fulgham
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2016-12-13 15:24 PST by Brent Fulgham
Modified: 2016-12-21 14:03 PST (History)
6 users (show)

See Also:


Attachments
Patch (3.80 KB, patch)
2016-12-13 15:27 PST, Brent Fulgham
no flags Details | Formatted Diff | Diff
Patch (4.89 KB, patch)
2016-12-14 10:24 PST, Brent Fulgham
no flags Details | Formatted Diff | Diff
Patch (4.32 KB, patch)
2016-12-14 11:17 PST, Brent Fulgham
no flags Details | Formatted Diff | Diff
Patch (5.83 KB, patch)
2016-12-14 17:44 PST, Brent Fulgham
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Brent Fulgham 2016-12-13 15:24:40 PST
Make the WebProcess sandbox profile more like the NetworkProcess by getting rid of the global "file*" rules, switching to more finely-focused versions.

Similar changes should be made in the Databases and Plugin sandboxes.
Comment 1 Brent Fulgham 2016-12-13 15:25:03 PST
<rdar://problem/14024823>
Comment 2 Brent Fulgham 2016-12-13 15:27:07 PST
Created attachment 297046 [details]
Patch
Comment 3 Alex Christensen 2016-12-13 16:03:07 PST
(In reply to comment #0)
> Make the WebProcess sandbox profile more like the NetworkProcess by getting
> rid of the global "file*" rules, switching to more finely-focused versions.
> 
> Similar changes should be made in the Databases and Plugin sandboxes.
Why not make them all at once?
Comment 4 Alexey Proskuryakov 2016-12-13 18:14:26 PST
Comment on attachment 297046 [details]
Patch

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

> Source/WebKit2/PluginProcess/mac/com.apple.WebKit.plugin-common.sb.in:262
> +(allow file-read* file-write* (subpath (param "NSURL_CACHE_DIR")))

I think that CFNetwork may need to issue sandbox extensions for cache content.

> Source/WebKit2/WebProcess/com.apple.WebProcess.sb.in:173
> +        (allow file-issue-extension (require-all (extension-class "com.apple.app-sandbox.read") (subpath (param "DARWIN_USER_TEMP_DIR"))))))

Did you test uploading packages? I'm not entirely sure if read extensions are all we use.
Comment 5 Alexey Proskuryakov 2016-12-13 18:15:12 PST
This seems worth trying, but I wouldn't be surprised if this broke something.
Comment 6 Brent Fulgham 2016-12-14 09:39:36 PST
(In reply to comment #4)
> Comment on attachment 297046 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=297046&action=review
> 
> > Source/WebKit2/PluginProcess/mac/com.apple.WebKit.plugin-common.sb.in:262
> > +(allow file-read* file-write* (subpath (param "NSURL_CACHE_DIR")))
> 
> I think that CFNetwork may need to issue sandbox extensions for cache
> content.

OK. I'll adjust the rules for that.

> > Source/WebKit2/WebProcess/com.apple.WebProcess.sb.in:173
> > +        (allow file-issue-extension (require-all (extension-class "com.apple.app-sandbox.read") (subpath (param "DARWIN_USER_TEMP_DIR"))))))
> 
> Did you test uploading packages? I'm not entirely sure if read extensions
> are all we use.

I did find that I needed to use "com.apple.app-sandbox.read-write" during my local testing (after uploading this patch). I'll use the read-write extension-class when landing this change.
Comment 7 Alexey Proskuryakov 2016-12-14 09:43:50 PST
> I did find that I needed to use "com.apple.app-sandbox.read-write" during my local testing (after uploading this patch).

Do we need com.apple.app-sandbox.read too?
Comment 8 Brent Fulgham 2016-12-14 10:24:11 PST
Created attachment 297099 [details]
Patch
Comment 9 Brent Fulgham 2016-12-14 11:17:51 PST
Created attachment 297103 [details]
Patch
Comment 10 Brent Fulgham 2016-12-14 11:18:10 PST
Comment on attachment 297103 [details]
Patch

Rebaselined patch.
Comment 11 Brent Fulgham 2016-12-14 11:20:53 PST
We should probably wait to land this until next week.
Comment 12 Brent Fulgham 2016-12-14 17:44:06 PST
Created attachment 297150 [details]
Patch
Comment 13 Brent Fulgham 2016-12-14 17:44:34 PST
Updated patch to support "read" and "read-write" extensions.
Comment 14 Alexey Proskuryakov 2016-12-15 09:49:47 PST
Comment on attachment 297150 [details]
Patch

Scary, but worth trying.
Comment 15 Brent Fulgham 2016-12-21 13:39:09 PST
We can land this now! cq+.
Comment 16 WebKit Commit Bot 2016-12-21 14:03:31 PST
Comment on attachment 297150 [details]
Patch

Clearing flags on attachment: 297150

Committed r210076: <http://trac.webkit.org/changeset/210076>
Comment 17 WebKit Commit Bot 2016-12-21 14:03:35 PST
All reviewed patches have been landed.  Closing bug.