Bug 198966 - StorageManager::removeAllowedSessionStorageNamespaceConnection should make sure its storageNamespaceID is valid
Summary: StorageManager::removeAllowedSessionStorageNamespaceConnection should make su...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit Misc. (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: youenn fablet
URL:
Keywords: InRadar
: 199208 (view as bug list)
Depends on:
Blocks:
 
Reported: 2019-06-18 09:03 PDT by youenn fablet
Modified: 2019-07-01 16:58 PDT (History)
4 users (show)

See Also:


Attachments
Patch (2.25 KB, patch)
2019-06-18 09:14 PDT, youenn fablet
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description youenn fablet 2019-06-18 09:03:06 PDT
StorageManager::removeAllowedSessionStorageNamespaceConnection should make sure its storageNamespaceID is valid
Comment 1 youenn fablet 2019-06-18 09:07:17 PDT
<rdar://problem/51352080>
Comment 2 youenn fablet 2019-06-18 09:14:10 PDT
Created attachment 372341 [details]
Patch
Comment 3 Sihui Liu 2019-06-18 10:10:39 PDT
Comment on attachment 372341 [details]
Patch

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

> Source/WebKit/ChangeLog:10
> +        The namespace ID is coming straight from IPC so should not be trusted.

I agree with this, but I don't think this crash is caused by untrusted message sent to web process. Likely there is a bug in the code (e.g. web page was removed before it's getting added because of some race), and using the If condition here will conceal the real bug.

But as we also don't like the idea of notifying network process when page is added/removed in web process for sessionStorage, this may be a good enough fix before we drop those code.

> Source/WebKit/ChangeLog:13
> +        Also, namespace IDs are added/removed based on web pages being created/deleted.
> +        Namespace IDs are supposed to be scoped by session IDs.
> +        Using page IDs for namespace IDs works as long as the page does not change of session ID during its lifetime, which is not guaranteed.

If my understanding is correct, if page is changing its session, it should add itself to new storage session(StorageManager) first, which will create a new sessionStorageNameSpace that have the corresponding namespace/page ID.
Comment 4 youenn fablet 2019-06-18 10:38:25 PDT
> I agree with this, but I don't think this crash is caused by untrusted
> message sent to web process. Likely there is a bug in the code (e.g. web
> page was removed before it's getting added because of some race), and using
> the If condition here will conceal the real bug.
> 
> But as we also don't like the idea of notifying network process when page is
> added/removed in web process for sessionStorage, this may be a good enough
> fix before we drop those code.

Yes, the patch is only about fixing the crash.
It should be completed by either retiring the use of page IDs, or making it fully working.
I think the end goal should be to retire the use of page IDs here.

> > Source/WebKit/ChangeLog:13
> > +        Also, namespace IDs are added/removed based on web pages being created/deleted.
> > +        Namespace IDs are supposed to be scoped by session IDs.
> > +        Using page IDs for namespace IDs works as long as the page does not change of session ID during its lifetime, which is not guaranteed.
> 
> If my understanding is correct, if page is changing its session, it should
> add itself to new storage session(StorageManager) first, which will create a
> new sessionStorageNameSpace that have the corresponding namespace/page ID.

I am not sure what we want in the short term.
Maybe it is ok to fix this one before trying to remove the page ID usage.
I fear that we may see other bugs in that area until we remove page ID usage.
Comment 5 youenn fablet 2019-06-18 10:39:35 PDT
> I agree with this, but I don't think this crash is caused by untrusted
> message sent to web process. Likely there is a bug in the code (e.g. web
> page was removed before it's getting added because of some race), and using
> the If condition here will conceal the real bug.

There is a debug assertion to catch the real bug.
The crash might come from session ID change.
Comment 6 WebKit Commit Bot 2019-06-18 11:10:14 PDT
Comment on attachment 372341 [details]
Patch

Clearing flags on attachment: 372341

Committed r246552: <https://trac.webkit.org/changeset/246552>
Comment 7 WebKit Commit Bot 2019-06-18 11:10:16 PDT
All reviewed patches have been landed.  Closing bug.
Comment 8 Alex Christensen 2019-06-25 16:27:31 PDT
*** Bug 199208 has been marked as a duplicate of this bug. ***