<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:st1="urn:schemas-microsoft-com:office:smarttags" xmlns="http://www.w3.org/TR/REC-html40">

<head>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">


<meta name=ProgId content=Word.Document>
<meta name=Generator content="Microsoft Word 10">
<meta name=Originator content="Microsoft Word 10">
<link rel=File-List href="cid:filelist.xml@01C9AEE2.BD139970">
<o:SmartTagType namespaceuri="urn:schemas-microsoft-com:office:smarttags"
 name="country-region"/>
<o:SmartTagType namespaceuri="urn:schemas-microsoft-com:office:smarttags"
 name="place"/>
<o:SmartTagType namespaceuri="urn:schemas-microsoft-com:office:smarttags"
 name="time"/>
<o:SmartTagType namespaceuri="urn:schemas-microsoft-com:office:smarttags"
 name="date"/>
<!--[if gte mso 9]><xml>
 <o:OfficeDocumentSettings>
  <o:DoNotRelyOnCSS/>
 </o:OfficeDocumentSettings>
</xml><![endif]--><!--[if gte mso 9]><xml>
 <w:WordDocument>
  <w:GrammarState>Clean</w:GrammarState>
  <w:DocumentKind>DocumentEmail</w:DocumentKind>
  <w:EnvelopeVis/>
  <w:Compatibility>
   <w:BreakWrappedTables/>
   <w:SnapToGridInCell/>
   <w:WrapTextWithPunct/>
   <w:UseAsianBreakRules/>
  </w:Compatibility>
  <w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel>
 </w:WordDocument>
</xml><![endif]--><!--[if !mso]>
<style>
st1\:*{behavior:url(#default#ieooui) }
</style>
<![endif]-->
<style>
<!--
 /* Font Definitions */
 @font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;
        mso-font-charset:0;
        mso-generic-font-family:swiss;
        mso-font-pitch:variable;
        mso-font-signature:1627421319 -2147483648 8 0 66047 0;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
        {mso-style-parent:"";
        margin:0in;
        margin-bottom:.0001pt;
        mso-pagination:widow-orphan;
        font-size:12.0pt;
        font-family:"Times New Roman";
        mso-fareast-font-family:"Times New Roman";}
a:link, span.MsoHyperlink
        {color:blue;
        text-decoration:underline;
        text-underline:single;}
a:visited, span.MsoHyperlinkFollowed
        {color:purple;
        text-decoration:underline;
        text-underline:single;}
p
        {mso-margin-top-alt:auto;
        margin-right:0in;
        mso-margin-bottom-alt:auto;
        margin-left:0in;
        mso-pagination:widow-orphan;
        font-size:12.0pt;
        font-family:"Times New Roman";
        mso-fareast-font-family:"Times New Roman";}
span.EmailStyle18
        {mso-style-type:personal-reply;
        mso-style-noshow:yes;
        mso-ansi-font-size:10.0pt;
        mso-bidi-font-size:10.0pt;
        font-family:Arial;
        mso-ascii-font-family:Arial;
        mso-hansi-font-family:Arial;
        mso-bidi-font-family:Arial;
        color:navy;}
@page Section1
        {size:8.5in 11.0in;
        margin:1.0in 1.25in 1.0in 1.25in;
        mso-header-margin:.5in;
        mso-footer-margin:.5in;
        mso-paper-source:0;}
div.Section1
        {page:Section1;}
-->
</style>
<!--[if gte mso 10]>
<style>
 /* Style Definitions */ 
 table.MsoNormalTable
        {mso-style-name:"Table Normal";
        mso-tstyle-rowband-size:0;
        mso-tstyle-colband-size:0;
        mso-style-noshow:yes;
        mso-style-parent:"";
        mso-padding-alt:0in 5.4pt 0in 5.4pt;
        mso-para-margin:0in;
        mso-para-margin-bottom:.0001pt;
        mso-pagination:widow-orphan;
        font-size:10.0pt;
        font-family:"Times New Roman";}
</style>
<![endif]--><!--[if gte mso 9]><xml>
 <o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
 <o:shapelayout v:ext="edit">
  <o:idmap v:ext="edit" data="1" />
 </o:shapelayout></xml><![endif]-->
</head>

<body bgcolor=white lang=EN-US link=blue vlink=purple style='tab-interval:.5in'>

<div class=Section1>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>Thanks for the quick response. I will
implement this and let you know.<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>Sukhi<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal style='margin-left:.5in'><font size=2 face=Tahoma><span
style='font-size:10.0pt;font-family:Tahoma'>-----Original Message-----<br>
<b><span style='font-weight:bold'>From:</span></b>
owasp-esapi-bounces@lists.owasp.org
[mailto:owasp-esapi-bounces@lists.owasp.org] <b><span style='font-weight:bold'>On
Behalf Of </span></b>Jim Manico<br>
<b><span style='font-weight:bold'>Sent:</span></b> </span></font><st1:date
Month="3" Day="27" Year="2009"><font size=2 face=Tahoma><span style='font-size:
 10.0pt;font-family:Tahoma'>Friday, March 27, 2009</span></font></st1:date><font
size=2 face=Tahoma><span style='font-size:10.0pt;font-family:Tahoma'> </span></font><st1:time
Hour="12" Minute="50"><font size=2 face=Tahoma><span style='font-size:10.0pt;
 font-family:Tahoma'>12:50 PM</span></font></st1:time><font size=2 face=Tahoma><span
style='font-size:10.0pt;font-family:Tahoma'><br>
<b><span style='font-weight:bold'>To:</span></b> Sukhmeet Sethi (</span></font><st1:country-region><st1:place><font
  size=2 face=Tahoma><span style='font-size:10.0pt;font-family:Tahoma'>India</span></font></st1:place></st1:country-region><font
size=2 face=Tahoma><span style='font-size:10.0pt;font-family:Tahoma'>);
owasp-esapi@lists.owasp.org<br>
<b><span style='font-weight:bold'>Subject:</span></b> Re: [OWASP-ESAPI] ESAPI :
CSRF with struts</span></font></p>

<p class=MsoNormal style='margin-left:.5in'><font size=3 face="Times New Roman"><span
style='font-size:12.0pt'><o:p>&nbsp;</o:p></span></font></p>

<div>

<p class=MsoNormal style='margin-left:.5in'><font size=2 face=Arial><span
style='font-size:10.0pt;font-family:Arial'>I feel you only want CSRF tokens
when user actions change the state of data. So what I do is :</span></font><br>
<font size=2 face=Arial><span style='font-size:10.0pt;font-family:Arial'><br>
1) After sucessful login, I generate a CSRF token and stick it in session for
that user (I think&nbsp;unique per-request CSRF tokens is overkill)<br>
2) Whenever I build a form that necessitates CSRF protection, I stick in a CSRF
hidden variable in it.<font color=teal><span style='color:teal'>&nbsp; &lt;</span></font><font
color="#3f7f7f"><span style='color:#3F7F7F'>html:hidden </span></font><font
color="#7f007f"><span style='color:#7F007F'>property</span></font>=<font
color="#2a00ff"><span style='color:#2A00FF'>&quot;csrf&quot; </span></font><font
color=teal><span style='color:teal'>/&gt;</span></font><br>
&nbsp;&nbsp;&nbsp; 2a) My Stuts form objects all descend from a parent that
automatically populates the CSRF token if it exists in the form (see below) so
all I need to do is drop in the csrf hidden variable.</span></font><o:p></o:p></p>

