@@ -1342,6 +1342,21 @@ void RenderViewHostImpl::OnMsgStartDragging(
1342
1342
if (!filtered_data.url .SchemeIs (chrome::kJavaScriptScheme ))
1343
1343
FilterURL (policy, GetProcess ()->GetID (), true , &filtered_data.url );
1344
1344
FilterURL (policy, GetProcess ()->GetID (), false , &filtered_data.html_base_url );
1345
+ // Filter out any paths that the renderer didn't have access to. This prevents
1346
+ // the following attack on a malicious renderer:
1347
+ // 1. StartDragging IPC sent with renderer-specified filesystem paths that it
1348
+ // doesn't have read permissions for.
1349
+ // 2. We initiate a native DnD operation.
1350
+ // 3. DnD operation immediately ends since mouse is not held down. DnD events
1351
+ // still fire though, which causes read permissions to be granted to the
1352
+ // renderer for any file paths in the drop.
1353
+ filtered_data.filenames .clear ();
1354
+ for (std::vector<string16>::const_iterator it = drop_data.filenames .begin ();
1355
+ it != drop_data.filenames .end (); ++it) {
1356
+ FilePath path (FilePath::FromUTF8Unsafe (UTF16ToUTF8 (*it)));
1357
+ if (policy->CanReadFile (GetProcess ()->GetID (), path))
1358
+ filtered_data.filenames .push_back (*it);
1359
+ }
1345
1360
view->StartDragging (filtered_data, drag_operations_mask, image, image_offset);
1346
1361
}
1347
1362
0 commit comments