From 7636b510a2cfc48bd0281374596f3c7caf1f7edf Mon Sep 17 00:00:00 2001 From: Christophe Simonis Date: Tue, 11 Aug 2015 15:03:41 +0200 Subject: [PATCH] [ADD] *: CSRF protection in forms and routes * make CSRF protection the default on all non-SAFE methods note: there currently is no way to call a CSRF-protected endpoint without a form-encoded entity-body as that's the only place we get the CSRF token from. * simple CSRF token generation: just use the HMAC'd session id, no generating a new random token per session then HMAC it * use constant-time equal function to avoid timing attacks * assert that a database secret is configured before hashing/validating the CSRF token * opt-out database manager from CSRF: The super-admin password serves the purpose of a CSRF token in the database manager screens. There is no request database to obtain the secret and generate a CSRF token. --- .../auth_signup/views/auth_signup_login.xml | 2 + addons/base_import/controllers.py | 2 +- addons/payment_ogone/controllers/main.py | 2 +- addons/payment_ogone/views/ogone.xml | 1 + addons/payment_transfer/controllers/main.py | 2 +- .../models/payment_acquirer.py | 2 +- addons/payment_transfer/views/transfer.xml | 4 +- addons/survey/controllers/main.py | 2 +- addons/survey/views/survey_templates.xml | 1 + addons/web/controllers/main.py | 12 ++-- addons/web/views/webclient_templates.xml | 1 + addons/web_editor/static/src/xml/editor.xml | 2 + addons/website/data/demo.xml | 1 + .../static/src/xml/website.gallery.xml | 1 + addons/website/views/website_templates.xml | 1 + addons/website_blog/controllers/main.py | 2 +- .../views/website_blog_templates.xml | 9 +-- addons/website_crm/views/website_crm.xml | 1 + addons/website_event/views/website_event.xml | 2 + .../views/website_event.xml | 1 + addons/website_forum/views/website_forum.xml | 10 +++ .../website_forum_doc/views/website_doc.xml | 1 + .../views/templates.xml | 1 + addons/website_mail/views/website_mail.xml | 1 + .../views/unsubscribe.xml | 5 +- .../views/website_payment_templates.xml | 1 + addons/website_portal/views/templates.xml | 1 + addons/website_quote/controllers/main.py | 4 +- .../website_quote/views/website_quotation.xml | 4 +- addons/website_sale/views/templates.xml | 11 ++- addons/website_slides/view/website_slides.xml | 1 + openerp/http.py | 72 +++++++++++++++++-- openerp/tools/misc.py | 8 +++ 33 files changed, 139 insertions(+), 32 deletions(-) diff --git a/addons/auth_signup/views/auth_signup_login.xml b/addons/auth_signup/views/auth_signup_login.xml index 149c490ad69..ab639267294 100644 --- a/addons/auth_signup/views/auth_signup_login.xml +++ b/addons/auth_signup/views/auth_signup_login.xml @@ -38,6 +38,7 @@