Index: content/browser/security_exploit_browsertest.cc |
diff --git a/content/browser/security_exploit_browsertest.cc b/content/browser/security_exploit_browsertest.cc |
index cf003bfe0f300567b765588e748d093cad00b205..872cdd487e0dca4dac0994a43edbd544fe18b7d0 100644 |
--- a/content/browser/security_exploit_browsertest.cc |
+++ b/content/browser/security_exploit_browsertest.cc |
@@ -559,4 +559,57 @@ IN_PROC_BROWSER_TEST_F(SecurityExploitBrowserTest, MismatchedOriginOnCommit) { |
ResourceDispatcherHost::Get()->SetDelegate(nullptr); |
} |
+// Test that a compromised renderer cannot ask to upload an arbitrary file in |
+// OpenURL. This is a regression test for https://crbug.com/726067. |
+IN_PROC_BROWSER_TEST_F(SecurityExploitBrowserTest, |
+ OpenUrl_ResourceRequestBody) { |
+ GURL start_url(embedded_test_server()->GetURL("/title1.html")); |
+ GURL target_url(embedded_test_server()->GetURL("/echoall")); |
+ EXPECT_TRUE(NavigateToURL(shell(), start_url)); |
+ |
+ FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) |
+ ->GetFrameTree() |
+ ->root(); |
+ |
+ RenderProcessHostWatcher exit_observer( |
+ root->current_frame_host()->GetProcess(), |
+ RenderProcessHostWatcher::WATCH_FOR_PROCESS_EXIT); |
+ |
+ // Prepare a file to upload. |
+ base::ThreadRestrictions::ScopedAllowIO allow_io_for_temp_dir; |
+ base::ScopedTempDir temp_dir; |
+ base::FilePath file_path; |
+ std::string file_content("test-file-content"); |
+ ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); |
+ ASSERT_TRUE(base::CreateTemporaryFileInDir(temp_dir.GetPath(), &file_path)); |
+ ASSERT_LT( |
+ 0, base::WriteFile(file_path, file_content.data(), file_content.size())); |
+ |
+ // Simulate an IPC message asking to POST a file that the renderer shouldn't |
+ // have access to. |
+ FrameHostMsg_OpenURL_Params params; |
+ params.url = target_url; |
+ params.uses_post = true; |
+ params.resource_request_body = new ResourceRequestBodyImpl; |
+ params.resource_request_body->AppendFileRange( |
+ file_path, 0, file_content.size(), base::Time()); |
+ params.disposition = WindowOpenDisposition::CURRENT_TAB; |
+ params.should_replace_current_entry = true; |
+ params.user_gesture = true; |
+ params.is_history_navigation_in_new_child = false; |
+ |
+ FrameHostMsg_OpenURL msg(root->current_frame_host()->routing_id(), params); |
+ IPC::IpcSecurityTestUtil::PwnMessageReceived( |
+ root->current_frame_host()->GetProcess()->GetChannel(), msg); |
+ |
+ // Verify that the malicious navigation did not commit the navigation to |
+ // |target_url|. |
+ WaitForLoadStop(shell()->web_contents()); |
+ EXPECT_EQ(start_url, root->current_frame_host()->GetLastCommittedURL()); |
+ |
+ // Verify that the malicious renderer got killed. |
+ exit_observer.Wait(); |
+ EXPECT_FALSE(exit_observer.did_exit_normally()); |
+} |
+ |
} // namespace content |