</div>

<div>

<p class=MsoNormal style='margin-left:.5in'><font size=2 face=Arial><span
style='font-size:10.0pt;font-family:Arial'>&nbsp;&nbsp;&nbsp; 2a) I then add
verifyCSRFToken() to the top of actions that need to enforce CSRF protection.</span></font><o:p></o:p></p>

</div>

<div>

<p class=MsoNormal style='margin-left:.5in'><font size=2 face=Arial><span
style='font-size:10.0pt;font-family:Arial'>3) If I want to add CSRF protection
to a GET parameter, then I'm being lazy. Whenever you see GETS needing CSRF
protection, you are designing wrong - you should move those to posts. But, I
break this rule - so I just manually stick a CSRF token to my gets that
necessitate CSRF protection (when building these URL in JSP's or the like)&nbsp;and
add the&nbsp;verify function to those actions. Pretty simple.</span></font><o:p></o:p></p>

</div>

<p style='margin-left:.5in'><b><font size=2 color="#7f0055" face=Arial><span
style='font-size:10.0pt;font-family:Arial;color:#7F0055;font-weight:bold'>public</span></font></b><font
size=2 face=Arial><span style='font-size:10.0pt;font-family:Arial'> <b><font
color="#7f0055"><span style='color:#7F0055;font-weight:bold'>class</span></font></b>
ParentActionForm <b><font color="#7f0055"><span style='color:#7F0055;
font-weight:bold'>extends</span></font></b> ActionForm {</span></font><o:p></o:p></p>

<p style='margin-left:.5in'><font size=2 face=Arial><span style='font-size:
10.0pt;font-family:Arial'>String <font color="#0000c0"><span style='color:#0000C0'>csrf</span></font>;</span></font><o:p></o:p></p>

<p style='margin-left:.5in'><b><font size=2 color="#7f0055" face=Arial><span
style='font-size:10.0pt;font-family:Arial;color:#7F0055;font-weight:bold'>public</span></font></b><font
size=2 face=Arial><span style='font-size:10.0pt;font-family:Arial'> String
getCsrf() {</span></font><o:p></o:p></p>

<p style='margin-left:.5in'><b><font size=2 color="#7f0055" face=Arial><span
style='font-size:10.0pt;font-family:Arial;color:#7F0055;font-weight:bold'>return</span></font></b><font
size=2 face=Arial><span style='font-size:10.0pt;font-family:Arial'> <font
color="#0000c0"><span style='color:#0000C0'>csrf</span></font>;</span></font><o:p></o:p></p>

<p style='margin-left:.5in'><font size=2 face=Arial><span style='font-size:
10.0pt;font-family:Arial'>}</span></font><o:p></o:p></p>

<p style='margin-left:.5in'><b><font size=2 color="#7f0055" face=Arial><span
style='font-size:10.0pt;font-family:Arial;color:#7F0055;font-weight:bold'>public</span></font></b><font
size=2 face=Arial><span style='font-size:10.0pt;font-family:Arial'> <b><font
color="#7f0055"><span style='color:#7F0055;font-weight:bold'>void</span></font></b>
setCsrf(String csrf) {</span></font><o:p></o:p></p>

<p style='margin-left:.5in'><b><font size=2 color="#7f0055" face=Arial><span
style='font-size:10.0pt;font-family:Arial;color:#7F0055;font-weight:bold'>this</span></font></b><font
size=2 face=Arial><span style='font-size:10.0pt;font-family:Arial'>.<font
color="#0000c0"><span style='color:#0000C0'>csrf</span></font> = csrf;</span></font><o:p></o:p></p>

<p style='margin-left:.5in'><font size=2 face=Arial><span style='font-size:
10.0pt;font-family:Arial'>}</span></font><o:p></o:p></p>

<p style='margin-left:.5in'><b><font size=2 color="#7f0055" face=Arial><span
style='font-size:10.0pt;font-family:Arial;color:#7F0055;font-weight:bold'>public</span></font></b><font
size=2 face=Arial><span style='font-size:10.0pt;font-family:Arial'> <b><font
color="#7f0055"><span style='color:#7F0055;font-weight:bold'>void</span></font></b>
reset(ActionMapping mapping, javax.servlet.http.HttpServletRequest request) {</span></font><o:p></o:p></p>

<p style='margin-left:.5in'><font size=2 face=Arial><span style='font-size:
10.0pt;font-family:Arial'>setCsrf(ESAPI.<i><span style='font-style:italic'>httpUtilities</span></i>().getCSRFToken());</span></font><o:p></o:p></p>

<p style='margin-left:.5in'><font size=2 face=Arial><span style='font-size:
10.0pt;font-family:Arial'>}</span></font><o:p></o:p></p>

<p style='margin-left:.5in'><font size=2 face=Arial><span style='font-size:
10.0pt;font-family:Arial'>}</span></font><o:p></o:p></p>

<div>

<p class=MsoNormal style='margin-left:.5in'><font size=2 face=Arial><span
style='font-size:10.0pt;font-family:Arial'><br>
- Jim<br>
----- Original Message ----- <br>
From: Sukhmeet Sethi (</span></font><st1:country-region><st1:place><font
  size=2 face=Arial><span style='font-size:10.0pt;font-family:Arial'>India</span></font></st1:place></st1:country-region><font
size=2 face=Arial><span style='font-size:10.0pt;font-family:Arial'>) <br>
To: owasp-esapi@lists.owasp.org <br>
Sent: </span></font><st1:date Month="3" Day="26" Year="2009"><font size=2
 face=Arial><span style='font-size:10.0pt;font-family:Arial'>Thursday, March
 26, 2009</span></font></st1:date><font size=2 face=Arial><span
style='font-size:10.0pt;font-family:Arial'> </span></font><st1:time Hour="21"
Minute="2"><font size=2 face=Arial><span style='font-size:10.0pt;font-family:
 Arial'>9:02 PM</span></font></st1:time><font size=2 face=Arial><span
style='font-size:10.0pt;font-family:Arial'><br>
Subject: [OWASP-ESAPI] ESAPI : CSRF with struts<br>
<br>
<br>
Hi there,<br>
&nbsp;<br>
I am trying to implement ESAPI - CSRF security in Struts web application but
wonder, how can I include CSRF token with each action.<br>
As per documentation, I can add CSRF token to any URL using following code:<br>
&nbsp;<br>
String url = ESAPI.httpUtilities().addCSRFToken(
&#8220;/example/action?t=1&#8221; );<br>
&nbsp;<br>
But what if I want to include token to all my action URL&#8217;s as in struts,
the desired URL is generated through struts-config&#8217;s action mapping.<br>
Kindly let me know if there&#8217;s way out or if there&#8217;s any example
available.<br>
&nbsp;<br>
Cheers,<br>
Sukhi<br>
&nbsp;<br>
<br>
<br>
<br>
_______________________________________________<br>
OWASP-ESAPI mailing list<br>
OWASP-ESAPI@lists.owasp.org<br>
https://lists.owasp.org/mailman/listinfo/owasp-esapi</span></font><o:p></o:p></p>

</div>

</div>

</body>

</html>