Skip to content

merge_pr_65038

Choose a tag to compare

@github-actions github-actions released this 11 Nov 15:48

Crash in DataTransfer::updateFileList() because the dragstart DataTransfer stays writable after dispatch

EventHandler::handleDrag() dispatches dragstart with a separate
read/write DataTransfer, then calls moveDragState() to move its state
into dragState().dataTransfer. Only dragState().dataTransfer was then
made invalid for security. The DataTransfer that script can see stayed
in read/write mode for as long as script kept a reference to it.

moveDragState() also moves m_fileList away from that object. If script
used dataTransfer.items during dragstart and later, for example in a
setTimeout, called items.add(file) and then items.remove(0), add()
succeeded, didAddFileToItemList() returned early because m_fileList was
null, and remove() called updateFileList(), which dereferenced the null
m_fileList.

Per the HTML spec, once a DND event has been dispatched the DataTransfer
is no longer associated with the drag data store, so its item list is in
disabled mode: add() must return null and remove() must throw an
InvalidStateError.

Fix this by making the dragstart DataTransfer invalid for security
before moving its state. Also make updateFileList() return early when
m_fileList is null, matching didAddFileToItemList().

WebKit-Bug: https://bugs.webkit.org/show_bug.cgi?id=330861
WebKit-Canonical-Link: https://commits.webkit.org/326392@main