Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(58)

Side by Side Diff: content/browser/security_exploit_browsertest.cc

Issue 2908433003: RenderFrameProxyHost::OnOpenURL needs to validate resource request body. (Closed)
Patch Set: Rebasing... Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <stdint.h> 5 #include <stdint.h>
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/containers/hash_tables.h" 8 #include "base/containers/hash_tables.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after
552 // terminated. However, the notification for that should be processed in a 552 // terminated. However, the notification for that should be processed in a
553 // separate task of the message loop, so ensure that the process is still 553 // separate task of the message loop, so ensure that the process is still
554 // considered alive. 554 // considered alive.
555 EXPECT_TRUE(root->current_frame_host()->GetProcess()->HasConnection()); 555 EXPECT_TRUE(root->current_frame_host()->GetProcess()->HasConnection());
556 556
557 exit_observer.Wait(); 557 exit_observer.Wait();
558 EXPECT_FALSE(exit_observer.did_exit_normally()); 558 EXPECT_FALSE(exit_observer.did_exit_normally());
559 ResourceDispatcherHost::Get()->SetDelegate(nullptr); 559 ResourceDispatcherHost::Get()->SetDelegate(nullptr);
560 } 560 }
561 561
562 // Test that a compromised renderer cannot ask to upload an arbitrary file in
563 // OpenURL. This is a regression test for https://crbug.com/726067.
564 IN_PROC_BROWSER_TEST_F(SecurityExploitBrowserTest,
565 OpenUrl_ResourceRequestBody) {
566 GURL start_url(embedded_test_server()->GetURL("/title1.html"));
567 GURL target_url(embedded_test_server()->GetURL("/echoall"));
568 EXPECT_TRUE(NavigateToURL(shell(), start_url));
569
570 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents())
571 ->GetFrameTree()
572 ->root();
573
574 RenderProcessHostWatcher exit_observer(
575 root->current_frame_host()->GetProcess(),
576 RenderProcessHostWatcher::WATCH_FOR_PROCESS_EXIT);
577
578 // Prepare a file to upload.
579 base::ThreadRestrictions::ScopedAllowIO allow_io_for_temp_dir;
580 base::ScopedTempDir temp_dir;
581 base::FilePath file_path;
582 std::string file_content("test-file-content");
583 ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
584 ASSERT_TRUE(base::CreateTemporaryFileInDir(temp_dir.GetPath(), &file_path));
585 ASSERT_LT(
586 0, base::WriteFile(file_path, file_content.data(), file_content.size()));
587
588 // Simulate an IPC message asking to POST a file that the renderer shouldn't
589 // have access to.
590 FrameHostMsg_OpenURL_Params params;
591 params.url = target_url;
592 params.uses_post = true;
593 params.resource_request_body = new ResourceRequestBodyImpl;
594 params.resource_request_body->AppendFileRange(
595 file_path, 0, file_content.size(), base::Time());
596 params.disposition = WindowOpenDisposition::CURRENT_TAB;
597 params.should_replace_current_entry = true;
598 params.user_gesture = true;
599 params.is_history_navigation_in_new_child = false;
600
601 FrameHostMsg_OpenURL msg(root->current_frame_host()->routing_id(), params);
602 IPC::IpcSecurityTestUtil::PwnMessageReceived(
603 root->current_frame_host()->GetProcess()->GetChannel(), msg);
604
605 // Verify that the malicious navigation did not commit the navigation to
606 // |target_url|.
607 WaitForLoadStop(shell()->web_contents());
608 EXPECT_EQ(start_url, root->current_frame_host()->GetLastCommittedURL());
609
610 // Verify that the malicious renderer got killed.
611 exit_observer.Wait();
612 EXPECT_FALSE(exit_observer.did_exit_normally());
613 }
614
562 } // namespace content 615 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/frame_host/render_frame_proxy_host.cc ('k') | tools/metrics/histograms/enums.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698