Clean up trailing and leading whitespace

This commit is contained in:
James Espinosa
2014-07-05 19:15:32 -05:00
parent 6ea16fbe18
commit 68e6a01743
75 changed files with 499 additions and 499 deletions
@@ -45,17 +45,17 @@
</p>
<p class="desc">
Any attribute added to the attr_accessible setting can be used during a mass assignment call. What this means is that conceptually, the following is allowed:
</p>
</p>
<pre class="ruby">
# Note the string "true"/"false" or 1/0, etc. can be added to specify the boolean attribute...
# is true or false thanks to ActiveRecord
User.new(:email => "email@email.com",
:admin => "true",
:password => "h4xx0r",
:first_name => "Captain",
User.new(:email => "email@email.com",
:admin => "true",
:password => "h4xx0r",
:first_name => "Captain",
:last_name => "Crunch"
)
</pre>
</pre>
</div>
</div>
</div>
@@ -72,8 +72,8 @@
<p><b> Mass Assignment ATTACK:</b></p>
<p class="desc">
Through the use of an intercepting proxy, we are able to capture our form submission after entering our information on the sign up page. The request looks like this...
</p>
<pre class="ruby">
</p>
<pre class="ruby">
POST /users HTTP/1.1
Host: railsgoat.dev
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:19.0) Gecko/20100101 Firefox/19.0
@@ -87,12 +87,12 @@
Content-Length: 248
utf8=✓&authenticity_token=GXhLKKhfBXdFx5i6iqHEd5E32Kebn1+G35eA87RW1tU=&user[email]=test@test.com&user[first_name]=test&user[last_name]=test&user[password]=testtest&user[password_confirmation]=testtest&commit=Submit
</pre>
</pre>
<p>
...and the attack is quite simple. Append a parameter to the body of this POST request that specifies the admin value is true.
</p>
<pre class="ruby"> utf8=✓&authenticity_token=GXhLKKhfBXdFx5i6iqHEd5E32Kebn1+G35eA87RW1tU=&user[email]=test@test.com&user[first_name]=test&user[last_name]=test&user[password]=testtest&user[password_confirmation]=testtest&commit=Submit&<span style="background-color: yellow">user[admin]=true</span>
</pre>
</pre>
<p class="desc">
So when the request is received by the create method within the user controller (code shown below), the admin attribute is set to true upon user creation.
</p>
@@ -114,18 +114,18 @@
</pre>
<p class="desc">
The last thing to mention here is that this can be done either through the signup page or when you edit your account settings.
</p>
</p>
<p><b> Mass Assignment SOLUTION:</b></p>
<p class="desc">
The solution is fairly simple, remove the admin attribute from the attr_accessible method. The following code shows what we mean:
</p>
<pre class="ruby">
<span style="background-color:yellow"># Note that the admin attr has been removed </span>
<%= %q{
<%= %q{
class User < ActiveRecord::Base
attr_accessible :email, :password, :password_confirmation, :first_name, :last_name
} %>
</pre>
</pre>
</div>
</div>
</div>
@@ -144,7 +144,7 @@
</p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>