Convert file indentation to spaces
This commit is contained in:
@@ -11,7 +11,7 @@
|
||||
<a href="#collapseFive" data-parent="#accordion1" data-toggle="collapse" class="accordion-toggle">
|
||||
<i class="icon-info icon-white">
|
||||
</i>
|
||||
Description
|
||||
Description
|
||||
</a>
|
||||
</div>
|
||||
<div class="accordion-body in collapse" id="collapseFive" style="height: auto;">
|
||||
@@ -33,30 +33,30 @@
|
||||
<div class="accordion-body collapse" id="collapseSix" style="height: 0px;">
|
||||
<div class="accordion-inner">
|
||||
<p>
|
||||
The following code was taken from app/views/sessions/new.html.erb:
|
||||
</p>
|
||||
<pre class="javascript">
|
||||
<%=
|
||||
%{
|
||||
<script>
|
||||
//document.write("<select style=\"width: 100px;\">");
|
||||
//document.write("<OPTION value=1>English</OPTION>");
|
||||
//document.write("<OPTION value=2>Spanish</OPTION>");
|
||||
try \{
|
||||
var hashParam = location.hash.split("#")[1];
|
||||
var paramName = hashParam.split('=')[0];
|
||||
var paramValue = hashParam.split('=')[1];
|
||||
document.write("<OPTION value=3>" +} %> <span style="background-color:yellow"> paramValue</span> <%= %{ + "</OPTION>");
|
||||
\} catch(err) \{
|
||||
\}
|
||||
//document.write("</select>");
|
||||
The following code was taken from app/views/sessions/new.html.erb:
|
||||
</p>
|
||||
<pre class="javascript">
|
||||
<%=
|
||||
%{
|
||||
<script>
|
||||
//document.write("<select style=\"width: 100px;\">");
|
||||
//document.write("<OPTION value=1>English</OPTION>");
|
||||
//document.write("<OPTION value=2>Spanish</OPTION>");
|
||||
try \{
|
||||
var hashParam = location.hash.split("#")[1];
|
||||
var paramName = hashParam.split('=')[0];
|
||||
var paramValue = hashParam.split('=')[1];
|
||||
document.write("<OPTION value=3>" +} %> <span style="background-color:yellow"> paramValue</span> <%= %{ + "</OPTION>");
|
||||
\} catch(err) \{
|
||||
\}
|
||||
//document.write("</select>");
|
||||
</script>
|
||||
}
|
||||
%>
|
||||
</pre>
|
||||
<p class="desc">
|
||||
The code (above) takes user input (params), and renders it back on the page without any output encoding or escaping.
|
||||
</p>
|
||||
}
|
||||
%>
|
||||
</pre>
|
||||
<p class="desc">
|
||||
The code (above) takes user input (params), and renders it back on the page without any output encoding or escaping.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -71,40 +71,40 @@
|
||||
<div class="accordion-body collapse" id="collapseSeven" style="height: 0px;">
|
||||
<div class="accordion-inner">
|
||||
<p><b> Stored Cross-Site Scripting ATTACK:</b></p>
|
||||
<p class="desc">
|
||||
Ensure you are signed out of the application first. Make sure you are using something like Firefox as Safari/Chrome won't work for this exercise. Then, use the following link (substitute hostname for your actual hostname) to execute an alert box:
|
||||
</p>
|
||||
<pre>
|
||||
<%= %{http://127.0.0.1:3000/#test=<script>alert(1)</script>} %>
|
||||
</pre>
|
||||
<p><b> Stored Cross-Site Scripting SOLUTION:</b></p>
|
||||
<p>
|
||||
Leverage the Hogan function for escaping (found in the application.js file) to escape user input:
|
||||
</p>
|
||||
<pre class="javascript">
|
||||
<%= %{
|
||||
<!-- support for multiple languages coming soon! -->
|
||||
<script>
|
||||
//document.write("<select style=\"width: 100px;\">");
|
||||
//document.write("<OPTION value=1>English</OPTION>");
|
||||
//document.write("<OPTION value=2>Spanish</OPTION>");
|
||||
try \{
|
||||
var hashParam = location.hash.split("#")[1];
|
||||
var paramName = hashParam.split('=')[0];
|
||||
var paramValue = hashParam.split('=')[1];
|
||||
document.write("<OPTION value=3>" + } %> <span style="background-color:yellow"> hoganEscape(paramValue)</span> <%= %{ + "</OPTION>");
|
||||
\} catch(err) \{
|
||||
\}
|
||||
//document.write("</select>");
|
||||
</script>
|
||||
}
|
||||
<p class="desc">
|
||||
Ensure you are signed out of the application first. Make sure you are using something like Firefox as Safari/Chrome won't work for this exercise. Then, use the following link (substitute hostname for your actual hostname) to execute an alert box:
|
||||
</p>
|
||||
<pre>
|
||||
<%= %{http://127.0.0.1:3000/#test=<script>alert(1)</script>} %>
|
||||
</pre>
|
||||
<p><b> Stored Cross-Site Scripting SOLUTION:</b></p>
|
||||
<p>
|
||||
Leverage the Hogan function for escaping (found in the application.js file) to escape user input:
|
||||
</p>
|
||||
<pre class="javascript">
|
||||
<%= %{
|
||||
<!-- support for multiple languages coming soon! -->
|
||||
<script>
|
||||
//document.write("<select style=\"width: 100px;\">");
|
||||
//document.write("<OPTION value=1>English</OPTION>");
|
||||
//document.write("<OPTION value=2>Spanish</OPTION>");
|
||||
try \{
|
||||
var hashParam = location.hash.split("#")[1];
|
||||
var paramName = hashParam.split('=')[0];
|
||||
var paramValue = hashParam.split('=')[1];
|
||||
document.write("<OPTION value=3>" + } %> <span style="background-color:yellow"> hoganEscape(paramValue)</span> <%= %{ + "</OPTION>");
|
||||
\} catch(err) \{
|
||||
\}
|
||||
//document.write("</select>");
|
||||
</script>
|
||||
}
|
||||
|
||||
%>
|
||||
</pre>
|
||||
%>
|
||||
</pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="accordion-group">
|
||||
<div class="accordion-group">
|
||||
<div class="accordion-heading">
|
||||
<a style="background-color: rgb(181, 121, 158)" href="#collapseEight" data-parent="#accordion1" data-toggle="collapse" class="accordion-toggle">
|
||||
<i class="icon-aid icon-white">
|
||||
@@ -115,11 +115,11 @@
|
||||
<div class="accordion-body collapse" id="collapseEight" style="height: 0px;">
|
||||
<div class="accordion-inner">
|
||||
<p class="desc">
|
||||
You should view the source of the login page, might be something interesting there.
|
||||
</p>
|
||||
You should view the source of the login page, might be something interesting there.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -32,21 +32,21 @@
|
||||
<div class="accordion-inner">
|
||||
<p><b>Stored Cross-Site Scripting - The following code was taken from app/views/layouts/shared/_header.html.erb</b></p>
|
||||
|
||||
<p>
|
||||
<pre class="ruby">
|
||||
<%= @code %>
|
||||
</pre>
|
||||
<p>
|
||||
<pre class="ruby">
|
||||
<%= @code %>
|
||||
</pre>
|
||||
</p>
|
||||
<p class="desc">
|
||||
Coincidentally, HTML safe is not safe from HTML Injection or "XSS" attacks. The name is deceiving. Some folks believe the raw() helper to be different than the html_safe String method. raw() is actually a wrapper for html_safe and essentially ensures exceptions are handled when the expected value is nil.
|
||||
<pre class="ruby">
|
||||
# Psuedo-code to help conceptualize
|
||||
def raw(dirty_string)
|
||||
dirty_string.to_s.html_safe
|
||||
end
|
||||
</pre>
|
||||
<p class="desc">
|
||||
Coincidentally, HTML safe is not safe from HTML Injection or "XSS" attacks. The name is deceiving. Some folks believe the raw() helper to be different than the html_safe String method. raw() is actually a wrapper for html_safe and essentially ensures exceptions are handled when the expected value is nil.
|
||||
<pre class="ruby">
|
||||
# Psuedo-code to help conceptualize
|
||||
def raw(dirty_string)
|
||||
dirty_string.to_s.html_safe
|
||||
end
|
||||
</pre>
|
||||
|
||||
</p>
|
||||
</p>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
@@ -63,16 +63,16 @@
|
||||
<div class="accordion-inner">
|
||||
<p><b> Stored Cross-Site Scripting ATTACK:</b></p>
|
||||
|
||||
<p> When registering, enter your JavaScript tag such as <%= %{<script>alert("ohai")</script>} %> in the First Name field. Upon login the header navigation bar will echo "Welcome" + your JS code. You can have your XSS code point the victim to a <b><%= link_to "BeEF server", "http://beefproject.com", {:style => "color: rgb(69, 126, 136)" } %></b> and have some fun as well.
|
||||
</p>
|
||||
<p><b> Stored Cross-Site Scripting SOLUTION:</b></p>
|
||||
<p>
|
||||
Often developers error on the side of using "html_safe" versus "raw" with the idea being one is safer than the other. In this example, simply removing the .html_safe call would both eliminate the attack (by default, Rails 3.x html encodes these dangerous chars). Rails 2.x would require that any potentially malicious content is wrapped within an h() tag. Potentially malicious content should be thought of anything that is dynamically generated. Also, it is important to note that if for some reason you wanted to render HTML code in literal form, you can use things like sanitize() or strip_tags().
|
||||
</p>
|
||||
<p> When registering, enter your JavaScript tag such as <%= %{<script>alert("ohai")</script>} %> in the First Name field. Upon login the header navigation bar will echo "Welcome" + your JS code. You can have your XSS code point the victim to a <b><%= link_to "BeEF server", "http://beefproject.com", {:style => "color: rgb(69, 126, 136)" } %></b> and have some fun as well.
|
||||
</p>
|
||||
<p><b> Stored Cross-Site Scripting SOLUTION:</b></p>
|
||||
<p>
|
||||
Often developers error on the side of using "html_safe" versus "raw" with the idea being one is safer than the other. In this example, simply removing the .html_safe call would both eliminate the attack (by default, Rails 3.x html encodes these dangerous chars). Rails 2.x would require that any potentially malicious content is wrapped within an h() tag. Potentially malicious content should be thought of anything that is dynamically generated. Also, it is important to note that if for some reason you wanted to render HTML code in literal form, you can use things like sanitize() or strip_tags().
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="accordion-group">
|
||||
<div class="accordion-group">
|
||||
<div class="accordion-heading">
|
||||
<a style="background-color: rgb(181, 121, 158)" href="#collapseFour" data-parent="#accordion1" data-toggle="collapse" class="accordion-toggle">
|
||||
<i class="icon-aid icon-white">
|
||||
@@ -83,12 +83,12 @@
|
||||
<div class="accordion-body collapse" id="collapseFour" style="height: 0px;">
|
||||
<div class="accordion-inner">
|
||||
<p class="desc">
|
||||
Apparently we had some issues rendering people's names with weird formatting or something, I dunno, I think I fixed it by safely encoding html and rendering the necessary content.<br/><br/>
|
||||
You're <b>Welcome</b>!
|
||||
</p>
|
||||
Apparently we had some issues rendering people's names with weird formatting or something, I dunno, I think I fixed it by safely encoding html and rendering the necessary content.<br/><br/>
|
||||
You're <b>Welcome</b>!
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
Reference in New Issue
Block a user