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

Side by Side Diff: components/password_manager/content/browser/content_password_manager_driver.cc

Issue 1212163007: Kill renderers for bad password forms in --site-per-process. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: adding test, bad message Created 5 years, 5 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "components/password_manager/content/browser/content_password_manager_d river.h" 5 #include "components/password_manager/content/browser/content_password_manager_d river.h"
6 6
7 #include "components/autofill/content/common/autofill_messages.h" 7 #include "components/autofill/content/common/autofill_messages.h"
8 #include "components/autofill/core/common/form_data.h" 8 #include "components/autofill/core/common/form_data.h"
9 #include "components/autofill/core/common/password_form.h" 9 #include "components/autofill/core/common/password_form.h"
10 #include "components/password_manager/content/browser/bad_message.h"
10 #include "components/password_manager/content/browser/content_password_manager_d river_factory.h" 11 #include "components/password_manager/content/browser/content_password_manager_d river_factory.h"
11 #include "components/password_manager/core/browser/password_manager_client.h" 12 #include "components/password_manager/core/browser/password_manager_client.h"
12 #include "content/public/browser/browser_context.h" 13 #include "content/public/browser/browser_context.h"
14 #include "content/public/browser/child_process_security_policy.h"
13 #include "content/public/browser/navigation_details.h" 15 #include "content/public/browser/navigation_details.h"
14 #include "content/public/browser/navigation_entry.h" 16 #include "content/public/browser/navigation_entry.h"
15 #include "content/public/browser/render_frame_host.h" 17 #include "content/public/browser/render_frame_host.h"
18 #include "content/public/browser/render_process_host.h"
16 #include "content/public/browser/render_view_host.h" 19 #include "content/public/browser/render_view_host.h"
17 #include "content/public/browser/site_instance.h" 20 #include "content/public/browser/site_instance.h"
18 #include "content/public/browser/web_contents.h" 21 #include "content/public/browser/web_contents.h"
19 #include "content/public/common/ssl_status.h" 22 #include "content/public/common/ssl_status.h"
20 #include "ipc/ipc_message_macros.h" 23 #include "ipc/ipc_message_macros.h"
21 #include "net/cert/cert_status_flags.h" 24 #include "net/cert/cert_status_flags.h"
22 25
23 namespace password_manager { 26 namespace password_manager {
24 27
25 ContentPasswordManagerDriver::ContentPasswordManagerDriver( 28 ContentPasswordManagerDriver::ContentPasswordManagerDriver(
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 PasswordAutofillManager::OnShowPasswordSuggestions) 147 PasswordAutofillManager::OnShowPasswordSuggestions)
145 IPC_MESSAGE_FORWARD(AutofillHostMsg_RecordSavePasswordProgress, client_, 148 IPC_MESSAGE_FORWARD(AutofillHostMsg_RecordSavePasswordProgress, client_,
146 PasswordManagerClient::LogSavePasswordProgress) 149 PasswordManagerClient::LogSavePasswordProgress)
147 IPC_MESSAGE_UNHANDLED(handled = false) 150 IPC_MESSAGE_UNHANDLED(handled = false)
148 IPC_END_MESSAGE_MAP() 151 IPC_END_MESSAGE_MAP()
149 return handled; 152 return handled;
150 } 153 }
151 154
152 void ContentPasswordManagerDriver::OnPasswordFormsParsed( 155 void ContentPasswordManagerDriver::OnPasswordFormsParsed(
153 const std::vector<autofill::PasswordForm>& forms) { 156 const std::vector<autofill::PasswordForm>& forms) {
157 for (const auto& form : forms)
158 if (!CheckChildProcessSecurityPolicy(form.origin))
159 return;
154 GetPasswordManager()->OnPasswordFormsParsed(this, forms); 160 GetPasswordManager()->OnPasswordFormsParsed(this, forms);
155 } 161 }
156 162
157 void ContentPasswordManagerDriver::OnPasswordFormsRendered( 163 void ContentPasswordManagerDriver::OnPasswordFormsRendered(
158 const std::vector<autofill::PasswordForm>& visible_forms, 164 const std::vector<autofill::PasswordForm>& visible_forms,
159 bool did_stop_loading) { 165 bool did_stop_loading) {
166 for (const auto& form : visible_forms)
167 if (!CheckChildProcessSecurityPolicy(form.origin))
168 return;
160 GetPasswordManager()->OnPasswordFormsRendered(this, visible_forms, 169 GetPasswordManager()->OnPasswordFormsRendered(this, visible_forms,
161 did_stop_loading); 170 did_stop_loading);
162 } 171 }
163 172
164 void ContentPasswordManagerDriver::OnPasswordFormSubmitted( 173 void ContentPasswordManagerDriver::OnPasswordFormSubmitted(
165 const autofill::PasswordForm& password_form) { 174 const autofill::PasswordForm& password_form) {
175 if (!CheckChildProcessSecurityPolicy(password_form.origin))
176 return;
166 GetPasswordManager()->OnPasswordFormSubmitted(this, password_form); 177 GetPasswordManager()->OnPasswordFormSubmitted(this, password_form);
167 } 178 }
168 179
169 void ContentPasswordManagerDriver::OnFocusedPasswordFormFound( 180 void ContentPasswordManagerDriver::OnFocusedPasswordFormFound(
170 const autofill::PasswordForm& password_form) { 181 const autofill::PasswordForm& password_form) {
182 if (!CheckChildProcessSecurityPolicy(password_form.origin))
183 return;
171 GetPasswordManager()->OnPasswordFormForceSaveRequested(this, password_form); 184 GetPasswordManager()->OnPasswordFormForceSaveRequested(this, password_form);
172 } 185 }
173 186
174 void ContentPasswordManagerDriver::DidNavigateFrame( 187 void ContentPasswordManagerDriver::DidNavigateFrame(
175 const content::LoadCommittedDetails& details, 188 const content::LoadCommittedDetails& details,
176 const content::FrameNavigateParams& params) { 189 const content::FrameNavigateParams& params) {
177 // Clear page specific data after main frame navigation. 190 // Clear page specific data after main frame navigation.
178 if (!render_frame_host_->GetParent() && !details.is_in_page) { 191 if (!render_frame_host_->GetParent() && !details.is_in_page) {
179 GetPasswordManager()->DidNavigateMainFrame(); 192 GetPasswordManager()->DidNavigateMainFrame();
180 GetPasswordAutofillManager()->DidNavigateMainFrame(); 193 GetPasswordAutofillManager()->DidNavigateMainFrame();
181 } 194 }
182 } 195 }
183 196
184 void ContentPasswordManagerDriver::OnInPageNavigation( 197 void ContentPasswordManagerDriver::OnInPageNavigation(
185 const autofill::PasswordForm& password_form) { 198 const autofill::PasswordForm& password_form) {
199 if (!CheckChildProcessSecurityPolicy(password_form.origin))
200 return;
186 GetPasswordManager()->OnInPageNavigation(this, password_form); 201 GetPasswordManager()->OnInPageNavigation(this, password_form);
187 } 202 }
188 203
189 void ContentPasswordManagerDriver::OnPasswordNoLongerGenerated( 204 void ContentPasswordManagerDriver::OnPasswordNoLongerGenerated(
190 const autofill::PasswordForm& password_form) { 205 const autofill::PasswordForm& password_form) {
206 if (!CheckChildProcessSecurityPolicy(password_form.origin))
207 return;
191 GetPasswordManager()->SetHasGeneratedPasswordForForm(this, password_form, 208 GetPasswordManager()->SetHasGeneratedPasswordForForm(this, password_form,
192 false); 209 false);
193 } 210 }
194 211
212 bool ContentPasswordManagerDriver::CheckChildProcessSecurityPolicy(
213 const GURL& url) {
214 content::ChildProcessSecurityPolicy* policy =
215 content::ChildProcessSecurityPolicy::GetInstance();
216 if (!policy->CanAccessDataForOrigin(render_frame_host_->GetProcess()->GetID(),
217 url)) {
218 bad_message::ReceivedBadMessage(render_frame_host_->GetProcess(),
219 bad_message::CPMD_BAD_ORIGIN);
ncarter (slow) 2015/07/07 22:18:32 Usually we've used a different bad_message reason
lfg 2015/07/08 15:31:47 Done.
220 return false;
221 }
222
223 return true;
224 }
225
195 } // namespace password_manager 226 } // namespace password_manager
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698