<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>https://wiki.owasp.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Stephendv</id>
		<title>OWASP - User contributions [en]</title>
		<link rel="self" type="application/atom+xml" href="https://wiki.owasp.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Stephendv"/>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php/Special:Contributions/Stephendv"/>
		<updated>2026-04-05T23:21:25Z</updated>
		<subtitle>User contributions</subtitle>
		<generator>MediaWiki 1.27.2</generator>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=User:Stephendv&amp;diff=178895</id>
		<title>User:Stephendv</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=User:Stephendv&amp;diff=178895"/>
				<updated>2014-07-17T10:06:09Z</updated>
		
		<summary type="html">&lt;p&gt;Stephendv: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Hi, I'm Stephen de Vries the CTO of [[http://www.continuumsecurity.net Continuum Security]] and can be reached at: stephen at continuumsecurity dot net.&lt;/div&gt;</summary>
		<author><name>Stephendv</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Category:OWASP_Java_Project&amp;diff=66920</id>
		<title>Category:OWASP Java Project</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Category:OWASP_Java_Project&amp;diff=66920"/>
				<updated>2009-07-30T09:13:35Z</updated>
		
		<summary type="html">&lt;p&gt;Stephendv: /* Project Sponsor */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==About==&lt;br /&gt;
&lt;br /&gt;
The OWASP Java Project's goal is to enable Java and J2EE developers to build secure applications efficiently. See the [[OWASP Java Project Roadmap]] for more information on our plans.&lt;br /&gt;
&lt;br /&gt;
==Joining the Project==&lt;br /&gt;
&lt;br /&gt;
Rohyt Belani is the project lead.  The project's high level roadmap can be found at the [[OWASP Java Project Roadmap]]&lt;br /&gt;
* Please submit your ideas for individual articles to the [[Java Project Article Wishlist]].&lt;br /&gt;
* If you'd like to contribute:&lt;br /&gt;
# visit the [[Tutorial]], &lt;br /&gt;
# join the [http://lists.owasp.org/mailman/listinfo/java-project mailing list] &lt;br /&gt;
# and pick a topic from the [[OWASP Java Table of Contents]], or suggest a new topic.&amp;lt;br&amp;gt;&lt;br /&gt;
Remember to add the tag: &amp;lt;nowiki&amp;gt;[[Category:OWASP Java Project]]&amp;lt;/nowiki&amp;gt; to the end of new articles so that they're properly categorised.&lt;br /&gt;
&lt;br /&gt;
==Java Security Overview==&lt;br /&gt;
&lt;br /&gt;
While Java and J2EE contain many security technologies, it is not easy to produce an application without security vulnerabilities. Most application security [[:Category:Vulnerability|vulnerabilities]] apply to Java applications just like other environments. The notable exception is [[Buffer Overflow|buffer overflow]] and related issues that do not apply to Java applications.&lt;br /&gt;
&lt;br /&gt;
There is a wealth of information about vulnerabilities that apply to Java and JavaEE application in the [[:Category:Vulnerability|Vulnerability]] articles here at OWASP. The articles that have specific Java examples are tagged with the [[:Category:Java|Java category]].&lt;br /&gt;
&lt;br /&gt;
The goals of this project are to provide information about building, configuring, deploying, operating, and maintaining secure Java applications. We cover the following topics:&lt;br /&gt;
&lt;br /&gt;
; [[OWASP Java Table of Contents#J2EE Security for Architects | J2EE Security for Architects]]&lt;br /&gt;
: Provides information about the design and architectural considerations for a Java web application.  Common architectures such as EJB, Web Services and Spring Middle tiers are discussed.&lt;br /&gt;
&lt;br /&gt;
; [[OWASP Java Table of Contents#J2EE Security for Developers | J2EE Security for Developers]]&lt;br /&gt;
: These articles cover dangerous Java calls and common vulnerabilities associated with them, such as Runtime.exec(), Statement.execute(), readline(), etc... The dangers of native code, dynamic code, and reflection will be discussed. We'll also talk about using tools like PMD, jlint, FindBugs, Eclipse, jad, and more. This section will also cover standard security mechanisms in the JDK, such as cryptography, logging, encryption, error handling.  Securing elements of an application, such as servlets, JSPs, controllers, business logic, and persistence layers will be covered. We'll discuss handling request parameters, encoding, injection, and more. We'll also discuss the use of security mechanisms such as log4j, BouncyCastle, XML encryption, XML signature, and other technologies.&lt;br /&gt;
&lt;br /&gt;
; [[OWASP Java Table of Contents#J2EE Security For Deployers| J2EE Security for Deployers]]&lt;br /&gt;
: These articles cover topics specifically related to the J2EE environment. We discuss minimizing the attack surface in web.xml, configuring error handlers, and performing hardening of popular J2EE application servers.&lt;br /&gt;
&lt;br /&gt;
; [[OWASP Java Table of Contents#J2EE Security for Security Analysts and Testers| J2EE Security for Security Analysts and Testers]]&lt;br /&gt;
: These articles cover the verification, analysis, and testing of the security of J2EE applications. This section will cover using tools to find vulnerabilities, both in source code and in running applications. These articles will focus on J2EE-specific aspects of testing applications that use various common J2EE frameworks and coding patterns.&lt;/div&gt;</summary>
		<author><name>Stephendv</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Category:OWASP_Java_Project&amp;diff=66919</id>
		<title>Category:OWASP Java Project</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Category:OWASP_Java_Project&amp;diff=66919"/>
				<updated>2009-07-30T09:13:11Z</updated>
		
		<summary type="html">&lt;p&gt;Stephendv: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==About==&lt;br /&gt;
&lt;br /&gt;
The OWASP Java Project's goal is to enable Java and J2EE developers to build secure applications efficiently. See the [[OWASP Java Project Roadmap]] for more information on our plans.&lt;br /&gt;
&lt;br /&gt;
==Joining the Project==&lt;br /&gt;
&lt;br /&gt;
Rohyt Belani is the project lead.  The project's high level roadmap can be found at the [[OWASP Java Project Roadmap]]&lt;br /&gt;
* Please submit your ideas for individual articles to the [[Java Project Article Wishlist]].&lt;br /&gt;
* If you'd like to contribute:&lt;br /&gt;
# visit the [[Tutorial]], &lt;br /&gt;
# join the [http://lists.owasp.org/mailman/listinfo/java-project mailing list] &lt;br /&gt;
# and pick a topic from the [[OWASP Java Table of Contents]], or suggest a new topic.&amp;lt;br&amp;gt;&lt;br /&gt;
Remember to add the tag: &amp;lt;nowiki&amp;gt;[[Category:OWASP Java Project]]&amp;lt;/nowiki&amp;gt; to the end of new articles so that they're properly categorised.&lt;br /&gt;
&lt;br /&gt;
==Java Security Overview==&lt;br /&gt;
&lt;br /&gt;
While Java and J2EE contain many security technologies, it is not easy to produce an application without security vulnerabilities. Most application security [[:Category:Vulnerability|vulnerabilities]] apply to Java applications just like other environments. The notable exception is [[Buffer Overflow|buffer overflow]] and related issues that do not apply to Java applications.&lt;br /&gt;
&lt;br /&gt;
There is a wealth of information about vulnerabilities that apply to Java and JavaEE application in the [[:Category:Vulnerability|Vulnerability]] articles here at OWASP. The articles that have specific Java examples are tagged with the [[:Category:Java|Java category]].&lt;br /&gt;
&lt;br /&gt;
The goals of this project are to provide information about building, configuring, deploying, operating, and maintaining secure Java applications. We cover the following topics:&lt;br /&gt;
&lt;br /&gt;
; [[OWASP Java Table of Contents#J2EE Security for Architects | J2EE Security for Architects]]&lt;br /&gt;
: Provides information about the design and architectural considerations for a Java web application.  Common architectures such as EJB, Web Services and Spring Middle tiers are discussed.&lt;br /&gt;
&lt;br /&gt;
; [[OWASP Java Table of Contents#J2EE Security for Developers | J2EE Security for Developers]]&lt;br /&gt;
: These articles cover dangerous Java calls and common vulnerabilities associated with them, such as Runtime.exec(), Statement.execute(), readline(), etc... The dangers of native code, dynamic code, and reflection will be discussed. We'll also talk about using tools like PMD, jlint, FindBugs, Eclipse, jad, and more. This section will also cover standard security mechanisms in the JDK, such as cryptography, logging, encryption, error handling.  Securing elements of an application, such as servlets, JSPs, controllers, business logic, and persistence layers will be covered. We'll discuss handling request parameters, encoding, injection, and more. We'll also discuss the use of security mechanisms such as log4j, BouncyCastle, XML encryption, XML signature, and other technologies.&lt;br /&gt;
&lt;br /&gt;
; [[OWASP Java Table of Contents#J2EE Security For Deployers| J2EE Security for Deployers]]&lt;br /&gt;
: These articles cover topics specifically related to the J2EE environment. We discuss minimizing the attack surface in web.xml, configuring error handlers, and performing hardening of popular J2EE application servers.&lt;br /&gt;
&lt;br /&gt;
; [[OWASP Java Table of Contents#J2EE Security for Security Analysts and Testers| J2EE Security for Security Analysts and Testers]]&lt;br /&gt;
: These articles cover the verification, analysis, and testing of the security of J2EE applications. This section will cover using tools to find vulnerabilities, both in source code and in running applications. These articles will focus on J2EE-specific aspects of testing applications that use various common J2EE frameworks and coding patterns.&lt;br /&gt;
&lt;br /&gt;
== Project Sponsor ==&lt;br /&gt;
The OWASP Java project is sponsored by &lt;br /&gt;
[http://www.corsaire.com https://www.owasp.org/images/8/81/Corsaire_smalllogo.JPG]&lt;br /&gt;
&lt;br /&gt;
[[Category:Platform]]&lt;br /&gt;
[[Category:OWASP Project]]&lt;/div&gt;</summary>
		<author><name>Stephendv</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=User:Stephendv&amp;diff=61746</id>
		<title>User:Stephendv</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=User:Stephendv&amp;diff=61746"/>
				<updated>2009-05-26T07:08:10Z</updated>
		
		<summary type="html">&lt;p&gt;Stephendv: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Hi, I'm Stephen de Vries a Principal Consultant at [[http://www.corsaire.com Corsaire]] and can be reached at: stephen at corsaire dot com.  I'm currently co-leading the OWASP Java project with Rohyt Belani.&lt;/div&gt;</summary>
		<author><name>Stephendv</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=OWASP_NYC_AppSec_2008_Conference&amp;diff=37566</id>
		<title>OWASP NYC AppSec 2008 Conference</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=OWASP_NYC_AppSec_2008_Conference&amp;diff=37566"/>
				<updated>2008-08-29T13:28:36Z</updated>
		
		<summary type="html">&lt;p&gt;Stephendv: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= 2008 OWASP USA, NYC =&lt;br /&gt;
Last Update: {{REVISIONMONTH}}/{{REVISIONDAY}}/{{REVISIONYEAR}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt; Scroll down to see speaker agenda, and training options &amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;[http://guest.cvent.com/i.aspx?4W,M3,828ca6d1-1b60-4105-8034-d344700e6956 http://www.owasp.org/images/6/61/Banner2_irfan.jpg]&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;hr&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt;[http://www.owasp.org/images/6/66/NY_Sponsorship_Form_update_%282%29.pdf Diamond Sponsor] - [http://www.imperva.com http://www.owasp.org/images/d/de/Imperva_2color_RGB.jpg]&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;[https://www.owasp.org/images/6/66/NY_Sponsorship_Form_update_%282%29.pdf Platinum Sponsor]  - [http://www.cenzic.com https://www.owasp.org/images/b/bf/CenzicLogo_RGB.gif]  - [http://www.whitehatsec.com http://www.owasp.org/images/archive/4/4d/20080703021901%21Whitehat.gif] -  [http://www-935.ibm.com/services/us/gbs/app/html/gbs_applicationservices.html?cm_re=masthead-_-business-_-apps-allappserv https://www.owasp.org/images/4/47/Ibm.jpg] &amp;lt;/center&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[http://www.owasp.org/images/6/66/NY_Sponsorship_Form_update_%282%29.pdf Gold, Silver &amp;amp; Other Sponsors] - [http://www.isc2.org http://www.owasp.org/images/4/45/Isc2logo.gif] - [http://www.f5.com http://www.owasp.org/images/7/7e/50px-F5_50px.jpg] - [http://www.aspectsecurity.com http://www.owasp.org/images/d/d1/Aspect_logo.gif] - [http://www.foundstone.com/us/education-overview.asp http://www.owasp.org/images/2/26/Foundstone.jpg] - [http://www.qualys.com https://www.owasp.org/images/a/ae/Qualys.gif] - [http://www.ouncelabs.com https://www.owasp.org/images/6/6e/OunceLabs_logo.jpg] - [http://www.fortify.com https://www.owasp.org/images/a/ac/Fortify.jpg] - [http://www.cigital.com/ https://www.owasp.org/images/b/be/Cigital_OWASP.GIF] - [http://www.acunetix.com https://www.owasp.org/images/e/eb/Acuneti.gif] - [http://www.accessitgroup.com https://www.owasp.org/images/6/6d/Accessit.JPG] - &lt;br /&gt;
[http://www.fishnetsecurity.com https://www.owasp.org/images/4/4a/Fishnet_security.png] - [http://www.arctecgroup.net http://www.owasp.org/images/b/bf/Arctec.jpg] - [http://www.airtightnetworks.net https://www.owasp.org/images/8/8b/Airtight.gif] - &lt;br /&gt;
[http://www.artofdefence.com https://www.owasp.org/images/d/dc/AOD_Logo.gif] - &lt;br /&gt;
[http://www.securityuniversity.net https://www.owasp.org/images/0/0d/Security_university.jpg] - &lt;br /&gt;
[http://www.breach.com https://www.owasp.org/images/9/9c/Breach_logo.gif] - [http://www.armorize.com https://www.owasp.org/images/c/ce/Armorize_Logo.png] -[http://www.barracudanetworks.com/ https://www.owasp.org/images/a/a2/Barracuda_Color_Logo.jpg] ~ [http://www.owasp.org/images/6/66/NY_Sponsorship_Form_update_%282%29.pdf http://www.owasp.org/images/f/f8/Sponsorsm.gif]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt;[https://www.owasp.org/images/6/66/NY_Sponsorship_Form_update_%282%29.pdf Sponsorship Opportunities] -- [http://www.owasp.org/index.php/OWASP_NYC_AppSec_2008_Conference-PRESS Press Registration] -- [http://www.owasp.org/index.php/Member_Offers Other OWASP Member Offers] &amp;lt;/center&amp;gt; &lt;br /&gt;
&amp;lt;hr&amp;gt;&lt;br /&gt;
With assistance from: [http://www.webappsec.org WASC], [http://www.nym-infragard.us NYM InfraGard], [http://aitglobal.com AITGlobal], [http://nyphp.org/index.php NYC PHP], [http://www.nycbug.org NYCBUG], [http://www.isacany.net NYC ISACA], [http://www.nymissa.org NYC ISSA] and [http://www.pace.edu Pace University] you're invited to (2) days of Seminars and Technology Pavilion from the world's best application security technology minds, (2) days of hardcore hands-on training, all held at &amp;lt;b&amp;gt;[http://www.pace.edu/page.cfm?doc_id=16157 Pace University]&amp;lt;/b&amp;gt;, located in downtown New York City at &amp;lt;b&amp;gt;One Pace Plaza New York, NY 10038.&amp;lt;/b&amp;gt; Event Fees: $350 Members / $400 Non-Members / $200 for Students.  [http://www.owasp.org/index.php/OWASP_NYC_AppSec_2008_Conference#OWASP_NYC_AppSec_2008_Training_Courses_-_September_22nd_and_23rd.2C_2008 2 days of hands on training classes] are also available.&lt;br /&gt;
&amp;lt;center&amp;gt;[http://guest.cvent.com/i.aspx?4W,M3,828ca6d1-1b60-4105-8034-d344700e6956 http://www.owasp.org/images/7/7f/Register.gif]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
OWASP NYC's conference offers tracks for security and development professionals interested in learning how to secure applications and enterprises as well as organization leaders who want to learn more about the state of the appsec industry and its trends.  With two days of training and two days of sessions discussing cutting edge research presented by some of the brightest people in the industry, this event is a must attend for anyone looking to improve their information security posture. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 2008 OWASP USA, NYC Conference Schedule – Sept 24th - Sept 25th ==&lt;br /&gt;
&amp;lt;center&amp;gt;[http://www.owasp.org/index.php/OWASP_NYC_AppSec_2008_Conference/speakeragreement OWASP Speaker Agreement]&amp;lt;/center&amp;gt;&lt;br /&gt;
{| style=&amp;quot;width:80%&amp;quot; border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
 ! colspan=&amp;quot;4&amp;quot; align=&amp;quot;center&amp;quot; style=&amp;quot;background:#4058A0; color:white&amp;quot; | Day 1 – Sept 24th, 2008 &lt;br /&gt;
 |-&lt;br /&gt;
 | style=&amp;quot;width:10%; background:#7B8ABD&amp;quot; | || style=&amp;quot;width:30%; background:#BC857A&amp;quot; | Track 1: &lt;br /&gt;
 | style=&amp;quot;width:30%; background:#BCA57A&amp;quot; | Track 2: &lt;br /&gt;
 | style=&amp;quot;width:30%; background:#99FF99&amp;quot; | Track 3: &lt;br /&gt;
 |-&lt;br /&gt;
 | style=&amp;quot;width:10%; background:#7B8ABD&amp;quot; | 07:30-10:00 || colspan=&amp;quot;3&amp;quot; style=&amp;quot;width:80%; background:#C2C2C2&amp;quot; align=&amp;quot;center&amp;quot; | '''Doors Open for Attendee/Speaker Registration &amp;amp; [http://www.owasp.org/index.php/OWASP_NYC_AppSec_2008_Conference#Technology_Pavilion_-_September_24th_and_25th Exhibit/Sponsor Area]'''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
 | style=&amp;quot;width:10%; background:#7B8ABD&amp;quot; | 09:00-09:45 || colspan=&amp;quot;3&amp;quot; style=&amp;quot;width:80%; background:#F2F2F2&amp;quot; align=&amp;quot;center&amp;quot; | OWASP Version 3.0 who we are, where we are.. where we are going &lt;br /&gt;
''OWASP Foundation: [http://www.owasp.org/index.php/Contact Jeff Williams], [http://www.owasp.org/index.php/Contact Dinis Cruz], [http://www.owasp.org/index.php/Contact Dave Wichers], [http://www.linkedin.com/in/tombrennan Tom Brennan], [http://www.owasp.org/index.php/Contact Sebastien Deleersnyder], [http://www.owasp.org/index.php/Contact Paulo Coimbra], [http://www.owasp.org/index.php/Contact Kate Hartmann], [http://www.owasp.org/index.php/Contact Alison Shrader] &amp;amp; [http://www.owasp.org/index.php/Category:OWASP_Chapter#Chapter_Support_Materials all local chapter leaders]&lt;br /&gt;
'' &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:10%; background:#7B8ABD&amp;quot; | 10:00-10:45 || style=&amp;quot;width:30%; background:#BC857A&amp;quot; align=&amp;quot;left&amp;quot; |  [http://www.owasp.org/index.php/AppSecEU08_Trends_in_Web_Hacking_Incidents:_What%27s_hot_for_2008 Analysis of the Web Hacking Incidents Database (WHID)]&lt;br /&gt;
''[http://blog.shezaf.com Ofer Shezaf]''&lt;br /&gt;
 | style=&amp;quot;width:30%; background:#BCA57A&amp;quot; align=&amp;quot;left&amp;quot; | [http://www.webappsecroadmap.com Web Application Security Road Map]  &amp;lt;br&amp;gt;&lt;br /&gt;
''[http://joesecurity.blogspot.com Joe White]''&lt;br /&gt;
| style=&amp;quot;width:30%; background:#99FF99&amp;quot; align=&amp;quot;left&amp;quot; |[https://buildsecurityin.us-cert.gov/swa/acqwg.html DHS Software Assurance Initiatives]&lt;br /&gt;
''[http://www.linkedin.com/pub/0/ab/3b7 Stan Wisseman] &amp;amp; [http://www.linkedin.com/pub/1/439/923 Joe Jarzombek]''&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:10%; background:#7B8ABD&amp;quot; | 11:00-11:45 || style=&amp;quot;width:30%; background:#BC857A&amp;quot; align=&amp;quot;left&amp;quot; | Web Security Education using Open Source Tools&lt;br /&gt;
''Prof. Li-Chiou Chen &amp;amp; Chienitng Lin, [http://www.pace.edu/page.cfm?doc_id=16399 Pace Univ]''&lt;br /&gt;
 | style=&amp;quot;width:30%; background:#BCA57A&amp;quot; align=&amp;quot;left&amp;quot; | Http Bot Research&lt;br /&gt;
''[http://www.shadowserver.org/wiki/pmwiki.php?n=Shadowserver.Mission Andre M. DiMino - ShadowServer Foundation]''&lt;br /&gt;
| style=&amp;quot;width:30%; background:#99FF99&amp;quot; align=&amp;quot;left&amp;quot; | MalSpam Research &lt;br /&gt;
'' [http://www.knujon.com/bios.html Garth Bruen]''&lt;br /&gt;
|-&lt;br /&gt;
 | style=&amp;quot;width:10%; background:#7B8ABD&amp;quot; | 12:00-13:00 || colspan=&amp;quot;3&amp;quot; style=&amp;quot;width:80%; background:#F2F2F2&amp;quot; align=&amp;quot;center&amp;quot; |  [http://www.owasp.org/index.php/OWASP_NYC_AppSec_2008_Conference/ctf Capture the Flag] Sign-Up&lt;br /&gt;
''LUNCH - Provided by event sponsors @ TechExpo''&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:10%; background:#7B8ABD&amp;quot; | 12:00-12:30 || style=&amp;quot;width:30%; background:#BC857A&amp;quot; align=&amp;quot;left&amp;quot; | Cross-Site Scripting Filter Evasion&lt;br /&gt;
''Alexios Fakos''&lt;br /&gt;
 | style=&amp;quot;width:30%; background:#BCA57A&amp;quot; align=&amp;quot;left&amp;quot; | Framework-level Threat Analysis: Adding Science to the Art of Source-code review&lt;br /&gt;
''[http://www.owasp.org/index.php/OWASP_NYC_AppSec_2008_Conference-rohit-sethi Rohit Sethi] &amp;amp; [http://www.owasp.org/index.php/OWASP_NYC_AppSec_2008_Conference-sahba-kazerooni Sahba Kazerooni]''&lt;br /&gt;
| style=&amp;quot;width:30%; background:#99FF99&amp;quot; align=&amp;quot;left&amp;quot; | Automated Web-based Malware Behavioral Analysis &lt;br /&gt;
''[http://www.linkedin.com/pub/3/359/b1a Tyler Hudak]''&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:10%; background:#7B8ABD&amp;quot; | 13:00-13:45 || style=&amp;quot;width:30%; background:#BC857A&amp;quot; align=&amp;quot;left&amp;quot; | OWASP Testing Guide - Offensive Assessing Financial Applications&lt;br /&gt;
'' [http://www.owasp.org/index.php/OWASP_NYC_AppSec_2008_Conference-daniel-cuthbert Daniel Cuthbert]''&lt;br /&gt;
 | style=&amp;quot;width:30%; background:#BCA57A&amp;quot; align=&amp;quot;left&amp;quot; | WAF ModSecurity&lt;br /&gt;
''[http://www.breach.com/company/executive-team/ Ivan Ristic]''&lt;br /&gt;
| style=&amp;quot;width:30%; background:#99FF99&amp;quot; align=&amp;quot;left&amp;quot; | Using Layer 8 and OWASP to Secure Web Applications&lt;br /&gt;
''[http://www.linkedin.com/in/davidstern2000 David Stern] &amp;amp; [http://www.linkedin.com/in/romangarber Roman Garber]''&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:10%; background:#7B8ABD&amp;quot; | 14:00-14:45 || style=&amp;quot;width:30%; background:#BC857A&amp;quot; align=&amp;quot;left&amp;quot; | Critical exploits... let us count the ways&lt;br /&gt;
''[http://jeremiahgrossman.blogspot.com Jeremiah Grossman] &amp;amp; [http://ha.ckers.org/blog/about Robert &amp;quot;RSnake&amp;quot; Hansen],''&lt;br /&gt;
 | style=&amp;quot;width:30%; background:#BCA57A&amp;quot; align=&amp;quot;left&amp;quot; | [http://www.owasp.org/index.php/Security_Assessing_Java_RMI Security Assessing Java RMI] &lt;br /&gt;
''[http://www.linkedin.com/in/adamboulton Adam Boulton]''&lt;br /&gt;
| style=&amp;quot;width:30%; background:#99FF99&amp;quot; align=&amp;quot;left&amp;quot; | JBroFuzz 0.1 - 1.1: Building a Java Fuzzer for the Web &lt;br /&gt;
''[http://www.owasp.org/index.php/OWASP_NYC_AppSec_2008_Conference-SPEAKER-Yiannis_Pavlosoglou Yiannis Pavlosoglou]''&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:10%; background:#7B8ABD&amp;quot; | 15:00-15:45 || style=&amp;quot;width:30%; background:#BC857A&amp;quot; align=&amp;quot;left&amp;quot; |Industry Outlook Panel: ''[http://www.linkedin.com/in/markclancy Mark Clancy] EVP CitiGroup, [http://www.linkedin.com/pub/0/497/86a Jim Routh] CISO DTCC, [http://www.linkedin.com/pub/0/bb1/68a Sunil Seshadri] CISO NYSE-Euronet, [http://www.linkedin.com/pub/0/1ba/4a9 Warren Axelrod] SVP Bank of America, [http://www.linkedin.com/in/bernik Joe Bernik] SVP, RBS,[http://www.linkedin.com/pub/8/878/240 Jennifer Bayuk] Infosec Consultant &amp;amp; [http://www.linkedin.com/in/philvenables Philip Venables] CISO, Goldman Sachs&lt;br /&gt;
[http://www.linkedin.com/in/crecalde Carlos Recalde] SVP, Lehman Brothers&lt;br /&gt;
[http://www.linkedin.com/in/mahidontamsetti Mahi Dontamsetti] Moderator''&lt;br /&gt;
 | style=&amp;quot;width:30%; background:#BCA57A&amp;quot; align=&amp;quot;left&amp;quot; | [http://www.owasp.org/index.php/Wild_Wild_Web_on_Security_Planet Wild Wild Web on Security Planet]&lt;br /&gt;
''[http://www.securisksolutions.com/company/execmgt.aspx Mano Paul]''&lt;br /&gt;
| style=&amp;quot;width:30%; background:#99FF99&amp;quot; align=&amp;quot;left&amp;quot; |[http://www.owasp.org/index.php/OWASP_NYC_AppSec_2008_Conference-SPEAKER-GunterOllmann Multidisciplinary Bank Attacks]&lt;br /&gt;
''Gunter Ollmann''&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:10%; background:#7B8ABD&amp;quot; | 16:00-16:45 || style=&amp;quot;width:30%; background:#BC857A&amp;quot; align=&amp;quot;left&amp;quot; | OWASP Enterprise Security API [http://www.owasp.org/index.php/ESAPI (ESAPI) Project]&lt;br /&gt;
'' [http://www.aspectsecurity.com/management.htm Jeff Williams]''&lt;br /&gt;
 | style=&amp;quot;width:30%; background:#BCA57A&amp;quot; align=&amp;quot;left&amp;quot; | Shootout @ Blackbox Corral&lt;br /&gt;
''Larry Suto ''&lt;br /&gt;
| style=&amp;quot;width:30%; background:#99FF99&amp;quot; align=&amp;quot;left&amp;quot; | Case Studies: Exploiting application testing tool deficiencies via &amp;quot;out of band&amp;quot; injection&lt;br /&gt;
''[http://www.linkedin.com/pub/0/a91/aa2 Vijay Akasapu] &amp;amp; [http://www.linkedin.com/pub/9/279/381 Marshall Heilman]''&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:10%; background:#7B8ABD&amp;quot; | 17:00-17:45 || style=&amp;quot;width:30%; background:#BC857A&amp;quot; align=&amp;quot;left&amp;quot; | Threading the Needle:&lt;br /&gt;
&lt;br /&gt;
Bypassing web application/service security controls using Encoding, Transcoding, Filter Evasion, and other Canonicalization Attacks&lt;br /&gt;
'' [http://www.linkedin.com/in/arianevans Arian Evans]''&lt;br /&gt;
 | style=&amp;quot;width:30%; background:#BCA57A&amp;quot; align=&amp;quot;left&amp;quot; |Shhhh Don’t Tell Anybody &lt;br /&gt;
''[http://www.linkedin.com/in/ppetkov Petko D. Petkov]''&lt;br /&gt;
| style=&amp;quot;width:30%; background:#99FF99&amp;quot; align=&amp;quot;left&amp;quot; | [http://www.owasp.org/index.php/OWASP_NYC_AppSec_2008_Conference-SPEAKER-Andres_Riancho w3af - A Framework to own the web]&lt;br /&gt;
''Andres Riancho''&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:10%; background:#7B8ABD&amp;quot; | 18:00-18:45 || style=&amp;quot;width:30%; background:#BC857A&amp;quot; align=&amp;quot;left&amp;quot; | [http://www.owasp.org/index.php/Category:OWASP_Live_CD_Project OWASP Live CD]&lt;br /&gt;
'' [http://www.linkedin.com/in/packetfocus Joshua Perrymon]''&lt;br /&gt;
 | style=&amp;quot;width:30%; background:#BCA57A&amp;quot; align=&amp;quot;left&amp;quot; | Coding Secure w/PHP&lt;br /&gt;
''[http://www.linkedin.com/in/zaunere Hans Zaunere]''&lt;br /&gt;
| style=&amp;quot;width:30%; background:#99FF99&amp;quot; align=&amp;quot;left&amp;quot; | [http://www.owasp.org/index.php/Payment_Card_Data_Security_and_the_new_Enterprise_Java Payment Card Data Security and the new Enterprise Java]&lt;br /&gt;
''[https://www.owasp.org/index.php/OWASP_NYC_AppSec_2008_Conference-SPEAKER-Dr._B._V._Kumar Dr. B. V. Kumar] &amp;amp; [https://www.owasp.org/index.php/OWASP_NYC_AppSec_2008_Conference-SPEAKER-Abhay_Bhargav Mr. Abhay Bhargav]''&lt;br /&gt;
|-&lt;br /&gt;
 | style=&amp;quot;width:10%; background:#7B8ABD&amp;quot; | 20:00-23:00 || colspan=&amp;quot;3&amp;quot; style=&amp;quot;width:80%; background:#C2C2C2&amp;quot; align=&amp;quot;center&amp;quot; | OWASP NYC AppSec 2008 VIP Party&lt;br /&gt;
''Location: TBD''&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;10&amp;quot; align=&amp;quot;center&amp;quot; style=&amp;quot;background:#4058A0; color:white&amp;quot; | Day 2 – Sept 25th, 2008 &lt;br /&gt;
|-&lt;br /&gt;
  | style=&amp;quot;width:10%; background:#99FF99&amp;quot; | 08:00-10:00 || colspan=&amp;quot;3&amp;quot; style=&amp;quot;width:80%; background:#F2F2F2&amp;quot; align=&amp;quot;center&amp;quot; |  BREAKFAST - Provided by event sponsors @ TechExpo&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:10%; background:#7B8ABD&amp;quot; | 08:00-08:45 || style=&amp;quot;width:30%; background:#BC857A&amp;quot; align=&amp;quot;left&amp;quot; | Software Development: The Last Security Frontier&lt;br /&gt;
''[http://blog.isc2.org/isc2_blog/tipton/index.html W. Hord Tipton], CISSP-ISSEP, CAP, CISA, CNSS and former Chief Information Officer for the U.S. Department of the Interior&lt;br /&gt;
Executive Director and member of the Board of Directors, (ISC)²''&lt;br /&gt;
 | style=&amp;quot;width:30%; background:#BCA57A&amp;quot; align=&amp;quot;left&amp;quot; | [http://www.owasp.org/index.php/AppSecEU08_Best_Practices_Guide_Web_Application_Firewalls Best Practices Guide: Web Application Firewalls]&lt;br /&gt;
''Alexander Meisel''&lt;br /&gt;
| style=&amp;quot;width:30%; background:#99FF99&amp;quot; align=&amp;quot;left&amp;quot; | The Good The Bad and The Ugly - Pen Testing VS. Source Code Analysis&lt;br /&gt;
''[http://www.linkedin.com/in/tommyryan Thomas Ryan]'' &amp;amp; ''[http://www.linkedin.com/in/steveantoniewicz Steve Antoniewicz]''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:10%; background:#7B8ABD&amp;quot; | 09:00-09:45 || style=&amp;quot;width:30%; background:#BC857A&amp;quot; align=&amp;quot;left&amp;quot; | [http://www.trutv.com/video/tiger-team/tiger-team-101-1-of-4.html APPSEC Red/Tiger Team Projects]&lt;br /&gt;
''[http://www.linkedin.com/pub/1/373/994 Chris Nickerson]''&lt;br /&gt;
 | style=&amp;quot;width:30%; background:#BCA57A&amp;quot; align=&amp;quot;left&amp;quot; | OWASP &amp;quot;Google Hacking&amp;quot; Project &lt;br /&gt;
''[http://www.linkedin.com/in/ChristianHeinrich Christian Heinrich]''&lt;br /&gt;
| style=&amp;quot;width:30%; background:#99FF99&amp;quot; align=&amp;quot;left&amp;quot; | OWASP Web Services Top Ten&lt;br /&gt;
''[http://1raindrop.typepad.com Gunnar Peterson]''&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:10%; background:#7B8ABD&amp;quot; | 10:00-10:45 || style=&amp;quot;width:30%; background:#BC857A&amp;quot; align=&amp;quot;left&amp;quot; | Lets talk about OWASP....&lt;br /&gt;
''Dinis Cruz''&lt;br /&gt;
 | style=&amp;quot;width:30%; background:#BCA57A&amp;quot; align=&amp;quot;left&amp;quot; | &amp;quot;Help Wanted&amp;quot; [http://www.infosecleaders.com/survey 7 Things You Need to Know APPSEC/INFOSEC Employment]&lt;br /&gt;
''[http://www.linkedin.com/pub/0/29/685 Lee Kushner]''&lt;br /&gt;
| style=&amp;quot;width:30%; background:#99FF99&amp;quot; align=&amp;quot;left&amp;quot; | Industry Analyst with Forrester Research&lt;br /&gt;
''[http://www.forrester.com/rb/analyst/chenxi_wang Chenxi Wang]''&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:10%; background:#7B8ABD&amp;quot; | 11:00-11:45 || style=&amp;quot;width:30%; background:#BC857A&amp;quot; align=&amp;quot;left&amp;quot; | [http://www.owasp.org/index.php/Category:OWASP_CLASP_Project CLASP (Comprehensive, Lightweight Application Security Process)]&lt;br /&gt;
''Pravir Chandra''&lt;br /&gt;
 | style=&amp;quot;width:30%; background:#BCA57A&amp;quot; align=&amp;quot;left&amp;quot; | Next Generation Cross Site Scripting Worms &lt;br /&gt;
''[http://i8jesus.com/?page_id=5 Arshan Dabirsiaghi]''&lt;br /&gt;
| style=&amp;quot;width:30%; background:#99FF99&amp;quot; align=&amp;quot;left&amp;quot; | Secure Software Impact&lt;br /&gt;
''[http://ouncelabs.com/company/team.asp Jack Danahy]''&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:10%; background:#7B8ABD&amp;quot; | 12:00-12:45 || style=&amp;quot;width:30%; background:#BC857A&amp;quot; align=&amp;quot;left&amp;quot; | Security in Agile Development&lt;br /&gt;
''[http://www.owasp.org/index.php/User:Wichers Dave Wichers]''&lt;br /&gt;
 | style=&amp;quot;width:30%; background:#BCA57A&amp;quot; align=&amp;quot;left&amp;quot; | Security of Software-as-a-Service (SaaS)&lt;br /&gt;
''[http://www.linkedin.com/pub/6/372/45a James Landis]''&lt;br /&gt;
| style=&amp;quot;width:30%; background:#99FF99&amp;quot; align=&amp;quot;left&amp;quot; | [http://reversebenchmarking.com/About.html Open Reverse Benchmarking Project]&lt;br /&gt;
''Marce Luck &amp;amp; [http://www.linkedin.com/pub/1/507/616 Tom Stracener]''&lt;br /&gt;
|-&lt;br /&gt;
 | style=&amp;quot;width:10%; background:#7B8ABD&amp;quot; | 12:00-13:00 || colspan=&amp;quot;3&amp;quot; style=&amp;quot;width:80%; background:#F2F2F2&amp;quot; align=&amp;quot;center&amp;quot; | [http://www.owasp.org/index.php/OWASP_NYC_AppSec_2008_Conference/ctf Capture the Flag] Status&lt;br /&gt;
''LUNCH - Provided @ TechExpo''&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:10%; background:#7B8ABD&amp;quot; | 13:00-13:45 || style=&amp;quot;width:30%; background:#BC857A&amp;quot; align=&amp;quot;left&amp;quot; | Security Research Report&lt;br /&gt;
''[http://www.linkedin.com/pub/5/742/233 Dinis Cruz]''&lt;br /&gt;
 | style=&amp;quot;width:30%; background:#BCA57A&amp;quot; align=&amp;quot;left&amp;quot; | Get Rich or Die Trying - Making Money on The Web, The Black Hat Way&lt;br /&gt;
''Trey Ford, Tom Brennan, Jeremiah Grossman''&lt;br /&gt;
| style=&amp;quot;width:30%; background:#99FF99&amp;quot; align=&amp;quot;left&amp;quot; | [https://www.owasp.org/index.php/User_talk:Jian Lotus Notes/Domino Web Application Security]&lt;br /&gt;
''[https://www.owasp.org/index.php/User_talk:Jian Jian Hui Wang]''&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:10%; background:#7B8ABD&amp;quot; | 14:00-14:45 || style=&amp;quot;width:30%; background:#BC857A&amp;quot; align=&amp;quot;left&amp;quot; | Practical Advanced Threat Modeling&lt;br /&gt;
''John Steven''&lt;br /&gt;
 | style=&amp;quot;width:30%; background:#BCA57A&amp;quot; align=&amp;quot;left&amp;quot; | [http://www.owasp.org/index.php/Category:OWASP_Orizon_Project The Owasp Orizon Project: towards version 1.0]&lt;br /&gt;
[https://www.owasp.org/index.php/User:Thesp0nge Paolo Perego]&lt;br /&gt;
| style=&amp;quot;width:30%; background:#99FF99&amp;quot; align=&amp;quot;left&amp;quot; | [http://www.owasp.org/index.php/Building_Usable_Security Building Usable Security]&lt;br /&gt;
[http://www.owasp.org/index.php/Zed_Abbadi Zed Abbadi]&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:10%; background:#7B8ABD&amp;quot; | 15:00-15:45 || style=&amp;quot;width:30%; background:#BC857A&amp;quot; align=&amp;quot;left&amp;quot; | [http://www.owasp.org/index.php/Input_validation:_the_Good%2C_the_Bad_and_the_Ugly Input validation: the Good, the Bad and the Ugly]&lt;br /&gt;
''[http://johanpeeters.com Johan Peeters]''&lt;br /&gt;
 | style=&amp;quot;width:30%; background:#BCA57A&amp;quot; align=&amp;quot;left&amp;quot; | Off-shoring Application Development? Security is Still Your Problem&lt;br /&gt;
''Rohyt Belani''&lt;br /&gt;
| style=&amp;quot;width:30%; background:#99FF99&amp;quot; align=&amp;quot;left&amp;quot; | [[NIST SAMATE Static Analysis Tool Exposition (SATE)]]&lt;br /&gt;
''[http://www.owasp.org/index.php/OWASP_NYC_AppSec_2008_Conference-vadim-okun Vadim Okun]''&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width:10%; background:#7B8ABD&amp;quot; | 16:00-16:45 || style=&amp;quot;width:30%; background:#BC857A&amp;quot; align=&amp;quot;left&amp;quot; | Vulnerabilities in application interpreters and runtimes&lt;br /&gt;
''Erik Cabetas''&lt;br /&gt;
 | style=&amp;quot;width:30%; background:#BCA57A&amp;quot; align=&amp;quot;left&amp;quot; | Flash Parameter Injection (FPI)&lt;br /&gt;
''Ayal Yogev &amp;amp; Adi Sharabani''&lt;br /&gt;
| style=&amp;quot;width:30%; background:#99FF99&amp;quot; align=&amp;quot;left&amp;quot; | Mastering PCI Section 6.6&lt;br /&gt;
''[http://www.linkedin.com/pub/1/228/6a5 Taylor McKinley] and [http://www.linkedin.com/in/jacobwest Jacob West]''&lt;br /&gt;
|-&lt;br /&gt;
 | style=&amp;quot;width:10%; background:#7B8ABD&amp;quot; | 17:00-17:45 || colspan=&amp;quot;3&amp;quot; style=&amp;quot;width:80%; background:#C2C2C2&amp;quot; align=&amp;quot;center&amp;quot; |  '''Wizdom of Crowds / CTF Awards &amp;amp; Raffles'''&lt;br /&gt;
|-&lt;br /&gt;
  | style=&amp;quot;width:10%; background:#7B8ABD&amp;quot; | 18:30-19:30 || colspan=&amp;quot;3&amp;quot; style=&amp;quot;width:80%; background:#C2C2C2&amp;quot; align=&amp;quot;center&amp;quot; | OWASP Foundation, Chapter Leader Meeting&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;[http://guest.cvent.com/i.aspx?4W,M3,828ca6d1-1b60-4105-8034-d344700e6956 http://www.owasp.org/images/7/7f/Register.gif]&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Technology Pavilion - September 24th and 25th  ==&lt;br /&gt;
&lt;br /&gt;
Want to see the latest offerings from technology product and service firms, visit the Technology Pavilion. On September 24th and 25th. 2 full days of exhibits by service providers and manufacturers from around the world.&lt;br /&gt;
&lt;br /&gt;
Do you want to preview the event space [http://www.flickr.com/photos/21550725@N04/sets/72157604662279903/detail Click Here]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;hr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== CPE Credits ==&lt;br /&gt;
&lt;br /&gt;
Much of the content is eligible for CPE credits.  Please check with your institution regarding specific requirements.&lt;br /&gt;
&lt;br /&gt;
'''The CISM cpe policy (www.isaca.org/cismcpepolicy) states''': &lt;br /&gt;
&lt;br /&gt;
One continuing professional education hour is earned for each fifty minutes of active participation (excluding lunches and breaks) in a professional educational activity. Continuing professional education hours are only earned in full-hour increments and rounding must be down. For example, a CISA who attends an eight-hour presentation (480 minutes) with 90 minutes of breaks will earn seven (7) continuing professional education hours.&lt;br /&gt;
&lt;br /&gt;
Activities that qualify for CPE must be directly applicable to the management, design or assessment of an enterprise's information security as per the CISM job practice&amp;quot;&lt;br /&gt;
&lt;br /&gt;
'''Earn (ISC)2 CPE Credits at 2008 OWASP USA, NYC'''&lt;br /&gt;
&lt;br /&gt;
Attendance at the 2008 OWASP NYC Training Courses or Conferences will earn you Continuing Professional Education (CPE) credits as follows:&lt;br /&gt;
Training Courses: September 22-23, 2008&lt;br /&gt;
•	16 CPE units for 2 days of training (Monday - Tuesday) &lt;br /&gt;
•	8 CPE units for 1 day of training (Monday or Tuesday Only) &lt;br /&gt;
Conferences: September 24-25, 2008&lt;br /&gt;
Earn 1 CPE per hour of conference attendance&lt;br /&gt;
&lt;br /&gt;
== [http://www.owasp.org/index.php/Category:OWASP_AppSec_Conference_Training OWASP NYC AppSec 2008 Training Courses - September 22nd and 23rd, 2008] ==&lt;br /&gt;
{| style=&amp;quot;width:80%&amp;quot; border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
 ! align=&amp;quot;center&amp;quot; style=&amp;quot;background:#4058A0; color:white&amp;quot; | T1. Defensive Programming - 2-Days - $1350&lt;br /&gt;
 |-&lt;br /&gt;
 | style=&amp;quot;background:#F2F2F2&amp;quot; | This class will teach you how to program defensively. A must for developers, managers, testers and security professionals. Learn the latest techniques to build attack resistant code, protect from current and future vulnerabilities and how to secure an application from both implementation bugs and design flaws. The instructor Pravir Chandra is well known security expert, project lead for OWASP CLASP project and former co-founder &amp;amp; CTO of secure software [[:Category:OWASP_AppSec_Conference_Training | Learn More Here]]&lt;br /&gt;
&lt;br /&gt;
Instructor: Jason Rouse, Technical Manager, [http://www.cigital.com/training/series http://www.owasp.org/images/b/be/Cigital_OWASP.GIF]''' &lt;br /&gt;
 |-&lt;br /&gt;
{| style=&amp;quot;width:80%&amp;quot; border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
! align=&amp;quot;center&amp;quot; style=&amp;quot;background:#4058A0; color:white&amp;quot; | T2. Secure Coding for Java EE - 2-Days - $1350&lt;br /&gt;
 |-&lt;br /&gt;
 | style=&amp;quot;background:#F2F2F2&amp;quot; | This course is similar to Aspect's Building and Testing Secure Web Applications except it includes a significant amount of Java focused content, including:&lt;br /&gt;
# Java EE security overview,&lt;br /&gt;
# All coding examples and recommendations are specifically focused on Java and Java servers, and&lt;br /&gt;
# 3 additional hands on coding labs where the students find and then fix security vulnerabilities in a Java EE application developed for the class.&lt;br /&gt;
&lt;br /&gt;
[[:Category:OWASP_AppSec_Conference_Training | Learn More Here]]&lt;br /&gt;
&lt;br /&gt;
Instructor: Dave Wichers: [http://www.aspectsecurity.com http://www.owasp.org/images/d/d1/Aspect_logo.gif]&lt;br /&gt;
'''&lt;br /&gt;
 |-&lt;br /&gt;
 ! align=&amp;quot;center&amp;quot; style=&amp;quot;background:#4058A0; color:white&amp;quot; | T3. Web Services and XML Security - 2-Days - $1350&lt;br /&gt;
 |-&lt;br /&gt;
 | style=&amp;quot;background:#F2F2F2&amp;quot; | The movement towards Web Services and Service Oriented architecture (SOA) paradigms requires new security paradigms to deal with new risks posed by these architectures. This session takes a pragmatic approach towards identifying Web Services security risks and selecting and applying countermeasures to the application, code, web servers, databases, application, and identity servers and related software. [[:Category:OWASP_AppSec_Conference_Training | Learn More Here]]&lt;br /&gt;
&lt;br /&gt;
Instructor: Gunnar Peterson''' [http://www.arctecgroup.net https://www.owasp.org/images/b/bf/Arctec.jpg]&lt;br /&gt;
 |-&lt;br /&gt;
 ! align=&amp;quot;center&amp;quot; style=&amp;quot;background:#4058A0; color:white&amp;quot; | T4. Advanced Web Application Security Testing - 2-Days - $1350&lt;br /&gt;
 |-&lt;br /&gt;
 | style=&amp;quot;background:#F2F2F2&amp;quot; | Course Overview While all developers need to know the basics of web application security testing, application security specialists will want to know all the advanced techniques for finding and diagnosing security problems in applications. Aspect’s Advanced Web Application Security Testing training is based on a decade of work verifying the security of critical applications. The course is taught by an experienced application security practitioner in an interactive manner. [[:Category:OWASP_AppSec_Conference_Training | Learn More Here]]&lt;br /&gt;
&lt;br /&gt;
Instructor: Eric Sheridan: [http://www.aspectsecurity.com http://www.owasp.org/images/d/d1/Aspect_logo.gif]'''&lt;br /&gt;
 |-&lt;br /&gt;
 ! align=&amp;quot;center&amp;quot; style=&amp;quot;background:#4058A0; color:white&amp;quot; | T5. Leading the Development of Secure Applications 1-Day - Sept 22nd- $675&lt;br /&gt;
 |-&lt;br /&gt;
 | style=&amp;quot;background:#F2F2F2&amp;quot; |  In this one-day management session you’ll get the answers to the ten key questions that most CIOs and development managers face when trying to improve security in the development process.  The course provides proven techniques and valuable lessons learned that can be applied to projects at any phase of their application’s lifecycle. [[:Category:OWASP_AppSec_Conference_Training | Learn More Here]]&lt;br /&gt;
Instructor: John Pavone: [http://www.aspectsecurity.com http://www.owasp.org/images/d/d1/Aspect_logo.gif]'''&lt;br /&gt;
|-&lt;br /&gt;
 {| style=&amp;quot;width:80%&amp;quot; border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! align=&amp;quot;center&amp;quot; style=&amp;quot;background:#4058A0; color:white&amp;quot; | T6. Building Secure Rich Internet Applications 1-Day - Sept 23rd- $675&lt;br /&gt;
 |-&lt;br /&gt;
 | style=&amp;quot;background:#F2F2F2&amp;quot; |  Rich Internet applications using technologies like Ajax, Flash, ActiveX, and Java Applets require special attention to secure. This one day training addresses the special issues that arise in this type of application development.  [[:Category:OWASP_AppSec_Conference_Training | Learn More Here]]&lt;br /&gt;
Instructor: Arshan Dabirsiaghi: [http://www.aspectsecurity.com http://www.owasp.org/images/d/d1/Aspect_logo.gif]'''&lt;br /&gt;
|-&lt;br /&gt;
 {| style=&amp;quot;width:80%&amp;quot; border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 ! align=&amp;quot;center&amp;quot; style=&amp;quot;background:#4058A0; color:white&amp;quot; | T8. Writing Secure Code  ASP.NET - 2-Days - $1350&lt;br /&gt;
 |-&lt;br /&gt;
 | style=&amp;quot;background:#F2F2F2&amp;quot; | Understand the key security features of the .NET platform, the common web security pitfalls developers make, and how to build secure and reliable web applications using ASP.NET. Students are lead through hands on code examples that highlight issues and prescribe solutions. [[:Category:OWASP_AppSec_Conference_Training | Learn More Here]]&lt;br /&gt;
&lt;br /&gt;
The instructors are Foundstone's Technical Director, Rudolph Araujo and Foundstone's Professional Services Conlultant, Alex Smolen. [http://www.foundstone.com/us/education-overview.asp https://www.owasp.org/images/2/26/Foundstone.jpg]&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;center&amp;gt;[http://guest.cvent.com/i.aspx?4W,M3,828ca6d1-1b60-4105-8034-d344700e6956 https://www.owasp.org/images/7/7f/Register.gif]&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; HOTELS / TRAVEL &amp;lt;/h2&amp;gt;&lt;br /&gt;
[http://maps.google.com/maps?near=Pace+Plz,+New+York,+NY+10038+(Pace+University+New+York+Cmps)&amp;amp;geocode=15467452012610799558,40.711640,-74.005820&amp;amp;q=hotel&amp;amp;f=l&amp;amp;dq=Pace+University-New+York&amp;amp;ie=UTF8&amp;amp;z=15&amp;amp;om=0 Hotels in the area of the event]&lt;br /&gt;
&lt;br /&gt;
New York City MTA: http://www.mta.nyc.ny.us/nyct/index.html&lt;br /&gt;
&lt;br /&gt;
New York City Subway &amp;amp; walking directions: http://www.hopstop.com/?city=newyork&lt;br /&gt;
&lt;br /&gt;
New York Sights &amp;amp; Sounds - SightsSounds&lt;br /&gt;
&lt;br /&gt;
New York City Travel Guide - http://www.nytoday.com/&lt;br /&gt;
&lt;br /&gt;
New York City Attractions - http://www.nycvisit.com&lt;br /&gt;
&lt;br /&gt;
New York TV Show Tickets - Get free tickets to TV shows! - http://www.nytix.com/&lt;br /&gt;
&lt;br /&gt;
New York City local news: http://www.ny1news.com&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt;EVENT SPONSORSHIP &amp;lt;/h2&amp;gt;The OWASP Conferences &amp;amp; Training security technologists including CSOs,admins, application admins, MIS directors, homeland defense chiefs. These important influencers drive buying decisions exclusive access to its audiences. OWASP has established strategic relationships with security—print publications, newsletters, portals, consultants,message—and leadership positioning OWASP events. OWASP’s mission is supported by organizations who share our application, and software security communities. This approach should be part of your mix.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;[https://www.owasp.org/images/6/66/NY_Sponsorship_Form_update_%282%29.pdf Sponsorship Opportunities]- Register online: [http://guest.cvent.com/i.aspx?4W,M3,09e3b490-ba93-4474-851e-be803b1a01c2 click here]&amp;lt;/b&amp;gt;&lt;/div&gt;</summary>
		<author><name>Stephendv</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Security_Assessing_Java_RMI&amp;diff=37565</id>
		<title>Security Assessing Java RMI</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Security_Assessing_Java_RMI&amp;diff=37565"/>
				<updated>2008-08-29T13:25:25Z</updated>
		
		<summary type="html">&lt;p&gt;Stephendv: New page: == Introduction == The talk will describe the process for performing a security assessment on Java RMI services, including identifying and making unauthorised calls to the service.  There ...&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
The talk will describe the process for performing a security assessment on Java RMI services, including identifying and making unauthorised calls to the service.  There are currently no available tools to perform object and method identification.  The techniques described in this talk will be used together with an innovative prototype for an RMI assessment tool to demonstrate how an RMI service can be interrogated and manipulated from a zero knowledge perspective.&lt;br /&gt;
 &lt;br /&gt;
== Outline ==&lt;br /&gt;
* Introduction to Java RMI - What is RMI, how and where is it used.&lt;br /&gt;
* RMI Architecture - How are RMI Client/Server applications structured and what is exposed?&lt;br /&gt;
* Objectives of assessing RMI:&lt;br /&gt;
** Identify the objects and methods that are exposed&lt;br /&gt;
** Make arbitrary calls to those methods.&lt;br /&gt;
* Enumerating bound objects - supported by the standard RMI API&lt;br /&gt;
* Enumerating remote methods - Methods are not exposed, but they can still be obtained!&lt;br /&gt;
** Using existing method signatures&lt;br /&gt;
** Sniffing the wire&lt;br /&gt;
** Brute force - is realistically feasible&lt;br /&gt;
* Determining the number of parameters&lt;br /&gt;
* Determining parameter type&lt;br /&gt;
* Calling remote methods&lt;br /&gt;
* Fuzzing&lt;br /&gt;
* Securing RMI&lt;br /&gt;
** Network controls&lt;br /&gt;
** Security on the server&lt;br /&gt;
** Secure coding of the exposed methods&lt;br /&gt;
&lt;br /&gt;
== About the Author ==&lt;br /&gt;
Adam Boulton is a Research Developer and Security Consultant for Corsaire. He has been involved in all aspects on the SDLC with a focus upon security. He graduated from Sheffield Hallam University with a 1st Class Software Engineering Degree and is also certified for secure code assessments.&lt;br /&gt;
Adam’s past roles have included that of a Software Engineer for the Ministry of Defence and a Virus Analyst for Sophos Plc. At both positions he was heavily involved in Software Development, Reverse Engineering and implementing security.&lt;/div&gt;</summary>
		<author><name>Stephendv</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Talk:Password_length_%26_complexity&amp;diff=27028</id>
		<title>Talk:Password length &amp; complexity</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Talk:Password_length_%26_complexity&amp;diff=27028"/>
				<updated>2008-03-25T12:45:07Z</updated>
		
		<summary type="html">&lt;p&gt;Stephendv: Removing all content from page&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Stephendv</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Category:OWASP_CSRFGuard_Project&amp;diff=26546</id>
		<title>Category:OWASP CSRFGuard Project</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Category:OWASP_CSRFGuard_Project&amp;diff=26546"/>
				<updated>2008-03-10T16:47:23Z</updated>
		
		<summary type="html">&lt;p&gt;Stephendv: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Overview==&lt;br /&gt;
&lt;br /&gt;
Just when developers are starting to run in circles over [[Cross Site Scripting]], the [http://www.darkreading.com/document.asp?doc_id=107651&amp;amp;WT.svl=news1_2 'sleeping giant'] awakes for yet another web-catastrophe. [[Cross-Site Request Forgery]] (CSRF) is an attack whereby the victim is tricked into loading information from or submitting information to a web application for which they are currently authenticated. The problem is that the web application has no means of verifying the integrity of the request. The OWASP CSRFGuard Project attempts to address this issue through the use of unique request tokens. &lt;br /&gt;
&lt;br /&gt;
[http://www.owasp.org/index.php/How_CSRFGuard_Works Click here] for more information regarding the design and implementation of CSRFGuard.&lt;br /&gt;
&lt;br /&gt;
==CSRF Testing Tool==&lt;br /&gt;
&lt;br /&gt;
Check out the [http://www.owasp.org/index.php/Category:OWASP_CSRFTester_Project OWASP CSRF Tester] tool which allows you to test for CSRF vulnerabilities. This tool is also written in Java.&lt;br /&gt;
&lt;br /&gt;
==License==&lt;br /&gt;
&lt;br /&gt;
CSRFGuard is offered under the [http://www.gnu.org/copyleft/lesser.html LGPL]. For further information on OWASP licenses, please consult the [[OWASP Licenses]] page.&lt;br /&gt;
&lt;br /&gt;
== Downloads ==&lt;br /&gt;
&lt;br /&gt;
=== Version 1===&lt;br /&gt;
&lt;br /&gt;
[http://www.owasp.org/index.php/Image:CSRF_Guard.zip Click here] to download the latest version of the OWASP CSRFGuard 1.x series.&lt;br /&gt;
&lt;br /&gt;
=== Version 2===&lt;br /&gt;
&lt;br /&gt;
[http://www.owasp.org/index.php/Image:OWASP-CSRFGuard-2.0.jar Click here] to download the latest OWASP CSRFGuard 2.0 binary.&lt;br /&gt;
&lt;br /&gt;
[http://www.owasp.org/index.php/Image:OWASP_CSRFGuard-2.0-src.zip Click here] to download the latest OWASP CSRFGuard 2.0 source, binary, and sample configuration files '''(Recommended)'''.&lt;br /&gt;
&lt;br /&gt;
[http://www.owasp.org/images/c/c9/CSRF_DangerDetectionDefenses.ppt Click here] to download the author's presentation at the 2007 OWASP conference in San Jose about the dangers of CSRF and a brief description of both CSRF Guard and CSRF Tester.&lt;br /&gt;
&lt;br /&gt;
== Installation Instructions ==&lt;br /&gt;
&lt;br /&gt;
[http://www.owasp.org/index.php/CSRFGuard_1.x_Installation Click here] to view the installation instructions of the OWASP CSRFGuard 1.0 series.&lt;br /&gt;
&lt;br /&gt;
[http://www.owasp.org/index.php/CSRFGuard_2.x_Installation Click here] to view the installation instructions of the OWASP CSRFGuard 2.0 series.&lt;br /&gt;
&lt;br /&gt;
== Road Map ==&lt;br /&gt;
&lt;br /&gt;
[https://www.owasp.org/index.php/CSRF_Guard_2x_Roadmap Click here] to view the road map for the latest development version of CSRFGuard. Please feel free to add your own change requests or send me patches/diffs!&lt;br /&gt;
&lt;br /&gt;
==Feedback and Participation ==&lt;br /&gt;
&lt;br /&gt;
We hope you find CSRFGuard useful. Please contribute back to the project by sending your comments, questions, and suggestions to OWASP. Thanks!&lt;br /&gt;
&lt;br /&gt;
==Similar Projects==&lt;br /&gt;
&lt;br /&gt;
There are a small number of other projects that implement the unique random request token concept similar to that of CSRFGuard. They are as follows:&lt;br /&gt;
&lt;br /&gt;
:*http://www.owasp.org/index.php/PHP_CSRF_Guard&lt;br /&gt;
:*http://www.thespanner.co.uk/2007/10/19/jsck/&lt;br /&gt;
&lt;br /&gt;
==Donations==&lt;br /&gt;
&lt;br /&gt;
The Open Web Application Security Project is purely an open-source community driven effort. As such, all projects and research efforts are contributed and maintained with an individual's ''spare time.'' If you have found this or any other project useful, please support OWASP with a [https://www.owasp.org/index.php/Contributions donation].&lt;br /&gt;
&lt;br /&gt;
==Project Sponsors== &lt;br /&gt;
&lt;br /&gt;
The OWASP CSRFGuard project is sponsored by [http://www.aspectsecurity.com https://www.owasp.org/images/d/d1/Aspect_logo.gif].&lt;br /&gt;
&lt;br /&gt;
[[Category:OWASP_Validation_Project]]&lt;br /&gt;
[[Category:Java]]&lt;br /&gt;
[[Category:OWASP_Project]]&lt;br /&gt;
[[Category:OWASP_Java_Project]]&lt;/div&gt;</summary>
		<author><name>Stephendv</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Preventing_LDAP_Injection_in_Java&amp;diff=26541</id>
		<title>Preventing LDAP Injection in Java</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Preventing_LDAP_Injection_in_Java&amp;diff=26541"/>
				<updated>2008-03-10T16:33:06Z</updated>
		
		<summary type="html">&lt;p&gt;Stephendv: /* Status */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Status==&lt;br /&gt;
Needs to be reviewed&lt;br /&gt;
&lt;br /&gt;
==Approach==&lt;br /&gt;
The best way to prevent LDAP injection is to use a positive validation scheme for ensuring that the data going into your queries doesn't contain any attacks. You can read more in [[:Category:OWASP Guide Project|the OWASP Guide]] about input validation.&lt;br /&gt;
&lt;br /&gt;
However, in some cases, it is necessary to include special characters in input that is passed into an LDAP query.  In this case, using escaping can prevent the LDAP interpreter from thinking those special characters are actually LDAP query.  Rather, the encoding lets the interpreter treat those special characters as data.&lt;br /&gt;
&lt;br /&gt;
Here are a few methods for escaping certain meta-characters in LDAP queries. Both the distinguished name (DN) and the search filter have their own sets of meta-characters.  In the case of Java, it is also necessary to escape any JNDI meta-characters, since java uses JNDI to perform LDAP queries.&lt;br /&gt;
&lt;br /&gt;
    public static String escapeDN(String name) {&lt;br /&gt;
        StringBuffer sb = new StringBuffer(); // If using JDK &amp;gt;= 1.5 consider using StringBuilder&lt;br /&gt;
        if ((name.length() &amp;gt; 0) &amp;amp;&amp;amp; ((name.charAt(0) == ' ') || (name.charAt(0) == '#'))) {&lt;br /&gt;
            sb.append('\\'); // add the leading backslash if needed&lt;br /&gt;
        }&lt;br /&gt;
        for (int i = 0; i &amp;lt; name.length(); i++) {&lt;br /&gt;
            char curChar = name.charAt(i);&lt;br /&gt;
            switch (curChar) {&lt;br /&gt;
                case '\\':&lt;br /&gt;
                    sb.append(&amp;quot;\\\\&amp;quot;);&lt;br /&gt;
                    break;&lt;br /&gt;
                case ',':&lt;br /&gt;
                    sb.append(&amp;quot;\\,&amp;quot;);&lt;br /&gt;
                    break;&lt;br /&gt;
                case '+':&lt;br /&gt;
                    sb.append(&amp;quot;\\+&amp;quot;);&lt;br /&gt;
                    break;&lt;br /&gt;
                case '&amp;quot;':&lt;br /&gt;
                    sb.append(&amp;quot;\\\&amp;quot;&amp;quot;);&lt;br /&gt;
                    break;&lt;br /&gt;
                case '&amp;lt;':&lt;br /&gt;
                    sb.append(&amp;quot;\\&amp;lt;&amp;quot;);&lt;br /&gt;
                    break;&lt;br /&gt;
                case '&amp;gt;':&lt;br /&gt;
                    sb.append(&amp;quot;\\&amp;gt;&amp;quot;);&lt;br /&gt;
                    break;&lt;br /&gt;
                case ';':&lt;br /&gt;
                    sb.append(&amp;quot;\\;&amp;quot;);&lt;br /&gt;
                    break;&lt;br /&gt;
                default:&lt;br /&gt;
                    sb.append(curChar);&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        if ((name.length() &amp;gt; 1) &amp;amp;&amp;amp; (name.charAt(name.length() - 1) == ' ')) {&lt;br /&gt;
            sb.insert(sb.length() - 1, '\\'); // add the trailing backslash if needed&lt;br /&gt;
        }&lt;br /&gt;
        return sb.toString();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
Escaping the search filter:&lt;br /&gt;
&lt;br /&gt;
    public static final String escapeLDAPSearchFilter(String filter) {&lt;br /&gt;
        StringBuffer sb = new StringBuffer(); // If using JDK &amp;gt;= 1.5 consider using StringBuilder&lt;br /&gt;
        for (int i = 0; i &amp;lt; filter.length(); i++) {&lt;br /&gt;
            char curChar = filter.charAt(i);&lt;br /&gt;
            switch (curChar) {&lt;br /&gt;
                case '\\':&lt;br /&gt;
                    sb.append(&amp;quot;\\5c&amp;quot;);&lt;br /&gt;
                    break;&lt;br /&gt;
                case '*':&lt;br /&gt;
                    sb.append(&amp;quot;\\2a&amp;quot;);&lt;br /&gt;
                    break;&lt;br /&gt;
                case '(':&lt;br /&gt;
                    sb.append(&amp;quot;\\28&amp;quot;);&lt;br /&gt;
                    break;&lt;br /&gt;
                case ')':&lt;br /&gt;
                    sb.append(&amp;quot;\\29&amp;quot;);&lt;br /&gt;
                    break;&lt;br /&gt;
                case '\u0000': &lt;br /&gt;
                    sb.append(&amp;quot;\\00&amp;quot;); &lt;br /&gt;
                    break;&lt;br /&gt;
                default:&lt;br /&gt;
                    sb.append(curChar);&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        return sb.toString();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
Test class:&lt;br /&gt;
&lt;br /&gt;
        //escapeDN&lt;br /&gt;
        assertEquals(&amp;quot;No special characters to escape&amp;quot;, &amp;quot;Helloé&amp;quot;, escapeDN(&amp;quot;Helloé&amp;quot;));&lt;br /&gt;
        assertEquals(&amp;quot;leading #&amp;quot;, &amp;quot;\\# Helloé&amp;quot;, escapeDN(&amp;quot;# Helloé&amp;quot;));&lt;br /&gt;
        assertEquals(&amp;quot;leading space&amp;quot;, &amp;quot;\\ Helloé&amp;quot;, escapeDN(&amp;quot; Helloé&amp;quot;));&lt;br /&gt;
        assertEquals(&amp;quot;trailing space&amp;quot;, &amp;quot;Helloé\\ &amp;quot;, escapeDN(&amp;quot;Helloé &amp;quot;));&lt;br /&gt;
        assertEquals(&amp;quot;only 3 spaces&amp;quot;, &amp;quot;\\  \\ &amp;quot;, escapeDN(&amp;quot;   &amp;quot;));&lt;br /&gt;
        assertEquals(&amp;quot;Christmas Tree DN&amp;quot;, &amp;quot;\\ Hello\\\\ \\+ \\, \\\&amp;quot;World\\\&amp;quot; \\;\\ &amp;quot;, Test.escapeDN(&amp;quot; Hello\\ + , \&amp;quot;World\&amp;quot; ; &amp;quot;));&lt;br /&gt;
&lt;br /&gt;
        assertEquals(&amp;quot;No special characters to escape&amp;quot;, &amp;quot;Hi This is a test #çà&amp;quot;, SecTool.escapeLDAPSearchFilter(&amp;quot;Hi This is a test #çà&amp;quot;));&lt;br /&gt;
        assertEquals(&amp;quot;LDAP Christams Tree&amp;quot;, &amp;quot;Hi \\28This\\29 = is \\2a a \\5c test # ç à ô&amp;quot;, SecTool.escapeLDAPSearchFilter(&amp;quot;Hi (This) = is * a \\ test # ç à ô&amp;quot;));&lt;br /&gt;
&lt;br /&gt;
[[Category:OWASP Java Project]]&lt;/div&gt;</summary>
		<author><name>Stephendv</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Preventing_LDAP_Injection_in_Java&amp;diff=26540</id>
		<title>Preventing LDAP Injection in Java</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Preventing_LDAP_Injection_in_Java&amp;diff=26540"/>
				<updated>2008-03-10T16:32:31Z</updated>
		
		<summary type="html">&lt;p&gt;Stephendv: /* Author */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Status==&lt;br /&gt;
'''Broken code!  Needs to be corrected.'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Approach==&lt;br /&gt;
The best way to prevent LDAP injection is to use a positive validation scheme for ensuring that the data going into your queries doesn't contain any attacks. You can read more in [[:Category:OWASP Guide Project|the OWASP Guide]] about input validation.&lt;br /&gt;
&lt;br /&gt;
However, in some cases, it is necessary to include special characters in input that is passed into an LDAP query.  In this case, using escaping can prevent the LDAP interpreter from thinking those special characters are actually LDAP query.  Rather, the encoding lets the interpreter treat those special characters as data.&lt;br /&gt;
&lt;br /&gt;
Here are a few methods for escaping certain meta-characters in LDAP queries. Both the distinguished name (DN) and the search filter have their own sets of meta-characters.  In the case of Java, it is also necessary to escape any JNDI meta-characters, since java uses JNDI to perform LDAP queries.&lt;br /&gt;
&lt;br /&gt;
    public static String escapeDN(String name) {&lt;br /&gt;
        StringBuffer sb = new StringBuffer(); // If using JDK &amp;gt;= 1.5 consider using StringBuilder&lt;br /&gt;
        if ((name.length() &amp;gt; 0) &amp;amp;&amp;amp; ((name.charAt(0) == ' ') || (name.charAt(0) == '#'))) {&lt;br /&gt;
            sb.append('\\'); // add the leading backslash if needed&lt;br /&gt;
        }&lt;br /&gt;
        for (int i = 0; i &amp;lt; name.length(); i++) {&lt;br /&gt;
            char curChar = name.charAt(i);&lt;br /&gt;
            switch (curChar) {&lt;br /&gt;
                case '\\':&lt;br /&gt;
                    sb.append(&amp;quot;\\\\&amp;quot;);&lt;br /&gt;
                    break;&lt;br /&gt;
                case ',':&lt;br /&gt;
                    sb.append(&amp;quot;\\,&amp;quot;);&lt;br /&gt;
                    break;&lt;br /&gt;
                case '+':&lt;br /&gt;
                    sb.append(&amp;quot;\\+&amp;quot;);&lt;br /&gt;
                    break;&lt;br /&gt;
                case '&amp;quot;':&lt;br /&gt;
                    sb.append(&amp;quot;\\\&amp;quot;&amp;quot;);&lt;br /&gt;
                    break;&lt;br /&gt;
                case '&amp;lt;':&lt;br /&gt;
                    sb.append(&amp;quot;\\&amp;lt;&amp;quot;);&lt;br /&gt;
                    break;&lt;br /&gt;
                case '&amp;gt;':&lt;br /&gt;
                    sb.append(&amp;quot;\\&amp;gt;&amp;quot;);&lt;br /&gt;
                    break;&lt;br /&gt;
                case ';':&lt;br /&gt;
                    sb.append(&amp;quot;\\;&amp;quot;);&lt;br /&gt;
                    break;&lt;br /&gt;
                default:&lt;br /&gt;
                    sb.append(curChar);&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        if ((name.length() &amp;gt; 1) &amp;amp;&amp;amp; (name.charAt(name.length() - 1) == ' ')) {&lt;br /&gt;
            sb.insert(sb.length() - 1, '\\'); // add the trailing backslash if needed&lt;br /&gt;
        }&lt;br /&gt;
        return sb.toString();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
Escaping the search filter:&lt;br /&gt;
&lt;br /&gt;
    public static final String escapeLDAPSearchFilter(String filter) {&lt;br /&gt;
        StringBuffer sb = new StringBuffer(); // If using JDK &amp;gt;= 1.5 consider using StringBuilder&lt;br /&gt;
        for (int i = 0; i &amp;lt; filter.length(); i++) {&lt;br /&gt;
            char curChar = filter.charAt(i);&lt;br /&gt;
            switch (curChar) {&lt;br /&gt;
                case '\\':&lt;br /&gt;
                    sb.append(&amp;quot;\\5c&amp;quot;);&lt;br /&gt;
                    break;&lt;br /&gt;
                case '*':&lt;br /&gt;
                    sb.append(&amp;quot;\\2a&amp;quot;);&lt;br /&gt;
                    break;&lt;br /&gt;
                case '(':&lt;br /&gt;
                    sb.append(&amp;quot;\\28&amp;quot;);&lt;br /&gt;
                    break;&lt;br /&gt;
                case ')':&lt;br /&gt;
                    sb.append(&amp;quot;\\29&amp;quot;);&lt;br /&gt;
                    break;&lt;br /&gt;
                case '\u0000': &lt;br /&gt;
                    sb.append(&amp;quot;\\00&amp;quot;); &lt;br /&gt;
                    break;&lt;br /&gt;
                default:&lt;br /&gt;
                    sb.append(curChar);&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        return sb.toString();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
Test class:&lt;br /&gt;
&lt;br /&gt;
        //escapeDN&lt;br /&gt;
        assertEquals(&amp;quot;No special characters to escape&amp;quot;, &amp;quot;Helloé&amp;quot;, escapeDN(&amp;quot;Helloé&amp;quot;));&lt;br /&gt;
        assertEquals(&amp;quot;leading #&amp;quot;, &amp;quot;\\# Helloé&amp;quot;, escapeDN(&amp;quot;# Helloé&amp;quot;));&lt;br /&gt;
        assertEquals(&amp;quot;leading space&amp;quot;, &amp;quot;\\ Helloé&amp;quot;, escapeDN(&amp;quot; Helloé&amp;quot;));&lt;br /&gt;
        assertEquals(&amp;quot;trailing space&amp;quot;, &amp;quot;Helloé\\ &amp;quot;, escapeDN(&amp;quot;Helloé &amp;quot;));&lt;br /&gt;
        assertEquals(&amp;quot;only 3 spaces&amp;quot;, &amp;quot;\\  \\ &amp;quot;, escapeDN(&amp;quot;   &amp;quot;));&lt;br /&gt;
        assertEquals(&amp;quot;Christmas Tree DN&amp;quot;, &amp;quot;\\ Hello\\\\ \\+ \\, \\\&amp;quot;World\\\&amp;quot; \\;\\ &amp;quot;, Test.escapeDN(&amp;quot; Hello\\ + , \&amp;quot;World\&amp;quot; ; &amp;quot;));&lt;br /&gt;
&lt;br /&gt;
        assertEquals(&amp;quot;No special characters to escape&amp;quot;, &amp;quot;Hi This is a test #çà&amp;quot;, SecTool.escapeLDAPSearchFilter(&amp;quot;Hi This is a test #çà&amp;quot;));&lt;br /&gt;
        assertEquals(&amp;quot;LDAP Christams Tree&amp;quot;, &amp;quot;Hi \\28This\\29 = is \\2a a \\5c test # ç à ô&amp;quot;, SecTool.escapeLDAPSearchFilter(&amp;quot;Hi (This) = is * a \\ test # ç à ô&amp;quot;));&lt;br /&gt;
&lt;br /&gt;
[[Category:OWASP Java Project]]&lt;/div&gt;</summary>
		<author><name>Stephendv</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Preventing_LDAP_Injection_in_Java&amp;diff=26539</id>
		<title>Preventing LDAP Injection in Java</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Preventing_LDAP_Injection_in_Java&amp;diff=26539"/>
				<updated>2008-03-10T16:16:04Z</updated>
		
		<summary type="html">&lt;p&gt;Stephendv: /* Approach */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Status==&lt;br /&gt;
'''Broken code!  Needs to be corrected.'''&lt;br /&gt;
&lt;br /&gt;
==Author==&lt;br /&gt;
==Approach==&lt;br /&gt;
The best way to prevent LDAP injection is to use a positive validation scheme for ensuring that the data going into your queries doesn't contain any attacks. You can read more in [[:Category:OWASP Guide Project|the OWASP Guide]] about input validation.&lt;br /&gt;
&lt;br /&gt;
However, in some cases, it is necessary to include special characters in input that is passed into an LDAP query.  In this case, using escaping can prevent the LDAP interpreter from thinking those special characters are actually LDAP query.  Rather, the encoding lets the interpreter treat those special characters as data.&lt;br /&gt;
&lt;br /&gt;
Here are a few methods for escaping certain meta-characters in LDAP queries. Both the distinguished name (DN) and the search filter have their own sets of meta-characters.  In the case of Java, it is also necessary to escape any JNDI meta-characters, since java uses JNDI to perform LDAP queries.&lt;br /&gt;
&lt;br /&gt;
    public static String escapeDN(String name) {&lt;br /&gt;
        StringBuffer sb = new StringBuffer(); // If using JDK &amp;gt;= 1.5 consider using StringBuilder&lt;br /&gt;
        if ((name.length() &amp;gt; 0) &amp;amp;&amp;amp; ((name.charAt(0) == ' ') || (name.charAt(0) == '#'))) {&lt;br /&gt;
            sb.append('\\'); // add the leading backslash if needed&lt;br /&gt;
        }&lt;br /&gt;
        for (int i = 0; i &amp;lt; name.length(); i++) {&lt;br /&gt;
            char curChar = name.charAt(i);&lt;br /&gt;
            switch (curChar) {&lt;br /&gt;
                case '\\':&lt;br /&gt;
                    sb.append(&amp;quot;\\\\&amp;quot;);&lt;br /&gt;
                    break;&lt;br /&gt;
                case ',':&lt;br /&gt;
                    sb.append(&amp;quot;\\,&amp;quot;);&lt;br /&gt;
                    break;&lt;br /&gt;
                case '+':&lt;br /&gt;
                    sb.append(&amp;quot;\\+&amp;quot;);&lt;br /&gt;
                    break;&lt;br /&gt;
                case '&amp;quot;':&lt;br /&gt;
                    sb.append(&amp;quot;\\\&amp;quot;&amp;quot;);&lt;br /&gt;
                    break;&lt;br /&gt;
                case '&amp;lt;':&lt;br /&gt;
                    sb.append(&amp;quot;\\&amp;lt;&amp;quot;);&lt;br /&gt;
                    break;&lt;br /&gt;
                case '&amp;gt;':&lt;br /&gt;
                    sb.append(&amp;quot;\\&amp;gt;&amp;quot;);&lt;br /&gt;
                    break;&lt;br /&gt;
                case ';':&lt;br /&gt;
                    sb.append(&amp;quot;\\;&amp;quot;);&lt;br /&gt;
                    break;&lt;br /&gt;
                default:&lt;br /&gt;
                    sb.append(curChar);&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        if ((name.length() &amp;gt; 1) &amp;amp;&amp;amp; (name.charAt(name.length() - 1) == ' ')) {&lt;br /&gt;
            sb.insert(sb.length() - 1, '\\'); // add the trailing backslash if needed&lt;br /&gt;
        }&lt;br /&gt;
        return sb.toString();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
Escaping the search filter:&lt;br /&gt;
&lt;br /&gt;
    public static final String escapeLDAPSearchFilter(String filter) {&lt;br /&gt;
        StringBuffer sb = new StringBuffer(); // If using JDK &amp;gt;= 1.5 consider using StringBuilder&lt;br /&gt;
        for (int i = 0; i &amp;lt; filter.length(); i++) {&lt;br /&gt;
            char curChar = filter.charAt(i);&lt;br /&gt;
            switch (curChar) {&lt;br /&gt;
                case '\\':&lt;br /&gt;
                    sb.append(&amp;quot;\\5c&amp;quot;);&lt;br /&gt;
                    break;&lt;br /&gt;
                case '*':&lt;br /&gt;
                    sb.append(&amp;quot;\\2a&amp;quot;);&lt;br /&gt;
                    break;&lt;br /&gt;
                case '(':&lt;br /&gt;
                    sb.append(&amp;quot;\\28&amp;quot;);&lt;br /&gt;
                    break;&lt;br /&gt;
                case ')':&lt;br /&gt;
                    sb.append(&amp;quot;\\29&amp;quot;);&lt;br /&gt;
                    break;&lt;br /&gt;
                case '\u0000': &lt;br /&gt;
                    sb.append(&amp;quot;\\00&amp;quot;); &lt;br /&gt;
                    break;&lt;br /&gt;
                default:&lt;br /&gt;
                    sb.append(curChar);&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        return sb.toString();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
Test class:&lt;br /&gt;
&lt;br /&gt;
        //escapeDN&lt;br /&gt;
        assertEquals(&amp;quot;No special characters to escape&amp;quot;, &amp;quot;Helloé&amp;quot;, escapeDN(&amp;quot;Helloé&amp;quot;));&lt;br /&gt;
        assertEquals(&amp;quot;leading #&amp;quot;, &amp;quot;\\# Helloé&amp;quot;, escapeDN(&amp;quot;# Helloé&amp;quot;));&lt;br /&gt;
        assertEquals(&amp;quot;leading space&amp;quot;, &amp;quot;\\ Helloé&amp;quot;, escapeDN(&amp;quot; Helloé&amp;quot;));&lt;br /&gt;
        assertEquals(&amp;quot;trailing space&amp;quot;, &amp;quot;Helloé\\ &amp;quot;, escapeDN(&amp;quot;Helloé &amp;quot;));&lt;br /&gt;
        assertEquals(&amp;quot;only 3 spaces&amp;quot;, &amp;quot;\\  \\ &amp;quot;, escapeDN(&amp;quot;   &amp;quot;));&lt;br /&gt;
        assertEquals(&amp;quot;Christmas Tree DN&amp;quot;, &amp;quot;\\ Hello\\\\ \\+ \\, \\\&amp;quot;World\\\&amp;quot; \\;\\ &amp;quot;, Test.escapeDN(&amp;quot; Hello\\ + , \&amp;quot;World\&amp;quot; ; &amp;quot;));&lt;br /&gt;
&lt;br /&gt;
        assertEquals(&amp;quot;No special characters to escape&amp;quot;, &amp;quot;Hi This is a test #çà&amp;quot;, SecTool.escapeLDAPSearchFilter(&amp;quot;Hi This is a test #çà&amp;quot;));&lt;br /&gt;
        assertEquals(&amp;quot;LDAP Christams Tree&amp;quot;, &amp;quot;Hi \\28This\\29 = is \\2a a \\5c test # ç à ô&amp;quot;, SecTool.escapeLDAPSearchFilter(&amp;quot;Hi (This) = is * a \\ test # ç à ô&amp;quot;));&lt;br /&gt;
&lt;br /&gt;
[[Category:OWASP Java Project]]&lt;/div&gt;</summary>
		<author><name>Stephendv</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Talk:Password_length_%26_complexity&amp;diff=26537</id>
		<title>Talk:Password length &amp; complexity</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Talk:Password_length_%26_complexity&amp;diff=26537"/>
				<updated>2008-03-10T16:06:28Z</updated>
		
		<summary type="html">&lt;p&gt;Stephendv: New page: The OWASP Guide project is the place for generic recommendations for implementing security.  What we need for this article is code examples on how to provide password length and complexity...&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The OWASP Guide project is the place for generic recommendations for implementing security.  What we need for this article is code examples on how to provide password length and complexity solution in Java.&lt;/div&gt;</summary>
		<author><name>Stephendv</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Java_Server_Faces&amp;diff=26533</id>
		<title>Java Server Faces</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Java_Server_Faces&amp;diff=26533"/>
				<updated>2008-03-10T15:53:06Z</updated>
		
		<summary type="html">&lt;p&gt;Stephendv: /* Web security.. before you start */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Status==&lt;br /&gt;
Under review 10/3/2008&lt;br /&gt;
&lt;br /&gt;
==Web security.. before you start ==&lt;br /&gt;
&lt;br /&gt;
This document is about security in web applications developed using the Java Server Faces (JSF) framework. The reader should be aware of the meaning of common terms of both JSF (converters, validators, managed beans) and web security (injection etc.)&lt;br /&gt;
&lt;br /&gt;
==JSF Standards and roles==&lt;br /&gt;
JavaServer Faces (JSF) is a Java-based Web application framework that implements the Model-View-Controller pattern and simplifies the development of web interfaces for Java EE applications.&lt;br /&gt;
&lt;br /&gt;
In a standard MVC JSF are meant to provide the V (of view) and part of the C (of Control). JSF components can present almost any basic interface model. The framework also provides part of the Control layer including:&lt;br /&gt;
* Navigation Handling &lt;br /&gt;
* Error Handling &lt;br /&gt;
* Action and event Management &lt;br /&gt;
* Input validation &lt;br /&gt;
* Value conversion &lt;br /&gt;
These elements are defined by the JSF standard (JCP 127) so that any attacker will have knowledge of the architecture and life cycle of a JSF based application. JSF does not implement it's own security model but instead relies on standard JEE security. This means that both application server security model, JAAS or other ACL implementations can be used with the JSF framework without any integration effort. But Access Control is just one part of security - all aspects should be implemented in a secure manner in order to consider the application itself secure.&lt;br /&gt;
&lt;br /&gt;
==Client-side state saving==&lt;br /&gt;
A JSF application can save the state of its components in the client response or on the server. Saving state on the client may be required because some users turn off cookies support, but it can increase response times when connections are slow. Saving state on the server may have the disadvantage of high memory consumption for the user, but it does minimize bandwidth requirements.&lt;br /&gt;
Since client-side state saving stores data in the client , it should be used wisely, or not used at all. An attacker that can manipulate a user's data could manage a data tampering or worst, a privilege escalation exploit. Unencrypted data is quite easy to manipulate and most of the client-side saved data are serialized Java objects  which can contain a wealth of sensitive data. If you plan to use client-side state saving carefully consider which information you decide to store in the POJO/DTO in order to minimise these risks.&lt;br /&gt;
==Components==&lt;br /&gt;
===Converters===&lt;br /&gt;
Converter could be a source of threat since it converts string in Java objects. An attacker could inject malicious code or tampered data to make the converter itself misbehave and expose protected data. The converter system is not insecure by itself, but conversion, since it is a security touch point for business logic and persistent data, should be handled carefully. Input should '''always''' be validated '''after''' being converted. In JSF lingo you should '''always''' have a validator if a conversion occurs. See next section on how to implement a security aware validator.&lt;br /&gt;
&lt;br /&gt;
===Validators===&lt;br /&gt;
Validation is your chance to verify that the input is as expected. This means that the input should be validated both from a domain view and from a security view. If input represents a string that in your domain should be from 10 to 254 characters long, the same string should be validated also to prevent SQL Injection and XSS attacks. Since many security checks are done using dictionary algorithms it's useful to have a validator that implements those checks and extends it to implement your domain validator.&lt;br /&gt;
For example:&lt;br /&gt;
&lt;br /&gt;
 public class TenToHundredsValidator extends SecureValidator() {&lt;br /&gt;
    public void validate(...) {&lt;br /&gt;
       &lt;br /&gt;
       super.validate(...); // Do security checks&lt;br /&gt;
       &lt;br /&gt;
       domainvalidate(....);&lt;br /&gt;
    }&lt;br /&gt;
 }          &lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===ManagedBeans===&lt;br /&gt;
Managed beans are the gears of JSF based application. Developers can access FacesContext statically and this is potentially dangerous. This is a common short cut for everything in the JSF layer, but manipulating this data could be harmful. Relying on security principals, and software engineering, is always a good approach.&lt;br /&gt;
Calls such as:&lt;br /&gt;
    FacesContext.getCurrentInstance().getExternalContext().getRequestParameter(&amp;quot;name&amp;quot;)&lt;br /&gt;
are dangerous because the whole validation stack is bypassed. You can read parameters but consider them as tainted input. Use Validators described above also if you are not in the validation phase . Validators are also an effective way to refactor your validation code and to prevent code repetition.&lt;br /&gt;
FacesContext  also allows access to user principal data; this data could be used to verify if the current user can actually execute the business logic in the managed Bean.&lt;br /&gt;
This practice should be adopted in favour of rendering or not the commandLinks that lead to the action of the managed Bean. A structured adoption of an execution based security framework , such as ACEGI (see the Appendix), could be a good enforcement of the security of the  managed bean.&lt;br /&gt;
===Custom components===&lt;br /&gt;
If the use of custom components is required in the application, the security depends on how the components are developed. Third party components should be delivered with a security report and support from the specific vendor or community.&lt;br /&gt;
If you develop custom components you should be aware of the same old security issues of web development:&lt;br /&gt;
* Do not trust request parameter &lt;br /&gt;
* Do not trust cookies &lt;br /&gt;
* Always consider that session could be hijacked &lt;br /&gt;
Since the component tree is assembled server side it can be trusted so if your custom component needs to read data from a sibling component it should be considered a safe operation although you will have to make assumptions on element names of the tree.&lt;br /&gt;
&lt;br /&gt;
==Implementations==&lt;br /&gt;
Since more than one JSF Implementation exists, bugs of the implementation should be first on the security list.&lt;br /&gt;
&lt;br /&gt;
===MyFaces===&lt;br /&gt;
There aren't major or critical security bugs registered in the current stable release of MyFaces (1.1.5). Client state saving is still the weak point and should be used wisely. My Faces comes also with a Security Extension  (http://wiki.apache.org/myfaces/SecurityContext) that allows to safely and easily retrieve authenticated user details.&lt;br /&gt;
&lt;br /&gt;
The MyFaces resource filter could be a source of threat. It is designed to expose resources from a jar file and could therefore, be considered, potentially dangerous. Note there aren't any claimed security flaws nor exploits in the resource filter, but the nature of this component makes it a good target for attackers. Since all it has to do is serve data it is recommended that a dispatcher be added to the filter mapping element. This should lower the possibility of an attacker successfully manipulating the server request.&lt;br /&gt;
For more information see: http://myfaces.apache.org/tomahawk/extensionsFilter.htm&lt;br /&gt;
&lt;br /&gt;
There is also an easy way to enable encryption when using ''client save state''&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;context-param&amp;gt;&lt;br /&gt;
        &amp;lt;param-name&amp;gt;org.apache.myfaces.secret&amp;lt;/param-name&amp;gt;&lt;br /&gt;
        &amp;lt;param-value&amp;gt;NzY1NDMyMTA=&amp;lt;/param-value&amp;gt;&lt;br /&gt;
    &amp;lt;/context-param&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Supported encryption methods are BlowFish, 3DES, AES and are definde bya a context parameter&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;context-param&amp;gt;&lt;br /&gt;
        &amp;lt;param-name&amp;gt;org.apache.myfaces.algorithm&amp;lt;/param-name&amp;gt;&lt;br /&gt;
        &amp;lt;param-value&amp;gt;Blowfish&amp;lt;/param-value&amp;gt;&lt;br /&gt;
    &amp;lt;/context-param&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can find mre info at http://wiki.apache.org/myfaces/Secure_Your_Application&lt;br /&gt;
&lt;br /&gt;
===SUN Reference Implementation===&lt;br /&gt;
Quoting from the documentation:&lt;br /&gt;
''There are several ways for a web application to store session state on the client tier. One possible solution is to use Cookies to store the state on the client. However, cookies have limitations in size and are not ideal in cases where you want to store session state on the client.  The state that needs to be stored on the client is first serialized into a byte array. This byte array is then encrypted using industrial-strength 3DES with cipher-block-chaining (CBC) and an initialization vector. To make the content tamper-resistant, we then create a message authentication code (using SHA1 algorithm) from the encrypted content and the initialization vector. The initialization vector, the message authentication code, and the encrypted content is then combined in a single byte array. Finally, this resulting byte array is converted into a base64 string which is stored in a hidden FORM field on the client.&lt;br /&gt;
This solution is secure because it uses a strong crypto algorithm and also uses a MAC for tamper-resistance. We also generate all the random numbers (for example, to generate the initialization vectors and the password) using the cryptographically-secure SecureRandom class. Note that the encryption keys are NEVER sent to the client or sent on the wire. These keys are used only on the server-side to encrypt and decrypt the state. One challenge is to decide what encryption keys to use. The encryption keys should not be known to the client, but still be associated with the client. We solve this problem by generating these keys from a password that is generated randomly and stored in the HttpSession. This strategy for key generation through password is pluggable in our solution and can be changed if needed.''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===ICE Faces===&lt;br /&gt;
&lt;br /&gt;
Starting from the idea that AJAX on Its Own Doesn't Corrupt Web Security ICE faces implements a component suite with ajax support by maintainig a coninus sync bettween the dom sent to the browser and a dom rapresentation on the server. javascript is used to send commands to the server and invoke the logic in the java layer. Since dom model and javascript is involved a Javascript debugging  tool with value injection or dom injection capability could be of some use in pick loking the app.&lt;br /&gt;
&lt;br /&gt;
As stated in ICEFaces manual &amp;quot; the client is untrusted, SO DON'T TRUST IT!!&amp;quot; : it means that is all ups to the application designer to implement a robust security logic behind the scenes.&lt;br /&gt;
In another point of view th developer could focus on implement server side security since with the server-side-dom architecture the thin client is even thinner.&lt;br /&gt;
&lt;br /&gt;
The component thath refresh the two dom , caled IntervalRenderer, uses  a persistent ServletRequest stored on the server. Unfortunately, this request does not contain sufficient information to perform the isUserInRole() check.&lt;br /&gt;
This kind of check is possible only on stadar render request phase. &lt;br /&gt;
&lt;br /&gt;
To address this, a small amount of integration will be required either between ICEfaces and acegi-security or ICEfaces and the application server.  Acegi-security (see appendix one ) is likely preferable as it will be more portable.&lt;br /&gt;
&lt;br /&gt;
==Apendix I==&lt;br /&gt;
&lt;br /&gt;
===ACEGI Integration===&lt;br /&gt;
&lt;br /&gt;
Acegi Security is a powerful, flexible security solution for enterprise software, with a particular emphasis on applications that use Spring. If used in combination with jsf, the managed beans could become more &amp;quot;security aware&amp;quot; since acegi do not only perform authentication but also authorization in business layer. Acegi is a convenient way to manage security in all the layers of our application. This is a valuable thing especially when authorization is strongly coupled with business logic (approval work flows etc).&lt;br /&gt;
&lt;br /&gt;
In order to use a custom JSF-Acegi login we have to provide a valid Security Context (''userName'' and ''password'' are properties of the managed bean)&lt;br /&gt;
&lt;br /&gt;
 UsernamePasswordAuthenticationToken authReq = new UsernamePasswordAuthenticationToken(userName, password);&lt;br /&gt;
 Authentication auth = getAuthenticationManager().authenticate(authReq);&lt;br /&gt;
 SecurityContext secCtx = SecurityContextHolder.getContext();&lt;br /&gt;
 secCtx.setAuthentication(auth);&lt;br /&gt;
&lt;br /&gt;
We can override the standard ACEGI navigation with custom, logic driven, navigation reading security context and routing the outcome.&lt;br /&gt;
&lt;br /&gt;
More information can be found at  here [http://www.javakaffee.de/blog/2006/07/04/jsfacegi-authentication-with-a-backing-bean/]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
ACEGI can be integrated also in the rendering via custom components [http://cagataycivici.wordpress.com/2006/01/19/acegi_jsf_components_hit_the/] which basically wrap the standard ACEGI tag library in JSF components. This conveniently solve the ''stage zero'' of profiling: display or not a widget in the page.&lt;br /&gt;
&lt;br /&gt;
Including a JSF based form for login in a page could be a little tricky, bu using MyFaces tomahawk components it can be done easely.&lt;br /&gt;
&lt;br /&gt;
The form will look like&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;%@ taglib uri=&amp;quot;http://myfaces.apache.org/tomahawk&amp;quot; prefix=&amp;quot;t&amp;quot;%&amp;gt;&lt;br /&gt;
 &amp;lt;t:inputText id=&amp;quot;j_username&amp;quot; forceId=&amp;quot;true&amp;quot; value=&amp;quot;#{backingBean.customerId}&amp;quot; size=&amp;quot;40&amp;quot; maxlength=&amp;quot;80&amp;quot;&amp;gt;&amp;lt;/t:inputText&amp;gt;&lt;br /&gt;
 &amp;lt;t:inputSecret id=&amp;quot;j_password&amp;quot; forceId=&amp;quot;true&amp;quot; value=&amp;quot;#{backingBean.password}&amp;quot; size=&amp;quot;40&amp;quot; maxlength=&amp;quot;80&amp;quot; redisplay=&amp;quot;true&amp;quot;&amp;gt;&amp;lt;/t:inputSecret&amp;gt;&lt;br /&gt;
 &amp;lt;h:commandButton action=&amp;quot;login&amp;quot; value=&amp;quot;#{messages.page_signon}&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;h:messages id=&amp;quot;messages&amp;quot; layout=&amp;quot;table&amp;quot; globalOnly=&amp;quot;true&amp;quot; showSummary=&amp;quot;true&amp;quot; showDetail=&amp;quot;false&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A navigation rule to follow ACEGI requirements&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;navigation-rule&amp;gt;&lt;br /&gt;
        &amp;lt;from-view-id&amp;gt;/login.jsp&amp;lt;/from-view-id&amp;gt;&lt;br /&gt;
        &amp;lt;navigation-case&amp;gt;&lt;br /&gt;
                &amp;lt;from-outcome&amp;gt;login&amp;lt;/from-outcome&amp;gt;&lt;br /&gt;
                &amp;lt;to-view-id&amp;gt;/j_acegi_security_check.jsp&amp;lt;/to-view-id&amp;gt;&lt;br /&gt;
        &amp;lt;/navigation-case&amp;gt;&lt;br /&gt;
 &amp;lt;/navigation-rule&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And finaly ACEGI is told which page do the login&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;bean id=&amp;quot;formAuthenticationProcessingFilter&amp;quot; class=&amp;quot;org.acegisecurity.ui.webapp.AuthenticationProcessingFilter&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;property name=&amp;quot;filterProcessesUrl&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;value&amp;gt;/j_acegi_security_check.jsp&amp;lt;/value&amp;gt;&lt;br /&gt;
        &amp;lt;/property&amp;gt;&lt;br /&gt;
        &amp;lt;property name=&amp;quot;authenticationFailureUrl&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;value&amp;gt;/login.faces&amp;lt;/value&amp;gt;&lt;br /&gt;
        &amp;lt;/property&amp;gt;&lt;br /&gt;
        ...&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:OWASP Java Project]]&lt;/div&gt;</summary>
		<author><name>Stephendv</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Java_Security_Frameworks&amp;diff=26532</id>
		<title>Java Security Frameworks</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Java_Security_Frameworks&amp;diff=26532"/>
				<updated>2008-03-10T15:40:31Z</updated>
		
		<summary type="html">&lt;p&gt;Stephendv: /* Access Control (Authentication and Authorisation) */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;A list of third party (i.e. not part of Java SE or EE) security frameworks.&lt;br /&gt;
&lt;br /&gt;
==Enterprise==&lt;br /&gt;
* [http://www.owasp.org/index.php/ESAPI OWASP Enterprise Security API] a new OWASP project to provide all essential security services under one roof.&lt;br /&gt;
&lt;br /&gt;
== Access Control (Authentication and Authorisation) ==&lt;br /&gt;
* [http://www.acegisecurity.org/ Acegi Security] - Acegi Security is a powerful, flexible security solution for enterprise software, with a particular emphasis on applications that use Spring. Using Acegi Security provides your applications with comprehensive authentication, authorization, instance-based access control, channel security and human user detection capabilities.&lt;br /&gt;
* [http://sourceforge.net/projects/jguard jGuard] - jGuard is written in Java. Its goal is to provide a security framework based on JAAS (Java Authentication and Authorization Security). The framework is written for web and standalone applications, to easily provide solutions for access control problems.&lt;br /&gt;
&lt;br /&gt;
== Encryption ==&lt;br /&gt;
* [http://www.bouncycastle.org/ Bouncycastle] - Lightweight Java cryptography APIs&lt;br /&gt;
* [http://www.jasypt.org/ Jasypt] - Jasypt is a java library which allows the developer to add basic encryption capabilities to his/her projects with minimum effort, and without the need of having deep knowledge on how cryptography works.&lt;br /&gt;
&lt;br /&gt;
[[Category:OWASP Java Project]]&lt;/div&gt;</summary>
		<author><name>Stephendv</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=How_to_perform_HTML_entity_encoding_in_Java&amp;diff=24496</id>
		<title>How to perform HTML entity encoding in Java</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=How_to_perform_HTML_entity_encoding_in_Java&amp;diff=24496"/>
				<updated>2008-01-15T12:33:34Z</updated>
		
		<summary type="html">&lt;p&gt;Stephendv: /* Status */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Status==&lt;br /&gt;
Released 14/1/2008&lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
&lt;br /&gt;
Injection attacks rely on the fact that interpreters take data and execute it as commands. If an attacker can modify the data that's sent to an interpreter, they may be able to make it misbehave. One way to help prevent this from happening is to encode the attacker's data in such a way that the interpreter will not get confused. [http://www.w3.org/TR/html401/sgml/entities.html HTML entity encoding] is just such an encoding mechanism for many interpreters.&lt;br /&gt;
&lt;br /&gt;
This is not a guarantee by the way. It's almost certain that someone, probably from the XML/Web Services world, will create an engine that performs HTML entity decoding automatically, thus reintroducing the injection threat.  However, for the time being, HTML entity encoding seems to work pretty well to prevent many types of injection.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Approach==&lt;br /&gt;
&lt;br /&gt;
We're going to implement a simple little method that encodes special characters. The nice .NET folks over at Microsoft had the foresight to build this into their platform, but the Java community seems to resist adding validation to the Java EE environment despite all the security issues that it could solve.  View layers such as Java Server Faces, Spring-MVC, WebWork and others automatically perform HTML encoding through custom tags.&lt;br /&gt;
&lt;br /&gt;
The best place for this method is in some kind of ValidationEngine, but since it's a good candidate for being static, it doesn't matter what class it ends up in that much.&lt;br /&gt;
&lt;br /&gt;
Note that this implementation doesn't produce the special characters like &amp;amp; lt; or &amp;amp; gt; - but it's not difficult to implement with a simple lookup table.&lt;br /&gt;
&lt;br /&gt;
    public static String HTMLEntityEncode( String s )&lt;br /&gt;
    {&lt;br /&gt;
        StringBuffer buf = new StringBuffer();&lt;br /&gt;
        int len = (s == null ? -1 : s.length());&lt;br /&gt;
 &lt;br /&gt;
        for ( int i = 0; i &amp;lt; len; i++ )&lt;br /&gt;
        {&lt;br /&gt;
            char c = s.charAt( i );&lt;br /&gt;
            if ( c&amp;gt;='a' &amp;amp;&amp;amp; c&amp;lt;='z' || c&amp;gt;='A' &amp;amp;&amp;amp; c&amp;lt;='Z' || c&amp;gt;='0' &amp;amp;&amp;amp; c&amp;lt;='9' )&lt;br /&gt;
            {&lt;br /&gt;
                buf.append( c );&lt;br /&gt;
            }&lt;br /&gt;
            else&lt;br /&gt;
            {&lt;br /&gt;
                buf.append( &amp;quot;&amp;amp;#&amp;quot; + (int)c + &amp;quot;;&amp;quot; );&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        return buf.toString();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
==Libraries==&lt;br /&gt;
* The Jakara Commons Lang package has a generic class for performing a wide range of [http://commons.apache.org/lang/api-release/org/apache/commons/lang/StringEscapeUtils.html String escaping functions]. &lt;br /&gt;
* jTidy includes an [http://jtidy.sourceforge.net/multiproject/jtidyservlet/apidocs/org/w3c/tidy/servlet/util/HTMLEncode.html HTMLEncode class] for performing HTML encoding.&lt;br /&gt;
&lt;br /&gt;
[[Category:How To]]&lt;br /&gt;
[[Category:OWASP Java Project]]&lt;br /&gt;
[[Category:OWASP Validation Project]]&lt;/div&gt;</summary>
		<author><name>Stephendv</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=How_to_perform_HTML_entity_encoding_in_Java&amp;diff=24495</id>
		<title>How to perform HTML entity encoding in Java</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=How_to_perform_HTML_entity_encoding_in_Java&amp;diff=24495"/>
				<updated>2008-01-15T12:33:15Z</updated>
		
		<summary type="html">&lt;p&gt;Stephendv: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Status==&lt;br /&gt;
Released 14/1/2008&lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
&lt;br /&gt;
Injection attacks rely on the fact that interpreters take data and execute it as commands. If an attacker can modify the data that's sent to an interpreter, they may be able to make it misbehave. One way to help prevent this from happening is to encode the attacker's data in such a way that the interpreter will not get confused. [http://www.w3.org/TR/html401/sgml/entities.html HTML entity encoding] is just such an encoding mechanism for many interpreters.&lt;br /&gt;
&lt;br /&gt;
This is not a guarantee by the way. It's almost certain that someone, probably from the XML/Web Services world, will create an engine that performs HTML entity decoding automatically, thus reintroducing the injection threat.  However, for the time being, HTML entity encoding seems to work pretty well to prevent many types of injection.&lt;br /&gt;
&lt;br /&gt;
==Status==&lt;br /&gt;
Released 14/1/2007&lt;br /&gt;
&lt;br /&gt;
==Approach==&lt;br /&gt;
&lt;br /&gt;
We're going to implement a simple little method that encodes special characters. The nice .NET folks over at Microsoft had the foresight to build this into their platform, but the Java community seems to resist adding validation to the Java EE environment despite all the security issues that it could solve.  View layers such as Java Server Faces, Spring-MVC, WebWork and others automatically perform HTML encoding through custom tags.&lt;br /&gt;
&lt;br /&gt;
The best place for this method is in some kind of ValidationEngine, but since it's a good candidate for being static, it doesn't matter what class it ends up in that much.&lt;br /&gt;
&lt;br /&gt;
Note that this implementation doesn't produce the special characters like &amp;amp; lt; or &amp;amp; gt; - but it's not difficult to implement with a simple lookup table.&lt;br /&gt;
&lt;br /&gt;
    public static String HTMLEntityEncode( String s )&lt;br /&gt;
    {&lt;br /&gt;
        StringBuffer buf = new StringBuffer();&lt;br /&gt;
        int len = (s == null ? -1 : s.length());&lt;br /&gt;
 &lt;br /&gt;
        for ( int i = 0; i &amp;lt; len; i++ )&lt;br /&gt;
        {&lt;br /&gt;
            char c = s.charAt( i );&lt;br /&gt;
            if ( c&amp;gt;='a' &amp;amp;&amp;amp; c&amp;lt;='z' || c&amp;gt;='A' &amp;amp;&amp;amp; c&amp;lt;='Z' || c&amp;gt;='0' &amp;amp;&amp;amp; c&amp;lt;='9' )&lt;br /&gt;
            {&lt;br /&gt;
                buf.append( c );&lt;br /&gt;
            }&lt;br /&gt;
            else&lt;br /&gt;
            {&lt;br /&gt;
                buf.append( &amp;quot;&amp;amp;#&amp;quot; + (int)c + &amp;quot;;&amp;quot; );&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        return buf.toString();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
==Libraries==&lt;br /&gt;
* The Jakara Commons Lang package has a generic class for performing a wide range of [http://commons.apache.org/lang/api-release/org/apache/commons/lang/StringEscapeUtils.html String escaping functions]. &lt;br /&gt;
* jTidy includes an [http://jtidy.sourceforge.net/multiproject/jtidyservlet/apidocs/org/w3c/tidy/servlet/util/HTMLEncode.html HTMLEncode class] for performing HTML encoding.&lt;br /&gt;
&lt;br /&gt;
[[Category:How To]]&lt;br /&gt;
[[Category:OWASP Java Project]]&lt;br /&gt;
[[Category:OWASP Validation Project]]&lt;/div&gt;</summary>
		<author><name>Stephendv</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=How_to_perform_HTML_entity_encoding_in_Java&amp;diff=24494</id>
		<title>How to perform HTML entity encoding in Java</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=How_to_perform_HTML_entity_encoding_in_Java&amp;diff=24494"/>
				<updated>2008-01-15T12:32:43Z</updated>
		
		<summary type="html">&lt;p&gt;Stephendv: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{GAnominee|2008-01-13}}&lt;br /&gt;
==Status==&lt;br /&gt;
Released 14/1/2008&lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
&lt;br /&gt;
Injection attacks rely on the fact that interpreters take data and execute it as commands. If an attacker can modify the data that's sent to an interpreter, they may be able to make it misbehave. One way to help prevent this from happening is to encode the attacker's data in such a way that the interpreter will not get confused. [http://www.w3.org/TR/html401/sgml/entities.html HTML entity encoding] is just such an encoding mechanism for many interpreters.&lt;br /&gt;
&lt;br /&gt;
This is not a guarantee by the way. It's almost certain that someone, probably from the XML/Web Services world, will create an engine that performs HTML entity decoding automatically, thus reintroducing the injection threat.  However, for the time being, HTML entity encoding seems to work pretty well to prevent many types of injection.&lt;br /&gt;
&lt;br /&gt;
==Status==&lt;br /&gt;
Released 14/1/2007&lt;br /&gt;
&lt;br /&gt;
==Approach==&lt;br /&gt;
&lt;br /&gt;
We're going to implement a simple little method that encodes special characters. The nice .NET folks over at Microsoft had the foresight to build this into their platform, but the Java community seems to resist adding validation to the Java EE environment despite all the security issues that it could solve.  View layers such as Java Server Faces, Spring-MVC, WebWork and others automatically perform HTML encoding through custom tags.&lt;br /&gt;
&lt;br /&gt;
The best place for this method is in some kind of ValidationEngine, but since it's a good candidate for being static, it doesn't matter what class it ends up in that much.&lt;br /&gt;
&lt;br /&gt;
Note that this implementation doesn't produce the special characters like &amp;amp; lt; or &amp;amp; gt; - but it's not difficult to implement with a simple lookup table.&lt;br /&gt;
&lt;br /&gt;
    public static String HTMLEntityEncode( String s )&lt;br /&gt;
    {&lt;br /&gt;
        StringBuffer buf = new StringBuffer();&lt;br /&gt;
        int len = (s == null ? -1 : s.length());&lt;br /&gt;
 &lt;br /&gt;
        for ( int i = 0; i &amp;lt; len; i++ )&lt;br /&gt;
        {&lt;br /&gt;
            char c = s.charAt( i );&lt;br /&gt;
            if ( c&amp;gt;='a' &amp;amp;&amp;amp; c&amp;lt;='z' || c&amp;gt;='A' &amp;amp;&amp;amp; c&amp;lt;='Z' || c&amp;gt;='0' &amp;amp;&amp;amp; c&amp;lt;='9' )&lt;br /&gt;
            {&lt;br /&gt;
                buf.append( c );&lt;br /&gt;
            }&lt;br /&gt;
            else&lt;br /&gt;
            {&lt;br /&gt;
                buf.append( &amp;quot;&amp;amp;#&amp;quot; + (int)c + &amp;quot;;&amp;quot; );&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        return buf.toString();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
==Libraries==&lt;br /&gt;
* The Jakara Commons Lang package has a generic class for performing a wide range of [http://commons.apache.org/lang/api-release/org/apache/commons/lang/StringEscapeUtils.html String escaping functions]. &lt;br /&gt;
* jTidy includes an [http://jtidy.sourceforge.net/multiproject/jtidyservlet/apidocs/org/w3c/tidy/servlet/util/HTMLEncode.html HTMLEncode class] for performing HTML encoding.&lt;br /&gt;
&lt;br /&gt;
[[Category:How To]]&lt;br /&gt;
[[Category:OWASP Java Project]]&lt;br /&gt;
[[Category:OWASP Validation Project]]&lt;/div&gt;</summary>
		<author><name>Stephendv</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=OWASP_Java_Table_of_Contents&amp;diff=24493</id>
		<title>OWASP Java Table of Contents</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=OWASP_Java_Table_of_Contents&amp;diff=24493"/>
				<updated>2008-01-15T10:59:08Z</updated>
		
		<summary type="html">&lt;p&gt;Stephendv: /* Noteworthy Frameworks */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;b&amp;gt;Key:&amp;lt;/b&amp;gt;&lt;br /&gt;
* xx%: Progress status of the paragraph&lt;br /&gt;
* &amp;lt;b&amp;gt;Review&amp;lt;/b&amp;gt;: The paragraph needs a review&lt;br /&gt;
* TD: Paragraph to be assigned&lt;br /&gt;
&lt;br /&gt;
==[[J2EE Security for Architects]]==&lt;br /&gt;
Discuss the security implications of common J2EE architectures.  This could be discussed in terms of: Authentication, Authorisation, Data Validation, Cross Site Scripting protection.  Other architecture concerns such as scalability, performance and maintainability can also be mentioned, but the focus on security should not be lost.&lt;br /&gt;
  &lt;br /&gt;
Any other security concerns that should be addressed during the design phase should also be mentioned here.&lt;br /&gt;
===Design considerations===&lt;br /&gt;
* Architectural considerations (0%, TD)&lt;br /&gt;
** EJB Middle tier (0%, TD)&lt;br /&gt;
** Web Services Middle tier (0%, TD)&lt;br /&gt;
** Spring Middle tier (0%, TD)&lt;br /&gt;
&lt;br /&gt;
==[[J2EE Security for Developers]]==&lt;br /&gt;
=== Noteworthy Frameworks ===&lt;br /&gt;
Discuss important and relevant Java security frameworks that would be useful to architects.  The information should be at a suitably high level, for example, by discussing the advantages and features as well as the associated costs (direct and indirect) of using the frameworks.&lt;br /&gt;
&lt;br /&gt;
(0%, Seeking Volunteers)&lt;br /&gt;
*	[[Struts]] (0% Jon Forck)&lt;br /&gt;
*	Turbine&lt;br /&gt;
*	[[Java Server Faces]] (Sam Reghenzi - 90%, Finalising content)&lt;br /&gt;
*	Tapestry&lt;br /&gt;
*	Webwork&lt;br /&gt;
*	Cocoon&lt;br /&gt;
*	Tiles&lt;br /&gt;
*	SiteMesh&lt;br /&gt;
*	Spring (0%, Adrian San Juan, TD)&lt;br /&gt;
&lt;br /&gt;
===[[Java Security Basics]]===&lt;br /&gt;
Provide an introduction into the basic security services provided by the Java language and environment.  Remember to keep this relevant for web developers for the initial release - there may be a potential to expand this to thick clients in subsequent releases.&lt;br /&gt;
* Class Loading (0%)&lt;br /&gt;
* Bytecode verifier (0%)&lt;br /&gt;
* The Security Manager and security.policy file (0%)&lt;br /&gt;
&lt;br /&gt;
===Input Validation Overview ===&lt;br /&gt;
Input validation is perhaps the most important category of application security. Any data entering a software system must be verified to contain safe data that is not mounting a SQL Injection, XSS, CSRF or other form of attack. This is done primarily through the use of regular expressions. It's crucial not to hard-code input validation routines. Regular expressions should contained within a configuration file that can easily updated by an InfoSec professional and not require a programmers intervention or deployment of new application code. Application security needs change over time as new attack vectors are discovered. Application administers need to be able to react to these changes as quickly as possible. &lt;br /&gt;
&lt;br /&gt;
===Input Validation ===&lt;br /&gt;
* Dangerous calls (BufferedReader.readLine(), ServletRequest.getParameter(), etc...) (0%, TD)&lt;br /&gt;
* [[How to add validation logic to HttpServletRequest]] (100%, Jeff Williams, Complete)&lt;br /&gt;
* [[How to perform HTML entity encoding in Java]] (100%, Jeff Williams, Complete)&lt;br /&gt;
&lt;br /&gt;
==== [[Preventing SQL Injection in Java]] ====&lt;br /&gt;
* Overview &lt;br /&gt;
* Prevention (60%, Stephen de Vries, &amp;lt;b&amp;gt;Review&amp;lt;/b&amp;gt;)&lt;br /&gt;
** White Listing&lt;br /&gt;
** Prepared Statements&lt;br /&gt;
** Stored Procedures &lt;br /&gt;
** Hibernate &lt;br /&gt;
** Ibatis (60%, Rohyt Belani, &amp;lt;b&amp;gt;Review&amp;lt;/b&amp;gt;)&lt;br /&gt;
** Spring JDBC &lt;br /&gt;
** EJB 3.0&lt;br /&gt;
** JDO&lt;br /&gt;
&lt;br /&gt;
==== [[Preventing LDAP Injection in Java]] ====&lt;br /&gt;
* Overview (100%, Stephen de Vries, Complete)&lt;br /&gt;
* Prevention (100%, Stephen de Vries, Complete)&lt;br /&gt;
&lt;br /&gt;
==== [[XPATH Injection]] ====&lt;br /&gt;
As with the other Injection sections, only provide cursory information on the general case. Should contain practical real-world advise and code examples for preventing XPATH injection.&lt;br /&gt;
* Overview (0%, TD)&lt;br /&gt;
* Prevention (0%, TD)&lt;br /&gt;
&lt;br /&gt;
==== Miscellaneous Injection Attacks  ====&lt;br /&gt;
* HTTP Response splitting (0%, TD)&lt;br /&gt;
* Command injection - Runtime.getRuntime().exec() (0%, TD)&lt;br /&gt;
&lt;br /&gt;
''' Status '''&lt;br /&gt;
In progress&lt;br /&gt;
&lt;br /&gt;
=== Authentication===&lt;br /&gt;
* [[Storing credentials]] - (20%, Adrian San Juan, &amp;lt;b&amp;gt;Review&amp;lt;/b&amp;gt;)&lt;br /&gt;
* [[Hashing Java|Hashing]] - (100%, Michel Prunet, &amp;lt;b&amp;gt;Review&amp;lt;/b&amp;gt;)&lt;br /&gt;
* [[SSL Best Practices]] - (20%, Philippe Curmin, &amp;lt;b&amp;gt;Review&amp;lt;/b&amp;gt;)&lt;br /&gt;
* [[Using JCaptcha]] - (100%, Dave Ferguson, &amp;lt;b&amp;gt;Review&amp;lt;/b&amp;gt;) &lt;br /&gt;
* Container-managed authentication with Realms&lt;br /&gt;
** [[Declarative Access Control in Java]] - (100%, Dave Ferguson, Completed)&lt;br /&gt;
* [[JAAS Timed Login Module]] - (100%, Stephen de Vries, &amp;lt;b&amp;gt;Review&amp;lt;/b&amp;gt;)&lt;br /&gt;
* [[JAAS Tomcat Login Module]] - (100%, Stephen de Vries, &amp;lt;b&amp;gt;Review&amp;lt;/b&amp;gt;)&lt;br /&gt;
* [[Password length &amp;amp; complexity]] - (100%, Adrian San Juan, &amp;lt;b&amp;gt;Review&amp;lt;/b&amp;gt;)&lt;br /&gt;
&lt;br /&gt;
===Session Management ===&lt;br /&gt;
The generic problems and solutions for session management are covered in the Guide.  This section should focus on Java specific examples.&lt;br /&gt;
* Logout (0%, TD)&lt;br /&gt;
* Session Timeout (0%, TD)&lt;br /&gt;
* Absolute Timeout (0%, TD)&lt;br /&gt;
* [[Session Fixation in Java]] (100%, Rohyt Belani, &amp;lt;b&amp;gt;Review&amp;lt;/b&amp;gt;)&lt;br /&gt;
* Terminating sessions (0%, TD)&lt;br /&gt;
** Terminating sessions when the browser window is closed&lt;br /&gt;
&lt;br /&gt;
===Authorization===&lt;br /&gt;
* [[Declarative v/s Programmatic]] (10%, TD)&lt;br /&gt;
* EJB Authorization (0%, TD)&lt;br /&gt;
* Acegi (0%, TD)&lt;br /&gt;
* JACC (0%, TD)&lt;br /&gt;
* Check horizontal privilege (0%, TD)&lt;br /&gt;
&lt;br /&gt;
=== Encryption===&lt;br /&gt;
* [http://www.owasp.org/index.php/Using_the_Java_Cryptographic_Extensions JCE] (100%, Joe Prasanna Kumar - To be reviewed)&lt;br /&gt;
* Storing db secrets (0%, TD)&lt;br /&gt;
* Encrypting JDBC connections (0%, TD)&lt;br /&gt;
* [http://www.owasp.org/index.php/Using_the_Java_Secure_Socket_Extensions JSSE] (100%, Joe Prasanna Kumar - To be reviewed)&lt;br /&gt;
* [http://www.owasp.org/index.php/Digital_Signature_Implementation_in_Java Digital Signatures in Java (100%, Joe Prasanna Kumar - To be reviewed)&lt;br /&gt;
&lt;br /&gt;
=== Error Handling &amp;amp; Logging===&lt;br /&gt;
* Logging - why log? what to log? log4j, etc. (0%, TD)&lt;br /&gt;
* Exception handling techniques (0%, TD)&lt;br /&gt;
** fail-open/fail-closed&lt;br /&gt;
** resource cleanup&lt;br /&gt;
** finally block&lt;br /&gt;
** swallowing exceptions&lt;br /&gt;
* Exception handling frameworks (50%, TD)&lt;br /&gt;
** Servlet spec - web.xml [[Securing tomcat]] (100%, Darren Edmonds, Completed)&lt;br /&gt;
** JSP errorPage (0%, TD)&lt;br /&gt;
* Web application forensics (0%, TD)&lt;br /&gt;
&lt;br /&gt;
=== Web Services Security ===&lt;br /&gt;
* SAML (0%, TD)&lt;br /&gt;
* (X)WS-Security (0%, TD)&lt;br /&gt;
* SunJWSDP (0%, TD)&lt;br /&gt;
* WSS4J (0%, Eelco Klaver)&lt;br /&gt;
* XML Signature (JSR 105) (0%, TD)&lt;br /&gt;
* XML Encryption (JSR 106) (0%, TD)&lt;br /&gt;
&lt;br /&gt;
=== Code Analysis Tools ===&lt;br /&gt;
The introduction should cover the advantages and short comings of code analysis tools.  An overview of the current state of the art and the available tools would go well here.  As a start, only open source tools are listed, but if vendors of commercial tools adhere to the [[Tutorial]] guidelines, these submissions will be gladly received.&lt;br /&gt;
* Introduction (0%, TD)&lt;br /&gt;
* [[:Category:OWASP LAPSE Project]] (100%, &amp;lt;b&amp;gt;Review&amp;lt;/b&amp;gt;)&lt;br /&gt;
* FindBugs (0%, TD)&lt;br /&gt;
** Creating custom rules&lt;br /&gt;
* PMD (0%, TD)&lt;br /&gt;
** Creating custom rules&lt;br /&gt;
* JLint (0%, TD)&lt;br /&gt;
* Jmetrics (0%, TD)&lt;br /&gt;
&lt;br /&gt;
== [[J2EE Security For Deployers]] ==&lt;br /&gt;
Practical step-by-step guides to securing various J2EE servers.  Examples of secure configurations can also be provided for download.  If configurations are provided, they should be properly commented so that the rationale for configuration settings is clearly explained.  Users of the configurations should be provided with enough information to make their own risk decisions.&lt;br /&gt;
=== Securing Popular J2EE Servers ===&lt;br /&gt;
* [[Securing tomcat|Securing Tomcat]] - (100%, Darren Edmonds, Completed)&lt;br /&gt;
* Securing JBoss (0%, TD)&lt;br /&gt;
* Securing WebLogic (0%, TD)&lt;br /&gt;
* Securing WebSphere (0%, TD)&lt;br /&gt;
* Others...&lt;br /&gt;
&lt;br /&gt;
=== Defining a Java Security Policy ===&lt;br /&gt;
Practical information on creating a Java security policies for J2EE servers.&lt;br /&gt;
* PolicyTool - JChains already provides this functionality, one policy tool is enough.&lt;br /&gt;
* jChains (www.jchains.org) - (0%, TD)&lt;br /&gt;
&lt;br /&gt;
=== Protecting Binaries ===&lt;br /&gt;
* Bytecode manipulation tools and techniques (0%, TD)&lt;br /&gt;
* [[Bytecode obfuscation]] (100%, Pierre Parrend, Released)&lt;br /&gt;
* Convert bytecode to native machine code (0%, TD)&lt;br /&gt;
* [[Protecting code archives with digital signatures]] (100%, Pierre Parrend, Released)&lt;br /&gt;
* [[Signing jar files with jarsigner]] (100%, Pierre Parrend, Released)&lt;br /&gt;
&lt;br /&gt;
==[[J2EE Security for Security Analysts and Testers]]==&lt;br /&gt;
* Using Eclipse to verify Java applications (0%, TD)&lt;br /&gt;
* Using [[:Category:OWASP WebScarab Project|WebScarab]] to find vulnerabilities in J2EE applications - (0%, TD)&lt;br /&gt;
* Decompiling Java bytecode (0%, TD)&lt;br /&gt;
&lt;br /&gt;
== [[Java Security Resources]] (ongoing)==&lt;br /&gt;
&lt;br /&gt;
[[Category:OWASP Java Project]]&lt;/div&gt;</summary>
		<author><name>Stephendv</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=OWASP_Java_Table_of_Contents&amp;diff=24453</id>
		<title>OWASP Java Table of Contents</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=OWASP_Java_Table_of_Contents&amp;diff=24453"/>
				<updated>2008-01-14T17:25:25Z</updated>
		
		<summary type="html">&lt;p&gt;Stephendv: /* Protecting Binaries */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;b&amp;gt;Key:&amp;lt;/b&amp;gt;&lt;br /&gt;
* xx%: Progress status of the paragraph&lt;br /&gt;
* &amp;lt;b&amp;gt;Review&amp;lt;/b&amp;gt;: The paragraph needs a review&lt;br /&gt;
* TD: Paragraph to be assigned&lt;br /&gt;
&lt;br /&gt;
==[[J2EE Security for Architects]]==&lt;br /&gt;
Discuss the security implications of common J2EE architectures.  This could be discussed in terms of: Authentication, Authorisation, Data Validation, Cross Site Scripting protection.  Other architecture concerns such as scalability, performance and maintainability can also be mentioned, but the focus on security should not be lost.&lt;br /&gt;
  &lt;br /&gt;
Any other security concerns that should be addressed during the design phase should also be mentioned here.&lt;br /&gt;
===Design considerations===&lt;br /&gt;
* Architectural considerations (0%, TD)&lt;br /&gt;
** EJB Middle tier (0%, TD)&lt;br /&gt;
** Web Services Middle tier (0%, TD)&lt;br /&gt;
** Spring Middle tier (0%, TD)&lt;br /&gt;
&lt;br /&gt;
==[[J2EE Security for Developers]]==&lt;br /&gt;
=== Noteworthy Frameworks ===&lt;br /&gt;
Discuss important and relevant Java security frameworks that would be useful to architects.  The information should be at a suitably high level, for example, by discussing the advantages and features as well as the associated costs (direct and indirect) of using the frameworks.&lt;br /&gt;
&lt;br /&gt;
(0%, Seeking Volunteers)&lt;br /&gt;
*	[[Struts]] (0% Needs a new owner)&lt;br /&gt;
*	Turbine&lt;br /&gt;
*	[[Java Server Faces]] (Sam Reghenzi - 90%, Finalising content)&lt;br /&gt;
*	Tapestry&lt;br /&gt;
*	Webwork&lt;br /&gt;
*	Cocoon&lt;br /&gt;
*	Tiles&lt;br /&gt;
*	SiteMesh&lt;br /&gt;
*	Spring (0%, Adrian San Juan, TD)&lt;br /&gt;
&lt;br /&gt;
===[[Java Security Basics]]===&lt;br /&gt;
Provide an introduction into the basic security services provided by the Java language and environment.  Remember to keep this relevant for web developers for the initial release - there may be a potential to expand this to thick clients in subsequent releases.&lt;br /&gt;
* Class Loading (0%)&lt;br /&gt;
* Bytecode verifier (0%)&lt;br /&gt;
* The Security Manager and security.policy file (0%)&lt;br /&gt;
&lt;br /&gt;
===Input Validation Overview ===&lt;br /&gt;
Input validation is perhaps the most important category of application security. Any data entering a software system must be verified to contain safe data that is not mounting a SQL Injection, XSS, CSRF or other form of attack. This is done primarily through the use of regular expressions. It's crucial not to hard-code input validation routines. Regular expressions should contained within a configuration file that can easily updated by an InfoSec professional and not require a programmers intervention or deployment of new application code. Application security needs change over time as new attack vectors are discovered. Application administers need to be able to react to these changes as quickly as possible. &lt;br /&gt;
&lt;br /&gt;
===Input Validation ===&lt;br /&gt;
* Dangerous calls (BufferedReader.readLine(), ServletRequest.getParameter(), etc...) (0%, TD)&lt;br /&gt;
* [[How to add validation logic to HttpServletRequest]] (100%, Jeff Williams, Complete)&lt;br /&gt;
* [[How to perform HTML entity encoding in Java]] (100%, Jeff Williams, Complete)&lt;br /&gt;
&lt;br /&gt;
==== [[Preventing SQL Injection in Java]] ====&lt;br /&gt;
* Overview &lt;br /&gt;
* Prevention (60%, Stephen de Vries, &amp;lt;b&amp;gt;Review&amp;lt;/b&amp;gt;)&lt;br /&gt;
** White Listing&lt;br /&gt;
** Prepared Statements&lt;br /&gt;
** Stored Procedures &lt;br /&gt;
** Hibernate &lt;br /&gt;
** Ibatis (60%, Rohyt Belani, &amp;lt;b&amp;gt;Review&amp;lt;/b&amp;gt;)&lt;br /&gt;
** Spring JDBC &lt;br /&gt;
** EJB 3.0&lt;br /&gt;
** JDO&lt;br /&gt;
&lt;br /&gt;
==== [[Preventing LDAP Injection in Java]] ====&lt;br /&gt;
* Overview (100%, Stephen de Vries, Complete)&lt;br /&gt;
* Prevention (100%, Stephen de Vries, Complete)&lt;br /&gt;
&lt;br /&gt;
==== [[XPATH Injection]] ====&lt;br /&gt;
As with the other Injection sections, only provide cursory information on the general case. Should contain practical real-world advise and code examples for preventing XPATH injection.&lt;br /&gt;
* Overview (0%, TD)&lt;br /&gt;
* Prevention (0%, TD)&lt;br /&gt;
&lt;br /&gt;
==== Miscellaneous Injection Attacks  ====&lt;br /&gt;
* HTTP Response splitting (0%, TD)&lt;br /&gt;
* Command injection - Runtime.getRuntime().exec() (0%, TD)&lt;br /&gt;
&lt;br /&gt;
''' Status '''&lt;br /&gt;
In progress&lt;br /&gt;
&lt;br /&gt;
=== Authentication===&lt;br /&gt;
* [[Storing credentials]] - (20%, Adrian San Juan, &amp;lt;b&amp;gt;Review&amp;lt;/b&amp;gt;)&lt;br /&gt;
* [[Hashing Java|Hashing]] - (100%, Michel Prunet, &amp;lt;b&amp;gt;Review&amp;lt;/b&amp;gt;)&lt;br /&gt;
* [[SSL Best Practices]] - (20%, Philippe Curmin, &amp;lt;b&amp;gt;Review&amp;lt;/b&amp;gt;)&lt;br /&gt;
* [[Using JCaptcha]] - (100%, Dave Ferguson, &amp;lt;b&amp;gt;Review&amp;lt;/b&amp;gt;) &lt;br /&gt;
* Container-managed authentication with Realms&lt;br /&gt;
** [[Declarative Access Control in Java]] - (100%, Dave Ferguson, Completed)&lt;br /&gt;
* [[JAAS Timed Login Module]] - (100%, Stephen de Vries, &amp;lt;b&amp;gt;Review&amp;lt;/b&amp;gt;)&lt;br /&gt;
* [[JAAS Tomcat Login Module]] - (100%, Stephen de Vries, &amp;lt;b&amp;gt;Review&amp;lt;/b&amp;gt;)&lt;br /&gt;
* [[Password length &amp;amp; complexity]] - (100%, Adrian San Juan, &amp;lt;b&amp;gt;Review&amp;lt;/b&amp;gt;)&lt;br /&gt;
&lt;br /&gt;
===Session Management ===&lt;br /&gt;
The generic problems and solutions for session management are covered in the Guide.  This section should focus on Java specific examples.&lt;br /&gt;
* Logout (0%, TD)&lt;br /&gt;
* Session Timeout (0%, TD)&lt;br /&gt;
* Absolute Timeout (0%, TD)&lt;br /&gt;
* [[Session Fixation in Java]] (100%, Rohyt Belani, &amp;lt;b&amp;gt;Review&amp;lt;/b&amp;gt;)&lt;br /&gt;
* Terminating sessions (0%, TD)&lt;br /&gt;
** Terminating sessions when the browser window is closed&lt;br /&gt;
&lt;br /&gt;
===Authorization===&lt;br /&gt;
* [[Declarative v/s Programmatic]] (10%, TD)&lt;br /&gt;
* EJB Authorization (0%, TD)&lt;br /&gt;
* Acegi (0%, TD)&lt;br /&gt;
* JACC (0%, TD)&lt;br /&gt;
* Check horizontal privilege (0%, TD)&lt;br /&gt;
&lt;br /&gt;
=== Encryption===&lt;br /&gt;
* [http://www.owasp.org/index.php/Using_the_Java_Cryptographic_Extensions JCE] (100%, Joe Prasanna Kumar - To be reviewed)&lt;br /&gt;
* Storing db secrets (0%, TD)&lt;br /&gt;
* Encrypting JDBC connections (0%, TD)&lt;br /&gt;
* [http://www.owasp.org/index.php/Using_the_Java_Secure_Socket_Extensions JSSE] (100%, Joe Prasanna Kumar - To be reviewed)&lt;br /&gt;
* [http://www.owasp.org/index.php/Digital_Signature_Implementation_in_Java Digital Signatures in Java (100%, Joe Prasanna Kumar - To be reviewed)&lt;br /&gt;
&lt;br /&gt;
=== Error Handling &amp;amp; Logging===&lt;br /&gt;
* Logging - why log? what to log? log4j, etc. (0%, TD)&lt;br /&gt;
* Exception handling techniques (0%, TD)&lt;br /&gt;
** fail-open/fail-closed&lt;br /&gt;
** resource cleanup&lt;br /&gt;
** finally block&lt;br /&gt;
** swallowing exceptions&lt;br /&gt;
* Exception handling frameworks (50%, TD)&lt;br /&gt;
** Servlet spec - web.xml [[Securing tomcat]] (100%, Darren Edmonds, Completed)&lt;br /&gt;
** JSP errorPage (0%, TD)&lt;br /&gt;
* Web application forensics (0%, TD)&lt;br /&gt;
&lt;br /&gt;
=== Web Services Security ===&lt;br /&gt;
* SAML (0%, TD)&lt;br /&gt;
* (X)WS-Security (0%, TD)&lt;br /&gt;
* SunJWSDP (0%, TD)&lt;br /&gt;
* WSS4J (0%, Eelco Klaver)&lt;br /&gt;
* XML Signature (JSR 105) (0%, TD)&lt;br /&gt;
* XML Encryption (JSR 106) (0%, TD)&lt;br /&gt;
&lt;br /&gt;
=== Code Analysis Tools ===&lt;br /&gt;
The introduction should cover the advantages and short comings of code analysis tools.  An overview of the current state of the art and the available tools would go well here.  As a start, only open source tools are listed, but if vendors of commercial tools adhere to the [[Tutorial]] guidelines, these submissions will be gladly received.&lt;br /&gt;
* Introduction (0%, TD)&lt;br /&gt;
* [[:Category:OWASP LAPSE Project]] (100%, &amp;lt;b&amp;gt;Review&amp;lt;/b&amp;gt;)&lt;br /&gt;
* FindBugs (0%, TD)&lt;br /&gt;
** Creating custom rules&lt;br /&gt;
* PMD (0%, TD)&lt;br /&gt;
** Creating custom rules&lt;br /&gt;
* JLint (0%, TD)&lt;br /&gt;
* Jmetrics (0%, TD)&lt;br /&gt;
&lt;br /&gt;
== [[J2EE Security For Deployers]] ==&lt;br /&gt;
Practical step-by-step guides to securing various J2EE servers.  Examples of secure configurations can also be provided for download.  If configurations are provided, they should be properly commented so that the rationale for configuration settings is clearly explained.  Users of the configurations should be provided with enough information to make their own risk decisions.&lt;br /&gt;
=== Securing Popular J2EE Servers ===&lt;br /&gt;
* [[Securing tomcat|Securing Tomcat]] - (100%, Darren Edmonds, Completed)&lt;br /&gt;
* Securing JBoss (0%, TD)&lt;br /&gt;
* Securing WebLogic (0%, TD)&lt;br /&gt;
* Securing WebSphere (0%, TD)&lt;br /&gt;
* Others...&lt;br /&gt;
&lt;br /&gt;
=== Defining a Java Security Policy ===&lt;br /&gt;
Practical information on creating a Java security policies for J2EE servers.&lt;br /&gt;
* PolicyTool - JChains already provides this functionality, one policy tool is enough.&lt;br /&gt;
* jChains (www.jchains.org) - (0%, TD)&lt;br /&gt;
&lt;br /&gt;
=== Protecting Binaries ===&lt;br /&gt;
* Bytecode manipulation tools and techniques (0%, TD)&lt;br /&gt;
* [[Bytecode obfuscation]] (100%, Pierre Parrend, Released)&lt;br /&gt;
* Convert bytecode to native machine code (0%, TD)&lt;br /&gt;
* [[Protecting code archives with digital signatures]] (100%, Pierre Parrend, Released)&lt;br /&gt;
* [[Signing jar files with jarsigner]] (100%, Pierre Parrend, Released)&lt;br /&gt;
&lt;br /&gt;
==[[J2EE Security for Security Analysts and Testers]]==&lt;br /&gt;
* Using Eclipse to verify Java applications (0%, TD)&lt;br /&gt;
* Using [[:Category:OWASP WebScarab Project|WebScarab]] to find vulnerabilities in J2EE applications - (0%, TD)&lt;br /&gt;
* Decompiling Java bytecode (0%, TD)&lt;br /&gt;
&lt;br /&gt;
== [[Java Security Resources]] (ongoing)==&lt;br /&gt;
&lt;br /&gt;
[[Category:OWASP Java Project]]&lt;/div&gt;</summary>
		<author><name>Stephendv</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Struts&amp;diff=24452</id>
		<title>Struts</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Struts&amp;diff=24452"/>
				<updated>2008-01-14T17:11:47Z</updated>
		
		<summary type="html">&lt;p&gt;Stephendv: /* Author */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Status==&lt;br /&gt;
'''Content to be finalised.  First draft'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Introduction ==&lt;br /&gt;
This article describes the web security implications for the Struts MVC framework, how Struts helps in securing your web applications and where special attention is needed. It will not describe the internal details of Struts.&lt;br /&gt;
&lt;br /&gt;
==Architecture==&lt;br /&gt;
The framework provides its own web Controller  component. This Controller acts as a bridge between the application's Model and the web View. When a request is received, the Controller invokes an Action class. The Action class interacts with the Model to examine or update the application's state. The framework provides an ActionForm class to help transfer data between Model and View.&lt;br /&gt;
&lt;br /&gt;
==Components==&lt;br /&gt;
===Action===&lt;br /&gt;
* No distinction is made between HTTP GET and POST method. Both methods are mapped to the same Action execute method.&lt;br /&gt;
&lt;br /&gt;
===ActionForm===&lt;br /&gt;
&lt;br /&gt;
===Validation===&lt;br /&gt;
* Integration with commons validator&lt;br /&gt;
&lt;br /&gt;
==Configuration==&lt;br /&gt;
&lt;br /&gt;
==Security==&lt;br /&gt;
===Roles===&lt;br /&gt;
In the struts-config.xml configuration file it is possible to specify a roles attribute, a comma-delimited list of security role names that are allowed access to the ActionMapping object.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;action&lt;br /&gt;
     roles=&amp;quot;administrator,contributor&amp;quot;&lt;br /&gt;
     path=&amp;quot;/article/Edit&amp;quot;&lt;br /&gt;
     parameter=&amp;quot;org.article.FindByArticle&amp;quot;&lt;br /&gt;
     name=&amp;quot;articleForm&amp;quot;  &lt;br /&gt;
     scope=&amp;quot;request&amp;quot;&amp;gt;&lt;br /&gt;
       &amp;lt;forward&lt;br /&gt;
             name=&amp;quot;success&amp;quot;&lt;br /&gt;
             path=&amp;quot;article.jsp&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/action&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
[[Category:OWASP Java Project]]&lt;/div&gt;</summary>
		<author><name>Stephendv</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Using_the_Java_Secure_Socket_Extensions&amp;diff=24451</id>
		<title>Using the Java Secure Socket Extensions</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Using_the_Java_Secure_Socket_Extensions&amp;diff=24451"/>
				<updated>2008-01-14T17:11:08Z</updated>
		
		<summary type="html">&lt;p&gt;Stephendv: /* Note */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Status==&lt;br /&gt;
Requires review&lt;br /&gt;
&lt;br /&gt;
''The code included in this article has not been reviewed and should not be used without proper analysis. If you have reviewed the included code (or portions of it), please post your findings back to this page or to: stephen [at] corsaire.com.''&lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
&lt;br /&gt;
===What is SSL ?=== &lt;br /&gt;
SSL - Secure Socket Layer is an Application layer cryptographic protocol developed by Netscape for securing communication over the Internet.&lt;br /&gt;
The security services provided by SSL are&lt;br /&gt;
# Confidentiality through Encryption of data using Symmetric Key Encryption Algorithms&lt;br /&gt;
# Non - Repudiation of Origin / Origin Integrity through Digital Signatures using Asymmetric key Encryption Algorithms or Public Key Cryptographic Algorithms&lt;br /&gt;
# Data Integrity through Hashing using Message Digest or Hashing Algorithms&lt;br /&gt;
&lt;br /&gt;
===What is JSSE ?===&lt;br /&gt;
JSSE is the acronym of Jave Secure Socket Extensions. As the name implies it is a set of Java API's which provides SSL / TLS functionalities. &lt;br /&gt;
JSSE follows a Provider Architecture wherein the functionalities specified in the Service Provider Interface can be implemented by any Service Provider. JSSE comes bundled with a default service provider named SunJSSE. JSSE was an optional package on jdk ##x and ##x. Since jdk ##x, JSSE comes pre-configured with the standard jdk package&lt;br /&gt;
&lt;br /&gt;
===The JSSE  Implementation of SSL===&lt;br /&gt;
JSSE provides an implementation for creating SSLSocket (used by clients) and SSLServerSocket (used by server).&lt;br /&gt;
====Algorithm for creating SSL Client socket====&lt;br /&gt;
# Determine the SSL Server Name and port in which the SSL server is listening&lt;br /&gt;
# Register the JSSE provider&lt;br /&gt;
# Create an instance of SSLSocketFactory&lt;br /&gt;
# Create an instance of SSLSocket&lt;br /&gt;
# Create an OutputStream object to write to the SSL Server&lt;br /&gt;
# Create an InputStream object to receive messages back from the SSL Server&lt;br /&gt;
&lt;br /&gt;
====Algorithm for creating SSL Server socket====&lt;br /&gt;
# Register the JSSE provider&lt;br /&gt;
# Set System property for keystore by specifying the keystore which contains the server certificate&lt;br /&gt;
# Set System property for the password of the keystore which contains the server certificate&lt;br /&gt;
# Create an instance of SSLServerSocketFactory&lt;br /&gt;
# Create an instance of SSLServerSocket by specifying the port to which the SSL Server socket needs to bind with&lt;br /&gt;
# Initialize an object of SSLSocket&lt;br /&gt;
# Create InputStream object to read data sent by clients&lt;br /&gt;
# Create an OutputStream object to write data back to clients.&lt;br /&gt;
&lt;br /&gt;
===SSL Handshake Protocol===&lt;br /&gt;
The SSL handshake protocol happens between the client and the server and comprises of 4 rounds that enable peers to agree on keys, ciphers and MAC algorithms. The handshake is explained below with the parameters captured in the debug mode during the execution of SSLClient and SSLServer java files.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Round 1 : Create the SSL connection between the Client and the Server====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
	C -&amp;gt; S {ver || randomcookie1 || sessionid || Cipher Suites || Compression Methods }&lt;br /&gt;
*** ClientHello, TLSv1&lt;br /&gt;
RandomCookie:  GMT: 1165141617 bytes = { 250, 20, 142, 231, 143, 78, 72, 52, 254, 46, 199, 39, 146, 23, 238, 5, 108, 171, 75, 192, 78, 173, 26, 151, 89, 86, 58, 197 }&lt;br /&gt;
Session ID:  {}&lt;br /&gt;
Cipher Suites: [SSL_RSA_WITH_RC4_128_MD5, SSL_RSA_WITH_RC4_128_SHA, TLS_RSA_WITH_AES_128_CBC_SHA, TLS_DHE_RSA_WITH_AES_128_CBC_SHA, TLS_DHE_DSS_WITH_AES_128_CBC_SHA, SSL_RSA_WITH_3DES_EDE_CBC_SHA, SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA, SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA, SSL_RSA_WITH_DES_CBC_SHA, SSL_DHE_RSA_WITH_DES_CBC_SHA, SSL_DHE_DSS_WITH_DES_CBC_SHA, SSL_RSA_EXPORT_WITH_RC4_40_MD5, SSL_RSA_EXPORT_WITH_DES40_CBC_SHA, SSL_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA, SSL_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA]&lt;br /&gt;
Compression Methods:  { 0 }&lt;br /&gt;
	S -&amp;gt; C {ver || randomcookie2 || session_id || cipher || compression }&lt;br /&gt;
*** ServerHello, TLSv1&lt;br /&gt;
RandomCookie:  GMT: 1165141617 bytes = { 33, 91, 78, 189, 156, 183, 142, 253, 119, 155, 22, 193, 46, 0, 50, 153, 168, 170, 19, 220, 68, 97, 98, 3, 36, 228, 103, 117 }&lt;br /&gt;
Session ID:  {69, 115, 166, 113, 102, 3, 65, 68, 227, 239, 225, 34, 115, 49, 73, 69, 174, 111, 222, 219, 119, 162, 5, 11, 77, 149, 181, 24, 38, 98, 5, 204}&lt;br /&gt;
Cipher Suite: SSL_RSA_WITH_RC4_128_MD5&lt;br /&gt;
Compression Method: 0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
====Round 2 : Server authenticates itself====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
	S -&amp;gt; C {server_cert}&lt;br /&gt;
***&lt;br /&gt;
%% Created:  [Session-1, SSL_RSA_WITH_RC4_128_MD5]&lt;br /&gt;
** SSL_RSA_WITH_RC4_128_MD5&lt;br /&gt;
[read] MD5 and SHA1 hashes:  len = 74&lt;br /&gt;
0000: 02 00 00 46 03 01 45 73   A6 71 21 5B 4E BD 9C B7  ...F..Es.q![N...&lt;br /&gt;
0010: 8E FD 77 9B 16 C1 2E 00   32 99 A8 AA 13 DC 44 61  ..w.....#....Da&lt;br /&gt;
0020: 62 03 24 E4 67 75 20 45   73 A6 71 66 03 41 44 E3  b.$.gu Es.qf.AD.&lt;br /&gt;
0030: EF E1 22 73 31 49 45 AE   6F DE DB 77 A2 05 0B 4D  ..&amp;quot;s1IE.o..w...M&lt;br /&gt;
0040: 95 B5 18 26 62 05 CC 00   04 00                    ...&amp;amp;b.....&lt;br /&gt;
&lt;br /&gt;
	S -&amp;gt; C {public key modulus || exponent || {hash (randomcookie1 || randomcookie2 || public key modulus || exponent )} signed by Server}&lt;br /&gt;
*** Certificate chain&lt;br /&gt;
chain [0] = [&lt;br /&gt;
[&lt;br /&gt;
  Version: V1&lt;br /&gt;
  Subject: CN=Jane P, OU=Network Admins, O=NewCo, L=Denver, ST=CO, C=US&lt;br /&gt;
  Signature Algorithm: MD5withRSA, OID = ######4&lt;br /&gt;
&lt;br /&gt;
  Key:  Sun RSA public key, 1024 bits&lt;br /&gt;
  modulus: 125799608853960565468693082080524019040787802862173204033354805928537584240351554241990082493719007271501637788649255493925650447292814949263542483518710211756489915623917992726468465059340034326131973495929283930754477403752766287367308326998219377123365800989254595407827915805528431637337980240073881550879&lt;br /&gt;
  public exponent: 65537&lt;br /&gt;
  Validity: [From: Sun Nov 26 06:33:42 EST 2006,&lt;br /&gt;
               To: Wed Apr 12 07:33:42 EDT 2034]&lt;br /&gt;
  Issuer: CN=Jane P, OU=Network Admins, O=NewCo, L=Denver, ST=CO, C=US&lt;br /&gt;
  SerialNumber: [    45697b96]&lt;br /&gt;
&lt;br /&gt;
]&lt;br /&gt;
  Algorithm: [MD5withRSA]&lt;br /&gt;
  Signature:&lt;br /&gt;
0000: 1A 35 AD 99 24 0A 8C 09   58 0C FC B4 B3 F8 3F DC  .#.$...X.....?.&lt;br /&gt;
0010: 44 BF 56 A2 3A 5D E5 DF   0D CF D2 59 51 F2 6E 1C  D.V.:].....YQ.n.&lt;br /&gt;
0020: 2A C0 03 9B 7C 3F 8B 53   C8 E9 16 A7 BC 28 23 C1  *....?.S.....(#.&lt;br /&gt;
0030: 67 F3 E4 05 D9 55 13 65   2E E3 80 BA A3 0A 9C F6  g....U.e........&lt;br /&gt;
0040: A1 50 46 90 D7 E0 8F 50   6C E4 00 5D 3F F8 D0 62  .PF....Pl..]?..b&lt;br /&gt;
0050: D2 A9 47 DF 65 3B 02 E8   1C 04 8A 3C 7B 19 B3 EB  ..G.e;.....&amp;lt;....&lt;br /&gt;
0060: B6 50 23 6E C6 8A 49 95   6E 38 70 D2 2B 40 31 A5  .P#n..I.n8p.+@#&lt;br /&gt;
0070: FE 3F 44 EF 3A E4 12 69   46 D1 4F A0 83 40 F7 F3  .?D.:..iF.O..@..&lt;br /&gt;
]&lt;br /&gt;
***&lt;br /&gt;
	S -&amp;gt; C { cert_type || good_cert_authorities}&lt;br /&gt;
	S -&amp;gt; C {end_round_2}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
====Round 3 : Client validates the Server certificate====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
	C -&amp;gt; S {client_cert}&lt;br /&gt;
	C -&amp;gt; S {pre master secret} &lt;br /&gt;
*** ClientKeyExchange, RSA PreMasterSecret, TLSv1&lt;br /&gt;
Random Secret:  { 3, 1, 161, 37, 5, 17, 154, 202, 73, 33, 75, 50, 61, 242, 44, 252, 232, 80, 161, 185, 2, 61, 154, 54, 177, 192, 141, 235, 95, 174, 219, 216, 251, 150, 189, 99, 188, 180, 15, 253, 28, 168, 85, 124, 17, 124, 218, 101 }&lt;br /&gt;
	C -&amp;gt; S {hash(master secret || padding value || hash(messages || master secret || padding value))}&lt;br /&gt;
    where messages refers to concatenation messages exchanged from 1 through #&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
====Round 4 : Acknowledgment between Client and the Server====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
	The client updates the session and connection information to reflect the cipher it uses and then sends a “finished” message&lt;br /&gt;
SESSION KEYGEN:&lt;br /&gt;
PreMaster Secret:&lt;br /&gt;
0000: 03 01 A1 25 05 11 9A CA   49 21 4B 32 3D F2 2C FC  ...%....I!K2=.,.&lt;br /&gt;
0010: E8 50 A1 B9 02 3D 9A 36   B1 C0 8D EB 5F AE DB D8  .P...=.#..._...&lt;br /&gt;
0020: FB 96 BD 63 BC B4 0F FD   1C A8 55 7C 11 7C DA 65  ...c......U....e&lt;br /&gt;
CONNECTION KEYGEN:&lt;br /&gt;
Client Nonce:&lt;br /&gt;
0000: 45 73 A6 71 FA 14 8E E7   8F 4E 48 34 FE 2E C7 27  Es.q.....NH#..'&lt;br /&gt;
0010: 92 17 EE 05 6C AB 4B C0   4E AD 1A 97 59 56 3A C5  ....l.K.N...YV:.&lt;br /&gt;
Server Nonce:&lt;br /&gt;
0000: 45 73 A6 71 21 5B 4E BD   9C B7 8E FD 77 9B 16 C1  Es.q![N.....w...&lt;br /&gt;
0010: 2E 00 32 99 A8 AA 13 DC   44 61 62 03 24 E4 67 75  ..#....Dab.$.gu&lt;br /&gt;
Master Secret:&lt;br /&gt;
0000: B5 AF 35 36 65 B8 2E A9   F0 5C C1 A7 BD 85 98 92  ..56e....\......&lt;br /&gt;
0010: 64 61 B6 B9 7D 86 AB C7   72 CA 67 9A E1 C1 C4 3F  da......r.g....?&lt;br /&gt;
0020: C5 8B 67 1A 49 C9 6E B2   FC AB 65 96 EA 7E 67 8C  ..g.I.n...e...g.&lt;br /&gt;
Client MAC write Secret:&lt;br /&gt;
0000: A4 C0 36 E3 9A D3 8B 67   AA 51 D6 78 59 BF 0A 5E  ..#...g.Q.xY..^&lt;br /&gt;
Server MAC write Secret:&lt;br /&gt;
0000: F7 D0 65 1D 4C 0E 81 0F   1F 76 86 D7 91 68 37 50  ..e.L....v...h7P&lt;br /&gt;
Client write key:&lt;br /&gt;
0000: A6 C5 F0 7D FE 1C 0E 58   85 00 A5 02 AE 08 B5 0E  .......X........&lt;br /&gt;
Server write key:&lt;br /&gt;
0000: 20 D3 07 A2 02 02 34 67   2C C3 5A 50 7C 0F 87 CB   .....4g,.ZP....&lt;br /&gt;
... no IV for cipher&lt;br /&gt;
[read] MD5 and SHA1 hashes:  len = 134&lt;br /&gt;
0000: 10 00 00 82 00 80 10 D4   F8 1C 1D 96 62 B2 59 DD  ............b.Y.&lt;br /&gt;
0010: D6 F8 F1 0F A5 5E 75 0F   4F 3D 5B 56 2C 6A 24 FD  .....^u.O=[V,j$.&lt;br /&gt;
0020: 4A 90 D4 3A F3 3F 7E 22   D2 00 18 3B 7D 3F CD 02  J..:.?.&amp;quot;...;.?..&lt;br /&gt;
0030: 0C E1 11 7C 12 59 D8 A3   85 8D CB 23 B7 90 1C 59  .....Y.....#...Y&lt;br /&gt;
0040: 94 65 5F 7E 8E 46 6D A9   7D FC 54 5D 81 DC 69 82  .e_..Fm...T]..i.&lt;br /&gt;
0050: 1A EE 1A A5 F1 52 66 A6   43 34 EE E0 F7 12 36 CF  .....Rf.C#...#&lt;br /&gt;
0060: 7A 38 48 5A C9 8E 11 CB   AE 7A 36 2D FD 0B CD 1A  z8HZ.....z6-....&lt;br /&gt;
0070: 0B F1 45 1E C6 71 D9 57   39 80 75 BF D6 68 43 15  ..E..q.W#u..hC.&lt;br /&gt;
0080: FE 4D 67 DC 2F BD                                  .Mg./.&lt;br /&gt;
[Raw read]: length = 5&lt;br /&gt;
0000: 14 03 01 00 01                                     .....&lt;br /&gt;
[Raw read]: length = 1&lt;br /&gt;
0000: 01                                                 .&lt;br /&gt;
main, READ: TLSv1 Change Cipher Spec, length = 1&lt;br /&gt;
[Raw read]: length = 5&lt;br /&gt;
0000: 16 03 01 00 20                                     ....&lt;br /&gt;
[Raw read]: length = 32&lt;br /&gt;
0000: C7 D8 CC 69 F7 F7 7F 00   29 F6 23 C8 DD 11 50 33  ...i....).#...P3&lt;br /&gt;
0010: 89 BB 91 21 BD 05 24 8C   5B 77 33 9D 78 0A B4 3C  ...!..$.[w#x..&amp;lt;&lt;br /&gt;
main, READ: TLSv1 Handshake, length = 32&lt;br /&gt;
Padded plaintext after DECRYPTION:  len = 32&lt;br /&gt;
0000: 14 00 00 0C 01 B0 24 0D   BC AD E7 E9 DC CB E4 17  ......$.........&lt;br /&gt;
0010: F9 FF 44 03 B2 00 37 12   9C A2 16 62 2E 9E 3C 33  ..D...#...b..&amp;lt;3&lt;br /&gt;
*** Finished&lt;br /&gt;
verify_data:  { 1, 176, 36, 13, 188, 173, 231, 233, 220, 203, 228, 23 }&lt;br /&gt;
&lt;br /&gt;
	Server responds back with a “change cipher spec” message and updates its session and connection information accordingly and sends a finish message.&lt;br /&gt;
SESSION KEYGEN:&lt;br /&gt;
PreMaster Secret:&lt;br /&gt;
0000: 03 01 A1 25 05 11 9A CA   49 21 4B 32 3D F2 2C FC  ...%....I!K2=.,.&lt;br /&gt;
0010: E8 50 A1 B9 02 3D 9A 36   B1 C0 8D EB 5F AE DB D8  .P...=.#..._...&lt;br /&gt;
0020: FB 96 BD 63 BC B4 0F FD   1C A8 55 7C 11 7C DA 65  ...c......U....e&lt;br /&gt;
CONNECTION KEYGEN:&lt;br /&gt;
Client Nonce:&lt;br /&gt;
0000: 45 73 A6 71 FA 14 8E E7   8F 4E 48 34 FE 2E C7 27  Es.q.....NH#..'&lt;br /&gt;
0010: 92 17 EE 05 6C AB 4B C0   4E AD 1A 97 59 56 3A C5  ....l.K.N...YV:.&lt;br /&gt;
Server Nonce:&lt;br /&gt;
0000: 45 73 A6 71 21 5B 4E BD   9C B7 8E FD 77 9B 16 C1  Es.q![N.....w...&lt;br /&gt;
0010: 2E 00 32 99 A8 AA 13 DC   44 61 62 03 24 E4 67 75  ..#....Dab.$.gu&lt;br /&gt;
Master Secret:&lt;br /&gt;
0000: B5 AF 35 36 65 B8 2E A9   F0 5C C1 A7 BD 85 98 92  ..56e....\......&lt;br /&gt;
0010: 64 61 B6 B9 7D 86 AB C7   72 CA 67 9A E1 C1 C4 3F  da......r.g....?&lt;br /&gt;
0020: C5 8B 67 1A 49 C9 6E B2   FC AB 65 96 EA 7E 67 8C  ..g.I.n...e...g.&lt;br /&gt;
Client MAC write Secret:&lt;br /&gt;
0000: A4 C0 36 E3 9A D3 8B 67   AA 51 D6 78 59 BF 0A 5E  ..#...g.Q.xY..^&lt;br /&gt;
Server MAC write Secret:&lt;br /&gt;
0000: F7 D0 65 1D 4C 0E 81 0F   1F 76 86 D7 91 68 37 50  ..e.L....v...h7P&lt;br /&gt;
Client write key:&lt;br /&gt;
0000: A6 C5 F0 7D FE 1C 0E 58   85 00 A5 02 AE 08 B5 0E  .......X........&lt;br /&gt;
Server write key:&lt;br /&gt;
0000: 20 D3 07 A2 02 02 34 67   2C C3 5A 50 7C 0F 87 CB   .....4g,.ZP....&lt;br /&gt;
... no IV for cipher&lt;br /&gt;
main, WRITE: TLSv1 Change Cipher Spec, length = 1&lt;br /&gt;
[Raw write]: length = 6&lt;br /&gt;
0000: 14 03 01 00 01 01                                  ......&lt;br /&gt;
*** Finished&lt;br /&gt;
verify_data:  { 1, 176, 36, 13, 188, 173, 231, 233, 220, 203, 228, 23 }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Once the handshake is complete, secure communication can commence.&lt;br /&gt;
&lt;br /&gt;
==The Need for Keytool==&lt;br /&gt;
The server needs to generate a certificate and a private key associated with its certificate. This certificate would be sent to the clients who wishes to communicate with the server. These functionalities of Key generation, Key management , certificate management are taken care by a tool provided by Sun known as keytool. Keytool uses keystores to store the public / private keys as well as certificates. &lt;br /&gt;
keystores are datastores implemented as files. Private keys are protected with passwords.&lt;br /&gt;
&lt;br /&gt;
===Algorithms supported by Keytool===&lt;br /&gt;
Keytool supports any algorithm implemented by the registered cryptographic service providers. Default key pair generation algorithm is DSA with a keysize of 1024 bits. The signature algorithm is derived from the algorithm of the private keys. DSA gets coupled with SHA1 by default and so &amp;quot;SHA1withDSA&amp;quot; would be used. RSA gets coupled with MD5 and so &amp;quot;MD5withRSA&amp;quot; would be used.&lt;br /&gt;
&lt;br /&gt;
===Some of the frequently used functions of keytool are:===&lt;br /&gt;
==== Generating keys using keytools====&lt;br /&gt;
Key pairs can be generated using keytool with the following command and options&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$bash # keytool -genkey -alias testkey -keystore testkeystore.ks&lt;br /&gt;
Enter keystore password:  testpwd&lt;br /&gt;
What is your first and last name?&lt;br /&gt;
  [Unknown]:  Tom&lt;br /&gt;
What is the name of your organizational unit?&lt;br /&gt;
  [Unknown]:  security&lt;br /&gt;
What is the name of your organization?&lt;br /&gt;
  [Unknown]:  ABC Inc&lt;br /&gt;
What is the name of your City or Locality?&lt;br /&gt;
  [Unknown]:  Fort Meade&lt;br /&gt;
What is the name of your State or Province?&lt;br /&gt;
  [Unknown]:  MA&lt;br /&gt;
What is the two-letter country code for this unit?&lt;br /&gt;
  [Unknown]:  US&lt;br /&gt;
Is CN=Tom, OU=security, O=ABC Inc, L=Fort Meade, ST=MA, C=US correct?&lt;br /&gt;
  [no]:  y&lt;br /&gt;
&lt;br /&gt;
Enter key password for &amp;lt;testkey&amp;gt;&lt;br /&gt;
        (RETURN if same as keystore password):&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* The option ''-genkey'' is used to generate the keys. &lt;br /&gt;
* ''-alias'' specifies the name of the key. This can be verified by the command keytool -list -keystore testkeystore.ks&lt;br /&gt;
* ''-keystore'' is the name of the keystore to where the key needs to be added. If no keystore name is specified, the generated keys will be added to the default keystore. The default keystore gets autogenerated when the first key is created and is  located in the users home directory with an &amp;quot;.keystore&amp;quot; extension.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following defaults would be applied during the genkey process:&lt;br /&gt;
		* keyalg - defaults to DSA&lt;br /&gt;
		* keysize - defaults to 1024 bits&lt;br /&gt;
		* validity - defaults to 90 days&lt;br /&gt;
&lt;br /&gt;
====Importing certificates into keystore from .cer files====&lt;br /&gt;
A certificate represented usually by a .cer file is imported into the keystore so that it gets added to the list of trusted certificates.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$bash # keytool -import -keystore testkeystore.ks -file ssltest.cer&lt;br /&gt;
Enter keystore password:  testpwd&lt;br /&gt;
Owner: CN=Jane P, OU=Network Admins, O=NewCo, L=Denver, ST=CO, C=US&lt;br /&gt;
Issuer: CN=Jane P, OU=Network Admins, O=NewCo, L=Denver, ST=CO, C=US&lt;br /&gt;
Serial number: 45697b96&lt;br /&gt;
Valid from: Sun Nov 26 06:33:42 EST 2006 until: Wed Apr 12 07:33:42 EDT 2034&lt;br /&gt;
Certificate fingerprints:&lt;br /&gt;
         MD5:  BD:AA:A5:77:AC:92:17:0E:D3:6E:E2:8F:2B:12:A5:6C&lt;br /&gt;
         SHA1: 2F:BF:88:E1:2F:26:B9:C3:64:5E:C5:7F:F4:BF:43:7F:37:3D:BE:C5&lt;br /&gt;
Trust this certificate? [no]:  yes&lt;br /&gt;
Certificate was added to keystore&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The certificate ssltest.cer is successfully imported into the keystore. The serial number generated is unique to this certificate and is useful during certificate revocations. When a certificate is revoked, the serial number gets added to the CRL (Certificate revocation list).&lt;br /&gt;
'''Warning:'''&lt;br /&gt;
'''Before importing a certificate, validate if the certificate really belongs to the entity it claims to represent.'''&lt;br /&gt;
====Use the keytool -printcert -file ssltest.cer to view the contents of the certificate====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$bash # keytool -printcert -file ssltest.cer&lt;br /&gt;
Owner: CN=Jane P, OU=Network Admins, O=NewCo, L=Denver, ST=CO, C=US&lt;br /&gt;
Issuer: CN=Jane P, OU=Network Admins, O=NewCo, L=Denver, ST=CO, C=US&lt;br /&gt;
Serial number: 45697b96&lt;br /&gt;
Valid from: Sun Nov 26 06:33:42 EST 2006 until: Wed Apr 12 07:33:42 EDT 2034&lt;br /&gt;
Certificate fingerprints:&lt;br /&gt;
         MD5:  BD:AA:A5:77:AC:92:17:0E:D3:6E:E2:8F:2B:12:A5:6C&lt;br /&gt;
         SHA1: 2F:BF:88:E1:2F:26:B9:C3:64:5E:C5:7F:F4:BF:43:7F:37:3D:BE:C5&lt;br /&gt;
&lt;br /&gt;
# Verify from the Issuer of the certificate if the Certificate fingerprint matches.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Exporting certificates from keystore to files====&lt;br /&gt;
To export a certificate from a keystore to a file, the following command could be used&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$bash # keytool -export -alias testkey -keystore testkeystore.ks -file testkey.cer&lt;br /&gt;
Enter keystore password:  testpwd&lt;br /&gt;
Certificate stored in file &amp;lt;testkey.cer&amp;gt;&lt;br /&gt;
Now you can verify the contents of the exported certificate using the command.&lt;br /&gt;
$bash # keytool -printcert -file testkey.cer&lt;br /&gt;
Owner: CN=Tom, OU=security, O=ABC Inc, L=Fort Meade, ST=MA, C=US&lt;br /&gt;
Issuer: CN=Tom, OU=security, O=ABC Inc, L=Fort Meade, ST=MA, C=US&lt;br /&gt;
Serial number: 45736152&lt;br /&gt;
Valid from: Sun Dec 03 18:44:18 EST 2006 until: Sat Mar 03 18:44:18 EST 2007&lt;br /&gt;
Certificate fingerprints:&lt;br /&gt;
         MD5:  8F:D3:EA:E7:B0:CF:9C:03:16:2F:3F:C9:6C:BC:5A:D4&lt;br /&gt;
         SHA1: 03:2B:C6:BD:D9:82:31:08:F1:88:3C:35:AD:8D:F9:C3:90:5E:53:6F&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
==Examples==&lt;br /&gt;
===SSLClient.java===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
package org.owasp.crypto;&lt;br /&gt;
&lt;br /&gt;
import java.io.*;&lt;br /&gt;
&lt;br /&gt;
import javax.net.ssl.*;&lt;br /&gt;
import com.sun.net.ssl.*;&lt;br /&gt;
import com.sun.net.ssl.internal.ssl.Provider;&lt;br /&gt;
import java.security.Security;&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 * @author Joe Prasanna Kumar&lt;br /&gt;
 * This program simulates a client socket program which communicates with the SSL Server&lt;br /&gt;
 * &lt;br /&gt;
 * Algorithm:&lt;br /&gt;
 * 1. Determine the SSL Server Name and port in which the SSL server is listening&lt;br /&gt;
 * 2. Register the JSSE provider&lt;br /&gt;
 * 3. Create an instance of SSLSocketFactory&lt;br /&gt;
 * 4. Create an instance of SSLSocket&lt;br /&gt;
 * 5. Create an OutputStream object to write to the SSL Server&lt;br /&gt;
 * 6. Create an InputStream object to receive messages back from the SSL Server&lt;br /&gt;
 * &lt;br /&gt;
 */ &lt;br /&gt;
&lt;br /&gt;
public class SSLClient {&lt;br /&gt;
&lt;br /&gt;
	/**&lt;br /&gt;
	 * @param args&lt;br /&gt;
	 */&lt;br /&gt;
	public static void main(String[] args) throws Exception{&lt;br /&gt;
		String strServerName = &amp;quot;localhost&amp;quot;; // SSL Server Name&lt;br /&gt;
		int intSSLport = 4443; // Port where the SSL Server is listening&lt;br /&gt;
		PrintWriter out = null;&lt;br /&gt;
        BufferedReader in = null;&lt;br /&gt;
&lt;br /&gt;
		{&lt;br /&gt;
			// Registering the JSSE provider&lt;br /&gt;
			Security.addProvider(new Provider());&lt;br /&gt;
		}&lt;br /&gt;
&lt;br /&gt;
		try {&lt;br /&gt;
			// Creating Client Sockets&lt;br /&gt;
			SSLSocketFactory sslsocketfactory = (SSLSocketFactory)SSLSocketFactory.getDefault();&lt;br /&gt;
			SSLSocket sslSocket = (SSLSocket)sslsocketfactory.createSocket(strServerName,intSSLport);&lt;br /&gt;
&lt;br /&gt;
         	// Initializing the streams for Communication with the Server&lt;br /&gt;
         	out = new PrintWriter(sslSocket.getOutputStream(), true);&lt;br /&gt;
         	in = new BufferedReader(new InputStreamReader(sslSocket.getInputStream()));&lt;br /&gt;
&lt;br /&gt;
			BufferedReader stdIn = new BufferedReader(new InputStreamReader(System.in));&lt;br /&gt;
			String userInput = &amp;quot;Hello Testing &amp;quot;;&lt;br /&gt;
			out.println(userInput);&lt;br /&gt;
&lt;br /&gt;
			while ((userInput = stdIn.readLine()) != null) {&lt;br /&gt;
			    out.println(userInput);&lt;br /&gt;
			    System.out.println(&amp;quot;echo: &amp;quot; + in.readLine());&lt;br /&gt;
			}&lt;br /&gt;
&lt;br /&gt;
				out.println(userInput);&lt;br /&gt;
&lt;br /&gt;
				// Closing the Streams and the Socket&lt;br /&gt;
				out.close();&lt;br /&gt;
				in.close();&lt;br /&gt;
				stdIn.close();&lt;br /&gt;
				sslSocket.close();&lt;br /&gt;
		}&lt;br /&gt;
&lt;br /&gt;
		catch(Exception exp)&lt;br /&gt;
		{&lt;br /&gt;
			System.out.println(&amp;quot; Exception occured .... &amp;quot; +exp);&lt;br /&gt;
			exp.printStackTrace();&lt;br /&gt;
		}&lt;br /&gt;
&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===SSLServer.java===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
package org.owasp.crypto;&lt;br /&gt;
&lt;br /&gt;
import java.io.*;&lt;br /&gt;
import java.security.Security;&lt;br /&gt;
import java.security.PrivilegedActionException;&lt;br /&gt;
&lt;br /&gt;
import javax.net.ssl.*;&lt;br /&gt;
import com.sun.net.ssl.*;&lt;br /&gt;
import com.sun.net.ssl.internal.ssl.Provider;&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 * @author Joe Prasanna Kumar&lt;br /&gt;
 * This program simulates an SSL Server listening on a specific port for client requests&lt;br /&gt;
 * &lt;br /&gt;
 * Algorithm:&lt;br /&gt;
 * 1. Regsiter the JSSE provider&lt;br /&gt;
 * 2. Set System property for keystore by specifying the keystore which contains the server certificate&lt;br /&gt;
 * 3. Set System property for the password of the keystore which contains the server certificate&lt;br /&gt;
 * 4. Create an instance of SSLServerSocketFactory&lt;br /&gt;
 * 5. Create an instance of SSLServerSocket by specifying the port to which the SSL Server socket needs to bind with&lt;br /&gt;
 * 6. Initialize an object of SSLSocket&lt;br /&gt;
 * 7. Create InputStream object to read data sent by clients&lt;br /&gt;
 * 8. Create an OutputStream object to write data back to clients.&lt;br /&gt;
 * &lt;br /&gt;
 */ &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
public class SSLServer {&lt;br /&gt;
&lt;br /&gt;
	/**&lt;br /&gt;
	 * @param args&lt;br /&gt;
	 */&lt;br /&gt;
&lt;br /&gt;
	public static void main(String[] args) throws Exception{&lt;br /&gt;
&lt;br /&gt;
		int intSSLport = 4443; // Port where the SSL Server needs to listen for new requests from the client&lt;br /&gt;
&lt;br /&gt;
		{&lt;br /&gt;
			// Registering the JSSE provider&lt;br /&gt;
			Security.addProvider(new Provider());&lt;br /&gt;
&lt;br /&gt;
			//Specifying the Keystore details&lt;br /&gt;
			System.setProperty(&amp;quot;javax.net.ssl.keyStore&amp;quot;,&amp;quot;server.ks&amp;quot;);&lt;br /&gt;
			System.setProperty(&amp;quot;javax.net.ssl.keyStorePassword&amp;quot;,&amp;quot;JsEkey@4&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
			// Enable debugging to view the handshake and communication which happens between the SSLClient and the SSLServer&lt;br /&gt;
			// System.setProperty(&amp;quot;javax.net.debug&amp;quot;,&amp;quot;all&amp;quot;);&lt;br /&gt;
		}&lt;br /&gt;
&lt;br /&gt;
		try {&lt;br /&gt;
				// Initialize the Server Socket&lt;br /&gt;
				SSLServerSocketFactory sslServerSocketfactory = (SSLServerSocketFactory)SSLServerSocketFactory.getDefault();&lt;br /&gt;
				SSLServerSocket sslServerSocket = (SSLServerSocket)sslServerSocketfactory.createServerSocket(intSSLport);&lt;br /&gt;
				SSLSocket sslSocket = (SSLSocket)sslServerSocket.accept();&lt;br /&gt;
&lt;br /&gt;
				// Create Input / Output Streams for communication with the client&lt;br /&gt;
				while(true)&lt;br /&gt;
				{&lt;br /&gt;
				PrintWriter out = new PrintWriter(sslSocket.getOutputStream(), true);&lt;br /&gt;
		        BufferedReader in = new BufferedReader(&lt;br /&gt;
						new InputStreamReader(&lt;br /&gt;
								sslSocket.getInputStream()));&lt;br /&gt;
		        String inputLine, outputLine;&lt;br /&gt;
&lt;br /&gt;
		        while ((inputLine = in.readLine()) != null) {&lt;br /&gt;
		             out.println(inputLine);&lt;br /&gt;
		             System.out.println(inputLine);&lt;br /&gt;
		        }&lt;br /&gt;
&lt;br /&gt;
		        // Close the streams and the socket&lt;br /&gt;
		        out.close();&lt;br /&gt;
		        in.close();&lt;br /&gt;
		        sslSocket.close();&lt;br /&gt;
		        sslServerSocket.close();&lt;br /&gt;
&lt;br /&gt;
				}&lt;br /&gt;
			}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
		catch(Exception exp)&lt;br /&gt;
		{&lt;br /&gt;
			PrivilegedActionException priexp = new PrivilegedActionException(exp);&lt;br /&gt;
			System.out.println(&amp;quot; Priv exp --- &amp;quot; + priexp.getMessage());&lt;br /&gt;
&lt;br /&gt;
			System.out.println(&amp;quot; Exception occured .... &amp;quot; +exp);&lt;br /&gt;
			exp.printStackTrace();&lt;br /&gt;
		}&lt;br /&gt;
&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
* Computer Security – Arts and Science - Matt Bishop&lt;br /&gt;
* Core Security Patterns – Christopher Steele, Ray Lai and Ramesh Nagappan&lt;br /&gt;
* http://java.sun.com/j2se/##2/docs/tooldocs/windows/keytool.html&lt;br /&gt;
* http://blogs.borland.com/krish/archive/2005/07/28/#aspx&lt;br /&gt;
&lt;br /&gt;
[[Category:OWASP Java Project]]&lt;/div&gt;</summary>
		<author><name>Stephendv</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Talk:Securing_tomcat&amp;diff=24449</id>
		<title>Talk:Securing tomcat</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Talk:Securing_tomcat&amp;diff=24449"/>
				<updated>2008-01-14T16:58:03Z</updated>
		
		<summary type="html">&lt;p&gt;Stephendv: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;What's the best way to acknowledge the contributions of others as I'd like to add some thanks to Kris Easter, Michel Prunet and Stephen More.  This discussion area?  In brackets after the article link from [https://www.owasp.org/index.php/OWASP_Java_Project_Roadmap#Securing_Popular_J2EE_Servers Java Project Roadmap] ? [[User:Dledmonds|Darren]] 08:58, 27 October 2006 (EDT)&lt;br /&gt;
&lt;br /&gt;
I've added an acknowledgements section to the main page.  [[User:Stephendv|Stephendv]] 11:58, 14 January 2008 (EST)&lt;br /&gt;
&lt;br /&gt;
==UNIX Permissions==&lt;br /&gt;
&lt;br /&gt;
&amp;gt; Change files in CATALINA_HOME/conf to be readonly (440)&lt;br /&gt;
&lt;br /&gt;
Initially these are 600 (except for tomcat-users.xml which is 644 and Tomcat keeps it that way). Is there a need to make them group-readable?&lt;br /&gt;
&lt;br /&gt;
&amp;gt; Make sure tomcat user has ... write (220 - yes, only write) access to CATALINA_HOME/logs&lt;br /&gt;
&lt;br /&gt;
This doesn't work. I think the best that can be done here is 750 or 700.&lt;br /&gt;
&lt;br /&gt;
[[User:Combatopera|Combatopera]] 15:53, 12 November 2006 (EST)&lt;br /&gt;
&lt;br /&gt;
CATALINA_HOME/conf files updated to recommend chmod 400.  tomcat-user.xml the same as tomcat doesn't write to it.  Original file permissions for all these conf files were 600 when 5.5.20 was unpacked on a debian box.&lt;br /&gt;
&lt;br /&gt;
CATALINA_HOME/logs directory updated to recommend chmod 300.  Prevents tomcat user reading the logs within, but writing works fine for me - again after 5.5.20 was unpacked on a debian box.&lt;br /&gt;
&lt;br /&gt;
[[User:Dledmonds|Darren]] 04:35, 9 January 2007 (EST)&lt;/div&gt;</summary>
		<author><name>Stephendv</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Securing_tomcat&amp;diff=24448</id>
		<title>Securing tomcat</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Securing_tomcat&amp;diff=24448"/>
				<updated>2008-01-14T16:57:02Z</updated>
		
		<summary type="html">&lt;p&gt;Stephendv: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Status==&lt;br /&gt;
Released 14/1/2007&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
Most weaknesses in [http://tomcat.apache.org/ Apache Tomcat] come from incorrect or inappropriate configuration.  It is nearly always possible to make Tomcat more secure than the default out of the box installation.  What follows documents best practices and recommendations on securing a production Tomcat server, whether it be hosted on a Windows or Unix based operating system.  ''Please note that the section ordering is not a representation of the section importance.''&lt;br /&gt;
&lt;br /&gt;
== Software Versions ==&lt;br /&gt;
&lt;br /&gt;
The first step is to make sure you are running the latest stable releases of software;&lt;br /&gt;
* Java Runtime Environment (JRE) or SDK&lt;br /&gt;
* Tomcat&lt;br /&gt;
* Third party libraries&lt;br /&gt;
This does not mean you have to upgrade all your production servers to a new (and potentially buggy) release which has just been made available to the public.  What you must do is download the latest stable bugfix release that has continual support.  For the JRE and Tomcat you should be looking at the last digits in the version number (5.5.'''X''') as it represents the bugfix information.  The bugs fixed in these releases are publicly available so if you don't upgrade you could be providing attackers with a very easy route to compromise your server.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Installation of Apache Tomcat 5.5 ==&lt;br /&gt;
&lt;br /&gt;
=== UNIX ===&lt;br /&gt;
&lt;br /&gt;
* Create a tomcat user/group&lt;br /&gt;
* Download and unpack the core distribution (referenced as '''CATALINA_HOME''' from now on)&lt;br /&gt;
* Change '''CATALINA_HOME''' ownership to tomcat user and tomcat group&lt;br /&gt;
* Change files in '''CATALINA_HOME'''/conf to be readonly (400)&lt;br /&gt;
* Make sure tomcat user has read/write access to /tmp and write (300 - yes, only write/execute) access to '''CATALINA_HOME'''/logs&lt;br /&gt;
&lt;br /&gt;
=== Windows ===&lt;br /&gt;
&lt;br /&gt;
* Download the core windows service installer&lt;br /&gt;
* Start the installation, click ''Next'' and ''Agree'' to the licence&lt;br /&gt;
* Untick ''native'', ''documentation'', ''examples'' and ''webapps'' then click ''Next''&lt;br /&gt;
* Choose an installation directory (referenced as '''CATALINA_HOME''' from now on), preferably on a different drive to the OS.  &lt;br /&gt;
* Choose an administrator username (NOT admin) and a secure password that complies with your organisations password policy.&lt;br /&gt;
* Complete tomcat installation, but do not start service.&lt;br /&gt;
&lt;br /&gt;
=== Common ===&lt;br /&gt;
&lt;br /&gt;
* Remove everything from '''CATALINA_HOME'''/webapps (ROOT, balancer, jsp-examples, servlet-examples, tomcat-docs, webdav)&lt;br /&gt;
&lt;br /&gt;
* Remove everything from '''CATALINA_HOME'''/server/webapps (host-manager, manager).  Note that it can be useful to keep the manager webapp installed if you need the ability to redeploy without restarting Tomcat.  If you choose to keep it please read the section on Securing the Manager WebApp.&lt;br /&gt;
&lt;br /&gt;
* Remove '''CATALINA_HOME'''/conf/Catalina/localhost/host-manager.xml and '''CATALINA_HOME'''/conf/Catalina/localhost/manager.xml (again, if you are keeping the manager application, do not remove this).&lt;br /&gt;
&lt;br /&gt;
* Make sure the default servlet is configured '''not''' to serve index pages when a welcome file is not present.  In '''CATALINA_HOME'''/conf/web.xml&lt;br /&gt;
  &amp;lt;servlet&amp;gt;&lt;br /&gt;
    &amp;lt;servlet-name&amp;gt;default&amp;lt;/servlet-name&amp;gt;&lt;br /&gt;
    &amp;lt;servlet-class&amp;gt;org.apache.catalina.servlets.DefaultServlet&amp;lt;/servlet-class&amp;gt;&lt;br /&gt;
    &amp;lt;init-param&amp;gt;&lt;br /&gt;
      &amp;lt;param-name&amp;gt;debug&amp;lt;/param-name&amp;gt;&lt;br /&gt;
      &amp;lt;param-value&amp;gt;0&amp;lt;/param-value&amp;gt;&lt;br /&gt;
    &amp;lt;/init-param&amp;gt;&lt;br /&gt;
    &amp;lt;init-param&amp;gt;&lt;br /&gt;
      &amp;lt;param-name&amp;gt;listings&amp;lt;/param-name&amp;gt;&lt;br /&gt;
      &amp;lt;param-value&amp;gt;'''false'''&amp;lt;/param-value&amp;gt;  &amp;amp;lt;!-- make sure this is false --&amp;amp;gt;&lt;br /&gt;
    &amp;lt;/init-param&amp;gt;&lt;br /&gt;
    &amp;lt;load-on-startup&amp;gt;1&amp;lt;/load-on-startup&amp;gt;&lt;br /&gt;
  &amp;lt;/servlet&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Remove version string from HTTP error messages by repacking '''CATALINA_HOME'''/server/lib/catalina.jar with an updated ServerInfo.properties file.  Note that making this change may prevent [http://www.lambdaprobe.org  Lambda Probe] (popular Tomcat monitoring webapp) to initialise as it cannot determine the Tomcat version.  A solution to this can be found on the [http://www.lambdaprobe.org/forum2/message.jspa?messageID=477 Lambda Probe Forum].&lt;br /&gt;
:unpack catalina.jar&lt;br /&gt;
  cd CATALINA_HOME/server/lib&lt;br /&gt;
  jar xf catalina.jar org/apache/catalina/util/ServerInfo.properties&lt;br /&gt;
:update ServerInfo.properties by changing server.info line to server.info=Apache Tomcat&lt;br /&gt;
:repackage catalina.jar&lt;br /&gt;
  jar uf catalina.jar org/apache/catalina/util/ServerInfo.properties&lt;br /&gt;
:remove CATALINA_HOME/server/lib/org (created when extracting the ServerInfo.properties file)&lt;br /&gt;
&lt;br /&gt;
* Replace default error page (default is stacktrace) by adding the following into '''CATALINA_HOME'''/conf/web.xml.  The default error page shows a full stacktrace which is a disclosure of sensitive information.  Place the following within the ''web-app'' tag (after the ''welcome-file-list'' tag is fine). ''The following solution is not ideal as it produces a blank page because Tomcat cannot find the file specified, but without a better solution this, at least, achieves the desired result.  A well configured web application will override this default in CATALINA_HOME/webapps/APP_NAME/WEB-INF/web.xml so it won't cause problems.''&lt;br /&gt;
  &amp;lt;error-page&amp;gt;&lt;br /&gt;
    &amp;lt;exception-type&amp;gt;java.lang.Exception&amp;lt;/exception-type&amp;gt;&lt;br /&gt;
    &amp;lt;location&amp;gt;/error.jsp&amp;lt;/location&amp;gt;&lt;br /&gt;
  &amp;lt;/error-page&amp;gt;&lt;br /&gt;
* Rename '''CATALINA_HOME'''/conf/server.xml to '''CATALINA_HOME'''/conf/server-original.xml and rename '''CATALINA_HOME'''/conf/server-minimal.xml to '''CATALINA_HOME'''/conf/server.xml.  The minimal configuration provides the same basic configuration, but without the nested comments is much easier to maintain and understand.  Do not delete the original file as the comments make it useful for reference if you ever need to make changes - e.g. enable SSL.&lt;br /&gt;
&lt;br /&gt;
* Replace the server version string from HTTP headers in server responses, by adding the server keyword in your Connectors in '''CATALINA_HOME'''/conf/server.xml&lt;br /&gt;
  &amp;lt;Connector port=&amp;quot;8080&amp;quot; ...&lt;br /&gt;
             server=&amp;quot;Apache&amp;quot; /&amp;gt;  &amp;amp;lt;!-- server header is now Apache --&amp;amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Start Tomcat, deploy your applications into '''CATALINA_HOME'''/webapps and hope it works!&lt;br /&gt;
&lt;br /&gt;
== Protecting the Shutdown Port ==&lt;br /&gt;
Tomcat uses a port (defaults to 8005) as a shutdown port.  What this means is that to stop all webapps and stop Tomcat cleanly the shutdown scripts make a connection to this port and send the ''shutdown'' command.  This is not as huge a security problem as it may sound considering the connection to the port must be made from the machine running tomcat and the ''shutdown'' command can be changed to something other than the string ''SHUTDOWN''.  However, it's wise to take the following precautions;&lt;br /&gt;
* if you are running a publicly accessible server make sure you prevent external access to the shutdown port by using a suitable firewall.&lt;br /&gt;
* change the shutdown command in '''CATALINA_HOME'''/conf/server.xml and make sure that file is only readable by the tomcat user.&lt;br /&gt;
  &amp;amp;lt;Server port=&amp;quot;8005&amp;quot; shutdown=&amp;quot;ReallyComplexWord&amp;quot;&amp;amp;gt;&lt;br /&gt;
* if this is still a big problem for you then check [http://marc.theaimsgroup.com/?l=tomcat-user&amp;amp;m=104400608619118&amp;amp;w=2 this thread], from the Tomcat mailing list, for alternatives (they all involve code customisation though).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Securing Manager WebApp ==&lt;br /&gt;
&lt;br /&gt;
* By default there are no users with the manager role.  To make use of the manager webapp you need to add a new role and user into the '''CATALINA_HOME'''/conf/tomcat-users.xml file.&lt;br /&gt;
  &amp;lt;role rolename=&amp;quot;manager&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;user username=&amp;quot;darren&amp;quot; password=&amp;quot;ReallyComplexPassword&amp;quot; roles=&amp;quot;manager&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Using a [http://tomcat.apache.org/tomcat-5.5-doc/config/valve.html valve] to filter by IP or hostname to only allow a subset of machines to connect (i.e. LAN machines).  Add one of the following within the Context tag in '''CATALINA_HOME'''/conf/Catalina/localhost/manager.xml&lt;br /&gt;
  &amp;amp;lt;!-- allow only LAN IPs to connect to the manager webapp --&amp;amp;gt;&lt;br /&gt;
  &amp;amp;lt;!-- contrary to the current Tomcat 5.5 documation the value for '''allow''' is not a regular expression --&amp;amp;gt;&lt;br /&gt;
  &amp;amp;lt;!-- future versions may have to be specified as 192\.168\.1\.* --&amp;amp;gt;&lt;br /&gt;
  &amp;lt;Valve className=&amp;quot;org.apache.catalina.valves.RemoteAddrValve&amp;quot;&lt;br /&gt;
         allow=&amp;quot;192.168.1.*&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;amp;lt;!-- allow only LAN hosts to connect to the manager webapp --&amp;amp;gt;&lt;br /&gt;
  &amp;amp;lt;!-- contrary to the current Tomcat 5.5 documation the value for '''allow''' is not a regular expression --&amp;amp;gt;&lt;br /&gt;
  &amp;amp;lt;!-- future versions may have to be specified as *\.localdomain\.com --&amp;amp;gt;&lt;br /&gt;
  &amp;lt;Valve className=&amp;quot;org.apache.catalina.valves.RemoteHostValve&amp;quot;&lt;br /&gt;
         allow=&amp;quot;*.localdomain.com&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* You can rename the manager webapp to something else, e.g. ''foobar''&lt;br /&gt;
** Move '''CATALINA_HOME'''/conf/Catalina/localhost/'''manager.xml''' to '''CATALINA_HOME'''/conf/Catalina/localhost/'''foobar.xml'''&lt;br /&gt;
** Update the '''docBase''' attribute within '''CATALINA_HOME'''/conf/Catalina/localhost/'''foobar.xml''' to ${catalina.home}/server/webapps/foobar&lt;br /&gt;
** Move '''CATALINA_HOME'''/server/webapps/'''manager''' to '''CATALINA_HOME'''/server/webapps/'''foobar'''&lt;br /&gt;
&lt;br /&gt;
== Logging ==&lt;br /&gt;
&lt;br /&gt;
As of tomcat 5.5 logging is now handled by the commons-logging framework allowing you to choose your preferred logging implementation - log4j or standard JDK logging.  By default the standard JDK logging is used (or a compatible extension called juli to be more precise), storing daily log files in '''CATALINA_HOME'''/logs.&lt;br /&gt;
&lt;br /&gt;
By default additional webapp log entries are added to '''CATALINA_HOME'''/logs/catalina.YYYY-MM-DD.log and System.out/System.err are redirected to '''CATALINA_HOME'''/logs/catalina.out.  To place webapp log entries in individual log files create a ''logging.properties'' file similar to the following within '''CATALINA_HOME'''/webapps/''APP_NAME''/WEB-INF/classes (change the ''APP_NAME'' value to create a unique file for each webapp)&lt;br /&gt;
&lt;br /&gt;
  handlers = org.apache.juli.FileHandler, java.util.logging.ConsoleHandler&lt;br /&gt;
  org.apache.juli.FileHandler.level = ALL&lt;br /&gt;
  org.apache.juli.FileHandler.directory = ${catalina.base}/logs&lt;br /&gt;
  org.apache.juli.FileHandler.prefix = APP_NAME.&lt;br /&gt;
&lt;br /&gt;
Further details on logging configuration can be found in the [http://tomcat.apache.org/tomcat-5.5-doc/logging.html tomcat logging documentation.]&lt;br /&gt;
&lt;br /&gt;
If you find you get logging output duplicated in catalina.out, you most likely have unnecessary entries for ''java.util.logging.ConsoleHandler'' in your logging configuration file.&lt;br /&gt;
&lt;br /&gt;
== Encryption ==&lt;br /&gt;
&lt;br /&gt;
* SSL for password or other sensitive data exchange (''bordering on application security, not specific to tomcat'')&lt;br /&gt;
* SSL for connections (JDBC, LDAP, etc ..)&lt;br /&gt;
* The Tomcat documentation clearly explains how to [http://tomcat.apache.org/tomcat-5.5-doc/ssl-howto.html enable SSL.]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Java Security ==&lt;br /&gt;
&lt;br /&gt;
=== Running Tomcat with a Security Manager=== &lt;br /&gt;
The default Tomcat configuration provides good protection for most requirements, but does not prevent a malicious application from compromising the security of other applications running in the same instance.  To prevent this sort of attack, Tomcat can be run with a Security Manager enabled which strictly controls access to server resources.&lt;br /&gt;
Tomcat documentation has a good section on [http://tomcat.apache.org/tomcat-5.5-doc/security-manager-howto.html enabling the Security Manager.]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Miscellaneous ==&lt;br /&gt;
&lt;br /&gt;
* [http://tomcat.apache.org/faq/security.html Tomcat Security FAQ]&lt;br /&gt;
&lt;br /&gt;
=== Using Port 80 ===&lt;br /&gt;
&lt;br /&gt;
If you are on a Windows machine you will be able to change the port attribute of the connector within the ''Catalina'' service from 8080 to 80.  This allows you to use tomcat directly to serve all requests.  Depending on your requirements it may not be good enough to serve directly from Tomcat so you may like to consider;&lt;br /&gt;
* Use IIS / Apache running on port 80 and mod_jk to proxy requests to Tomcat&lt;br /&gt;
&lt;br /&gt;
On a UNIX machine only root is allowed to run services on ports below 1024 (kernel recompilation can overcome this).  It is a very bad idea to run Tomcat as root, so the options are (in no particular order);&lt;br /&gt;
* Use Apache running on port 80 and mod_jk (or mod_proxy_ajp) to proxy requests to Tomcat&lt;br /&gt;
* Run Tomcat as root, but in a chroot jail&lt;br /&gt;
* Use a tool like authbind to enable a non root user to bind to ports below 1024&lt;br /&gt;
* Use a port forwarder such as [http://www.netfilter.org/projects/iptables/index.html Iptables] to redirect incoming requests from 8080 to 80.  This has the disadvantage that internal redirects still need to use 8080.&lt;br /&gt;
* Run [http://www.squid-cache.org/ Squid] as a web accelerator in front of Tomcat&lt;br /&gt;
* Use JSVC/procrun&lt;br /&gt;
Each of the above options '''may''' bring extra security concerns which are outside the scope of this document.&lt;br /&gt;
&lt;br /&gt;
=== Cleartext Passwords in CATALINA_HOME/conf/server.xml ===&lt;br /&gt;
&lt;br /&gt;
When configuring a resource, such as a JDBC pool, it is necessary to include clear text username and password in CATALINA_HOME/conf/server.xml  Best practices advice us never to store clear text passwords, but the following paragraphs highlight it is very difficult to avoid.&lt;br /&gt;
&lt;br /&gt;
If one way encryption was used on the password it must be possible for a database connection to be established using a username and encrypted password - so the encrypted password is just as valuable as the clear text one to an attacker.&lt;br /&gt;
&lt;br /&gt;
If two way encryption was used a keyfile is needed which must also live on the filesystem.  To make it more secure a passphase is added to the keyfile which then has to be stored in the configuration as clear text - no improvement.&lt;br /&gt;
&lt;br /&gt;
Encoding is security by obscurity and offers no form of protection (algorithms can be reverse engineered).  What encoding does do is make huge amounts of overhead work - you need to customise Tomcat and the commons digester it uses to parse the config files.  You'd also need a way to create encoded passwords.&lt;br /&gt;
&lt;br /&gt;
In the case of a JDBC pool what you can do is;&lt;br /&gt;
* make sure the database user only has access to the databases and tables they need (also limit rights as necessary).&lt;br /&gt;
* make sure the raw database files are only accessible to the user running the database services (e.g. mysql/postgresql user)&lt;br /&gt;
* make sure the Tomcat configuration files are only accessible to the tomcat user&lt;br /&gt;
&lt;br /&gt;
==Acknowledgements==&lt;br /&gt;
The author would like to thank Kris Easter, Michel Prunet and Stephen More for their valuable input.&lt;br /&gt;
&lt;br /&gt;
[[Category:OWASP Java Project]]&lt;br /&gt;
[[Category:Java]]&lt;/div&gt;</summary>
		<author><name>Stephendv</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=SSL_Best_Practices&amp;diff=24447</id>
		<title>SSL Best Practices</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=SSL_Best_Practices&amp;diff=24447"/>
				<updated>2008-01-14T16:52:12Z</updated>
		
		<summary type="html">&lt;p&gt;Stephendv: /* Status */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Status ==&lt;br /&gt;
Draft&lt;br /&gt;
&lt;br /&gt;
==What is SSL==&lt;br /&gt;
&lt;br /&gt;
SSL is the abbreviation of Secured Socket Layer. It is a protocol enabling to settle a secured communication between two hosts. The origin host is viewed as an SSL client and the destination host as an SSL server.&lt;br /&gt;
&lt;br /&gt;
SSL has also been normalised as the TLS (Transport Layer Security) protocol. &lt;br /&gt;
&lt;br /&gt;
'''SSL is used on top of a transport level protocol''' like HTTP or FTP in order to secure it. &lt;br /&gt;
&lt;br /&gt;
SSL enables : &lt;br /&gt;
* authentication of the destination host for the origin host or mutual authentication of both the origin and the destination hosts&lt;br /&gt;
* data confidentiality through encryption&lt;br /&gt;
* data integrity checking through hashing.&lt;br /&gt;
&lt;br /&gt;
SSL relies on two types of encryption :&lt;br /&gt;
* public key encryption in the initiation phase, where authentication takes place&lt;br /&gt;
* secret key encryption when a session has been established and data is sent between two peers which trust each other.&lt;br /&gt;
&lt;br /&gt;
'''SSL only secures the communication between two endpoints''' : in the origin and destination points, data is in clear text, unless it is encrypted by another means, at the application level.&lt;br /&gt;
&lt;br /&gt;
==How SSL is implemented in J2EE==&lt;br /&gt;
==HTTPS best practices in general==&lt;br /&gt;
==HTTPS best practices in J2EE==&lt;br /&gt;
==Examples with Tomcat==&lt;br /&gt;
==Examples with JBoss==&lt;br /&gt;
&lt;br /&gt;
[[Category:OWASP Java Project]]&lt;/div&gt;</summary>
		<author><name>Stephendv</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Talk:Protecting_code_archives_with_digital_signatures&amp;diff=24445</id>
		<title>Talk:Protecting code archives with digital signatures</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Talk:Protecting_code_archives_with_digital_signatures&amp;diff=24445"/>
				<updated>2008-01-14T16:50:30Z</updated>
		
		<summary type="html">&lt;p&gt;Stephendv: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Status==&lt;br /&gt;
Reviewed [[User:Stephendv|Stephendv]] 11:50, 14 January 2008 (EST)&lt;br /&gt;
&lt;br /&gt;
==Authors==&lt;br /&gt;
* Pierre Parrend&lt;br /&gt;
&lt;br /&gt;
==Reviewers==&lt;br /&gt;
* Stephen de Vries&lt;br /&gt;
&lt;br /&gt;
==General Discussion==&lt;br /&gt;
*  'An example with OSGi bundles' should be a subtitle, not a paragraph title.&lt;/div&gt;</summary>
		<author><name>Stephendv</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Preventing_SQL_Injection_in_Java&amp;diff=24443</id>
		<title>Preventing SQL Injection in Java</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Preventing_SQL_Injection_in_Java&amp;diff=24443"/>
				<updated>2008-01-14T16:35:43Z</updated>
		
		<summary type="html">&lt;p&gt;Stephendv: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Status==&lt;br /&gt;
Released 14/1/2008&lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
As the name implies, SQL injection vulnerabilities allow an attacker to inject (or execute) SQL commands within an application.  It is one of the most wide spread and dangerous application vulnerability.  The CLASP project provides a good overview of [[SQL injection]].&lt;br /&gt;
===Example of SQL injection===&lt;br /&gt;
The following Java servlet code, used to perform a login function, illustrates the vulnerability by accepting user input without performing adequate input validation or escaping meta-characters:&lt;br /&gt;
 conn = pool.getConnection( );&lt;br /&gt;
 String sql = &amp;quot;select * from user where username='&amp;quot; + username +&amp;quot;' and password='&amp;quot; + password + &amp;quot;'&amp;quot;;&lt;br /&gt;
 stmt = conn.createStatement();&lt;br /&gt;
 rs = stmt.executeQuery(sql);&lt;br /&gt;
 if (rs.next()) {&lt;br /&gt;
 loggedIn = true;&lt;br /&gt;
 	out.println(&amp;quot;Successfully logged in&amp;quot;);&lt;br /&gt;
 } else {&lt;br /&gt;
 	out.println(&amp;quot;Username and/or password not recognized&amp;quot;);&lt;br /&gt;
 }&lt;br /&gt;
It is possible for attackers to provide a username containing SQL meta-characters that subvert the intended function of the SQL statement.  For example, by providing a username of:&lt;br /&gt;
 admin' OR '1'='1&lt;br /&gt;
and a blank password, the generated SQL statement becomes:&lt;br /&gt;
 select * from user where username='admin' OR '1'='1' and password=' '&lt;br /&gt;
This allows an attacker to log in to the site without supplying a password, since the ‘OR’ expression is always true.  Using the same technique attackers can inject other SQL commands which could extract, modify or delete data within the database.&lt;br /&gt;
===Attack techniques===&lt;br /&gt;
For more information on SQL injection attacks see:&lt;br /&gt;
* http://www.spidynamics.com/papers/SQLInjectionWhitePaper.pdf&lt;br /&gt;
* http://www.nextgenss.com/papers/advanced_sql_injection.pdf&lt;br /&gt;
* http://www.appsecinc.com/presentations/Manipulating_SQL_Server_Using_SQL_Injection.pdf &lt;br /&gt;
==Defence Strategy==&lt;br /&gt;
To prevent SQL injection, a two pronged approach is recommended:&lt;br /&gt;
* Firstly, all data accepted from user input should be thoroughly &amp;lt;b&amp;gt;validated&amp;lt;/b&amp;gt; to ensure that the characters received are part of the set of valid characters for that field;&lt;br /&gt;
* Secondly, all data acted on by SQL commands should be &amp;lt;b&amp;gt;escaped for meta-characters&amp;lt;/b&amp;gt;.&lt;br /&gt;
=== Validating Input ===&lt;br /&gt;
A general security principle which applies itself well to data validation is that of “deny by default” where data is rejected unless it specifically matches the criteria for known good data.  This is also known as a “white list” approach and is the preferred method for performing data validation.  It allows one to define a restricted range for valid data and reject everything that does not fit this set.  The set of valid data should be constrained by:&lt;br /&gt;
* Type – String, integer, unsigned integer, float etc;&lt;br /&gt;
* Length;&lt;br /&gt;
* Set of character – for example, only alphabetic characters [a-zA-Z]*; &lt;br /&gt;
* Format – if appropriate the data could be further constrained by specifying a format, e.g.: \d\d\/\d\d\/\d\d&lt;br /&gt;
* Reasonableness – where possible, values should be compared to expected ranges.  For example, a customer ordering 1000 televisions could be suspicious.&lt;br /&gt;
It is essential that the data validation routines themselves can be trusted, therefore they must be performed on the server side.  Client side validation can be performed as a useful user interface feature, but it must be reinforced by server side validation.&lt;br /&gt;
Where input validation is performed on the server side will depend largely on the frameworks available.  JSF and Struts provide validation functions that are defined in the view layer, while Spring and EJB 3.0 allow validation to be defined in the model.&amp;lt;br&amp;gt; &lt;br /&gt;
Input validation provides the first line of defence in preventing dangerous characters from being processed by the application.&lt;br /&gt;
But even if data is constrained in this way it does not solve the meta-character problem: How should the application handle meta-characters that are defined as valid data, but cannot be used in certain processing contexts?  For example, the single quote (') character may be a valid character in a surname, but this character cannot simply be used in a string that is used to form an SQL statement.  The OWASP Guide project has more information on [[Data Validation]].&lt;br /&gt;
=== Escaping Meta-characters ===&lt;br /&gt;
All data access techniques provide some means for escaping SQL meta-characters automatically.  The important thing to remember is to &amp;lt;b&amp;gt;never construct SQL statements using string concatenation of unchecked input values.&amp;lt;/b&amp;gt;  The following sections detail how to perform input validation and meta-character escaping using popular data access technologies.&lt;br /&gt;
==Prepared Statements==&lt;br /&gt;
Variables passed as arguments to prepared statements will automatically be escaped by the JDBC driver.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;b&amp;gt;Example: &amp;lt;/b&amp;gt;ps.1&amp;lt;br&amp;gt;&lt;br /&gt;
 String selectStatement = &amp;quot;SELECT * FROM User WHERE userId = ? &amp;quot;;&lt;br /&gt;
 PreparedStatement prepStmt = con.prepareStatement(selectStatement);&lt;br /&gt;
 prepStmt.setString(1, userId);&lt;br /&gt;
 ResultSet rs = prepStmt.executeQuery();&lt;br /&gt;
&lt;br /&gt;
Although Prepared Statements helps in defending against SQL Injection, there are possibilities of SQL Injection attacks through inappropriate usage of Prepared Statements. The example below explains such a scenario where the input variables are passed directly into the Prepared Statement and thereby paving way for SQL Injection attacks. &amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;b&amp;gt;Example: &amp;lt;/b&amp;gt;ps.2&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
String strUserName = request.getParameter(&amp;quot;Txt_UserName&amp;quot;); &lt;br /&gt;
PreparedStatement prepStmt = con.prepareStatement(&amp;quot;SELECT * FROM user WHERE userId = '+strUserName+'&amp;quot;);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
It is highly recommended to use Bind Variables as mentioned in the example ps.1 above. Usage of PreparedStatement with Bind variables defends SQL Injection attacks and improves the performance.&lt;br /&gt;
&lt;br /&gt;
==Stored Procedures==&lt;br /&gt;
==Hibernate==&lt;br /&gt;
According to [http://forum.hibernate.org/viewtopic.php?t=960817&amp;amp;start=0&amp;amp;postdays=0&amp;amp;postorder=asc this forum thread] hibernate uses prepared statements, so it is protected from direct sql injection, but it could still be vulnerable to [http://www.owasp.org/index.php/Interpreter_Injection#ORM_Injection injecting HQL statements].&lt;br /&gt;
&lt;br /&gt;
==Ibatis==&lt;br /&gt;
&lt;br /&gt;
Ibatis creates prepared statements for database access.&lt;br /&gt;
However, SQL injection is possible in Ibatis if the $$ variable replacement syntax is used.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Vulnerable: &amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;select id=“vuln&amp;quot; resultMap=“myResultMap”&amp;gt; select * from table where id = &amp;lt;b&amp;gt;$&amp;lt;/b&amp;gt;value&amp;lt;b&amp;gt;$&amp;lt;/b&amp;gt;&amp;lt;/select&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
The above query is called as follows:&lt;br /&gt;
 MyBean b = (MyBean)sqlMap.queryForObject(&amp;quot;vuln&amp;quot;, new Integer(1));&lt;br /&gt;
 &lt;br /&gt;
The SQL statement thus created, looks as follows:&lt;br /&gt;
&lt;br /&gt;
select * from table where id = 1&lt;br /&gt;
&lt;br /&gt;
The object passed as parameter is directly fed to the SQL query making it susceptible to SQL injection&amp;lt;br&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;b&amp;gt;Secure: &amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;select id=“vuln&amp;quot; resultMap=“myResultMap”&amp;gt; select * from table where id = &amp;lt;b&amp;gt;#&amp;lt;/b&amp;gt;value&amp;lt;b&amp;gt;#&amp;lt;/b&amp;gt;&amp;lt;/select&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Using this form instead generates the following SQL&lt;br /&gt;
&lt;br /&gt;
select * from table where id = ?&lt;br /&gt;
&lt;br /&gt;
The value of the parameter is sent directly to the driver and not used to modify the SQL statement itself.&amp;lt;br&amp;gt;&lt;br /&gt;
This approach thwarts SQL injection attacks by automatically escaping SQL meta-characters.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
*[1] [http://research.corsaire.com/whitepapers/060116-a-modular-approach-to-data-validation.pdf A Modular Approach to Data Validation]&lt;br /&gt;
*[2] [http://forum.hibernate.org/viewtopic.php?t=960817&amp;amp;start=0&amp;amp;postdays=0&amp;amp;postorder=asc&amp;amp;highlight= Topic: does Hibernate guard against SQL injection?]&lt;br /&gt;
&lt;br /&gt;
[[Category:OWASP Java Project]]&lt;/div&gt;</summary>
		<author><name>Stephendv</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Preventing_SQL_Injection_in_Java&amp;diff=24441</id>
		<title>Preventing SQL Injection in Java</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Preventing_SQL_Injection_in_Java&amp;diff=24441"/>
				<updated>2008-01-14T16:34:47Z</updated>
		
		<summary type="html">&lt;p&gt;Stephendv: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Status==&lt;br /&gt;
Released 14/1/2008&lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
As the name implies, SQL injection vulnerabilities allow an attacker to inject (or execute) SQL commands within an application.  It is one of the most wide spread and dangerous application vulnerability.  The CLASP project provides a good overview of [[SQL injection]].&lt;br /&gt;
===Example of SQL injection===&lt;br /&gt;
The following Java servlet code, used to perform a login function, illustrates the vulnerability by accepting user input without performing adequate input validation or escaping meta-characters:&lt;br /&gt;
 conn = pool.getConnection( );&lt;br /&gt;
 String sql = &amp;quot;select * from user where username='&amp;quot; + username +&amp;quot;' and password='&amp;quot; + password + &amp;quot;'&amp;quot;;&lt;br /&gt;
 stmt = conn.createStatement();&lt;br /&gt;
 rs = stmt.executeQuery(sql);&lt;br /&gt;
 if (rs.next()) {&lt;br /&gt;
 loggedIn = true;&lt;br /&gt;
 	out.println(&amp;quot;Successfully logged in&amp;quot;);&lt;br /&gt;
 } else {&lt;br /&gt;
 	out.println(&amp;quot;Username and/or password not recognized&amp;quot;);&lt;br /&gt;
 }&lt;br /&gt;
It is possible for attackers to provide a username containing SQL meta-characters that subvert the intended function of the SQL statement.  For example, by providing a username of:&lt;br /&gt;
 admin' OR '1'='1&lt;br /&gt;
and a blank password, the generated SQL statement becomes:&lt;br /&gt;
 select * from user where username='admin' OR '1'='1' and password=' '&lt;br /&gt;
This allows an attacker to log in to the site without supplying a password, since the ‘OR’ expression is always true.  Using the same technique attackers can inject other SQL commands which could extract, modify or delete data within the database.&lt;br /&gt;
===Attack techniques===&lt;br /&gt;
For more information on SQL injection attacks see:&lt;br /&gt;
* http://www.spidynamics.com/papers/SQLInjectionWhitePaper.pdf&lt;br /&gt;
* http://www.nextgenss.com/papers/advanced_sql_injection.pdf&lt;br /&gt;
* http://www.appsecinc.com/presentations/Manipulating_SQL_Server_Using_SQL_Injection.pdf &lt;br /&gt;
==Defence Strategy==&lt;br /&gt;
To prevent SQL injection, a two pronged approach is recommended:&lt;br /&gt;
* Firstly, all data accepted from user input should be thoroughly &amp;lt;b&amp;gt;validated&amp;lt;/b&amp;gt; to ensure that the characters received are part of the set of valid characters for that field;&lt;br /&gt;
* Secondly, all data acted on by SQL commands should be &amp;lt;b&amp;gt;escaped for meta-characters&amp;lt;/b&amp;gt;.&lt;br /&gt;
=== Validating Input ===&lt;br /&gt;
A general security principle which applies itself well to data validation is that of “deny by default” where data is rejected unless it specifically matches the criteria for known good data.  This is also known as a “white list” approach and is the preferred method for performing data validation.  It allows one to define a restricted range for valid data and reject everything that does not fit this set.  The set of valid data should be constrained by:&lt;br /&gt;
* Type – String, integer, unsigned integer, float etc;&lt;br /&gt;
* Length;&lt;br /&gt;
* Set of character – for example, only alphabetic characters [a-zA-Z]*; &lt;br /&gt;
* Format – if appropriate the data could be further constrained by specifying a format, e.g.: \d\d\/\d\d\/\d\d&lt;br /&gt;
* Reasonableness – where possible, values should be compared to expected ranges.  For example, a customer ordering 1000 televisions could be suspicious.&lt;br /&gt;
It is essential that the data validation routines themselves can be trusted, therefore they must be performed on the server side.  Client side validation can be performed as a useful user interface feature, but it must be reinforced by server side validation.&lt;br /&gt;
Where input validation is performed on the server side will depend largely on the frameworks available.  JSF and Struts provide validation functions that are defined in the view layer, while Spring and EJB 3.0 allow validation to be defined in the model.&amp;lt;br&amp;gt; &lt;br /&gt;
Input validation provides the first line of defence in preventing dangerous characters from being processed by the application.&lt;br /&gt;
But even if data is constrained in this way it does not solve the meta-character problem: How should the application handle meta-characters that are defined as valid data, but cannot be used in certain processing contexts?  For example, the single quote (') character may be a valid character in a surname, but this character cannot simply be used in a string that is used to form an SQL statement.  The OWASP Guide project has more information on [[Data Validation]].&lt;br /&gt;
=== Escaping Meta-characters ===&lt;br /&gt;
All data access techniques provide some means for escaping SQL meta-characters automatically.  The important thing to remember is to &amp;lt;b&amp;gt;never construct SQL statements using string concatenation of unchecked input values.&amp;lt;/b&amp;gt;  The following sections detail how to perform input validation and meta-character escaping using popular data access technologies.&lt;br /&gt;
==Prepared Statements==&lt;br /&gt;
Variables passed as arguments to prepared statements will automatically be escaped by the JDBC driver.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;b&amp;gt;Example: &amp;lt;/b&amp;gt;ps.1&amp;lt;br&amp;gt;&lt;br /&gt;
 String selectStatement = &amp;quot;SELECT * FROM User WHERE userId = ? &amp;quot;;&lt;br /&gt;
 PreparedStatement prepStmt = con.prepareStatement(selectStatement);&lt;br /&gt;
 prepStmt.setString(1, userId);&lt;br /&gt;
 ResultSet rs = prepStmt.executeQuery();&lt;br /&gt;
&lt;br /&gt;
Although Prepared Statements helps in defending against SQL Injection, there are possibilities of SQL Injection attacks through inappropriate usage of Prepared Statements. The example below explains such a scenario where the input variables are passed directly into the Prepared Statement and thereby paving way for SQL Injection attacks. &amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;b&amp;gt;Example: &amp;lt;/b&amp;gt;ps.2&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
String strUserName = request.getParameter(&amp;quot;Txt_UserName&amp;quot;); &lt;br /&gt;
PreparedStatement prepStmt = con.prepareStatement(&amp;quot;SELECT * FROM user WHERE userId = '+strUserName+'&amp;quot;);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
It is highly recommended to use Bind Variables as mentioned in the example ps.1 above. Usage of PreparedStatement with Bind variables defends SQL Injection attacks and improves the performance.&lt;br /&gt;
&lt;br /&gt;
==Stored Procedures==&lt;br /&gt;
==Hibernate==&lt;br /&gt;
According to [http://forum.hibernate.org/viewtopic.php?t=960817&amp;amp;start=0&amp;amp;postdays=0&amp;amp;postorder=asc this forum thread] hibernate uses prepared statements, so it is protected from direct sql injection, but it could still be vulnerable to [http://www.owasp.org/index.php/Interpreter_Injection#ORM_Injection injecting HQL statements].&lt;br /&gt;
&lt;br /&gt;
==Ibatis==&lt;br /&gt;
&lt;br /&gt;
Ibatis creates prepared statements for database access.&lt;br /&gt;
However, SQL injection is possible in Ibatis if the $$ variable replacement syntax is used.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Vulnerable: &amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;select id=“vuln&amp;quot; resultMap=“myResultMap”&amp;gt; select * from table where id = &amp;lt;b&amp;gt;$&amp;lt;/b&amp;gt;value&amp;lt;b&amp;gt;$&amp;lt;/b&amp;gt;&amp;lt;/select&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
The above query is called as follows:&lt;br /&gt;
 MyBean b = (MyBean)sqlMap.queryForObject(&amp;quot;vuln&amp;quot;, new Integer(1));&lt;br /&gt;
 &lt;br /&gt;
The SQL statement thus created, looks as follows:&lt;br /&gt;
&lt;br /&gt;
select * from table where id = 1&lt;br /&gt;
&lt;br /&gt;
The object passed as parameter is directly fed to the SQL query making it susceptible to SQL injection&amp;lt;br&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;b&amp;gt;Secure: &amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;select id=“vuln&amp;quot; resultMap=“myResultMap”&amp;gt; select * from table where id = &amp;lt;b&amp;gt;#&amp;lt;/b&amp;gt;value&amp;lt;b&amp;gt;#&amp;lt;/b&amp;gt;&amp;lt;/select&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Using this form instead generates the following SQL&lt;br /&gt;
&lt;br /&gt;
select * from table where id = ?&lt;br /&gt;
&lt;br /&gt;
The value of the parameter is sent directly to the driver and not used to modify the SQL statement itself.&amp;lt;br&amp;gt;&lt;br /&gt;
This approach thwarts SQL injection attacks by automatically escaping SQL meta-characters.&lt;br /&gt;
&lt;br /&gt;
==Spring JDBC==&lt;br /&gt;
==EJB 3.0==&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
*[1] [http://research.corsaire.com/whitepapers/060116-a-modular-approach-to-data-validation.pdf A Modular Approach to Data Validation]&lt;br /&gt;
*[2] [http://forum.hibernate.org/viewtopic.php?t=960817&amp;amp;start=0&amp;amp;postdays=0&amp;amp;postorder=asc&amp;amp;highlight= Topic: does Hibernate guard against SQL injection?]&lt;br /&gt;
&lt;br /&gt;
[[Category:OWASP Java Project]]&lt;/div&gt;</summary>
		<author><name>Stephendv</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Preventing_SQL_Injection_in_Java&amp;diff=24439</id>
		<title>Preventing SQL Injection in Java</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Preventing_SQL_Injection_in_Java&amp;diff=24439"/>
				<updated>2008-01-14T16:28:30Z</updated>
		
		<summary type="html">&lt;p&gt;Stephendv: /* Hibernate */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Overview==&lt;br /&gt;
As the name implies, SQL injection vulnerabilities allow an attacker to inject (or execute) SQL commands within an application.  It is one of the most wide spread and dangerous application vulnerability.  The CLASP project provides a good overview of [[SQL injection]].&lt;br /&gt;
===Example of SQL injection===&lt;br /&gt;
The following Java servlet code, used to perform a login function, illustrates the vulnerability by accepting user input without performing adequate input validation or escaping meta-characters:&lt;br /&gt;
 conn = pool.getConnection( );&lt;br /&gt;
 String sql = &amp;quot;select * from user where username='&amp;quot; + username +&amp;quot;' and password='&amp;quot; + password + &amp;quot;'&amp;quot;;&lt;br /&gt;
 stmt = conn.createStatement();&lt;br /&gt;
 rs = stmt.executeQuery(sql);&lt;br /&gt;
 if (rs.next()) {&lt;br /&gt;
 loggedIn = true;&lt;br /&gt;
 	out.println(&amp;quot;Successfully logged in&amp;quot;);&lt;br /&gt;
 } else {&lt;br /&gt;
 	out.println(&amp;quot;Username and/or password not recognized&amp;quot;);&lt;br /&gt;
 }&lt;br /&gt;
It is possible for attackers to provide a username containing SQL meta-characters that subvert the intended function of the SQL statement.  For example, by providing a username of:&lt;br /&gt;
 admin' OR '1'='1&lt;br /&gt;
and a blank password, the generated SQL statement becomes:&lt;br /&gt;
 select * from user where username='admin' OR '1'='1' and password=' '&lt;br /&gt;
This allows an attacker to log in to the site without supplying a password, since the ‘OR’ expression is always true.  Using the same technique attackers can inject other SQL commands which could extract, modify or delete data within the database.&lt;br /&gt;
===Attack techniques===&lt;br /&gt;
For more information on SQL injection attacks see:&lt;br /&gt;
* http://www.spidynamics.com/papers/SQLInjectionWhitePaper.pdf&lt;br /&gt;
* http://www.nextgenss.com/papers/advanced_sql_injection.pdf&lt;br /&gt;
* http://www.appsecinc.com/presentations/Manipulating_SQL_Server_Using_SQL_Injection.pdf &lt;br /&gt;
==Defence Strategy==&lt;br /&gt;
To prevent SQL injection, a two pronged approach is recommended:&lt;br /&gt;
* Firstly, all data accepted from user input should be thoroughly &amp;lt;b&amp;gt;validated&amp;lt;/b&amp;gt; to ensure that the characters received are part of the set of valid characters for that field;&lt;br /&gt;
* Secondly, all data acted on by SQL commands should be &amp;lt;b&amp;gt;escaped for meta-characters&amp;lt;/b&amp;gt;.&lt;br /&gt;
=== Validating Input ===&lt;br /&gt;
A general security principle which applies itself well to data validation is that of “deny by default” where data is rejected unless it specifically matches the criteria for known good data.  This is also known as a “white list” approach and is the preferred method for performing data validation.  It allows one to define a restricted range for valid data and reject everything that does not fit this set.  The set of valid data should be constrained by:&lt;br /&gt;
* Type – String, integer, unsigned integer, float etc;&lt;br /&gt;
* Length;&lt;br /&gt;
* Set of character – for example, only alphabetic characters [a-zA-Z]*; &lt;br /&gt;
* Format – if appropriate the data could be further constrained by specifying a format, e.g.: \d\d\/\d\d\/\d\d&lt;br /&gt;
* Reasonableness – where possible, values should be compared to expected ranges.  For example, a customer ordering 1000 televisions could be suspicious.&lt;br /&gt;
It is essential that the data validation routines themselves can be trusted, therefore they must be performed on the server side.  Client side validation can be performed as a useful user interface feature, but it must be reinforced by server side validation.&lt;br /&gt;
Where input validation is performed on the server side will depend largely on the frameworks available.  JSF and Struts provide validation functions that are defined in the view layer, while Spring and EJB 3.0 allow validation to be defined in the model.&amp;lt;br&amp;gt; &lt;br /&gt;
Input validation provides the first line of defence in preventing dangerous characters from being processed by the application.&lt;br /&gt;
But even if data is constrained in this way it does not solve the meta-character problem: How should the application handle meta-characters that are defined as valid data, but cannot be used in certain processing contexts?  For example, the single quote (') character may be a valid character in a surname, but this character cannot simply be used in a string that is used to form an SQL statement.  The OWASP Guide project has more information on [[Data Validation]].&lt;br /&gt;
=== Escaping Meta-characters ===&lt;br /&gt;
All data access techniques provide some means for escaping SQL meta-characters automatically.  The important thing to remember is to &amp;lt;b&amp;gt;never construct SQL statements using string concatenation of unchecked input values.&amp;lt;/b&amp;gt;  The following sections detail how to perform input validation and meta-character escaping using popular data access technologies.&lt;br /&gt;
==Prepared Statements==&lt;br /&gt;
Variables passed as arguments to prepared statements will automatically be escaped by the JDBC driver.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;b&amp;gt;Example: &amp;lt;/b&amp;gt;ps.1&amp;lt;br&amp;gt;&lt;br /&gt;
 String selectStatement = &amp;quot;SELECT * FROM User WHERE userId = ? &amp;quot;;&lt;br /&gt;
 PreparedStatement prepStmt = con.prepareStatement(selectStatement);&lt;br /&gt;
 prepStmt.setString(1, userId);&lt;br /&gt;
 ResultSet rs = prepStmt.executeQuery();&lt;br /&gt;
&lt;br /&gt;
Although Prepared Statements helps in defending against SQL Injection, there are possibilities of SQL Injection attacks through inappropriate usage of Prepared Statements. The example below explains such a scenario where the input variables are passed directly into the Prepared Statement and thereby paving way for SQL Injection attacks. &amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;b&amp;gt;Example: &amp;lt;/b&amp;gt;ps.2&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
String strUserName = request.getParameter(&amp;quot;Txt_UserName&amp;quot;); &lt;br /&gt;
PreparedStatement prepStmt = con.prepareStatement(&amp;quot;SELECT * FROM user WHERE userId = '+strUserName+'&amp;quot;);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
It is highly recommended to use Bind Variables as mentioned in the example ps.1 above. Usage of PreparedStatement with Bind variables defends SQL Injection attacks and improves the performance.&lt;br /&gt;
&lt;br /&gt;
==Stored Procedures==&lt;br /&gt;
==Hibernate==&lt;br /&gt;
According to [http://forum.hibernate.org/viewtopic.php?t=960817&amp;amp;start=0&amp;amp;postdays=0&amp;amp;postorder=asc this forum thread] hibernate uses prepared statements, so it is protected from direct sql injection, but it could still be vulnerable to [http://www.owasp.org/index.php/Interpreter_Injection#ORM_Injection injecting HQL statements].&lt;br /&gt;
&lt;br /&gt;
==Ibatis==&lt;br /&gt;
&lt;br /&gt;
Ibatis creates prepared statements for database access.&lt;br /&gt;
However, SQL injection is possible in Ibatis if the $$ variable replacement syntax is used.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Vulnerable: &amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;select id=“vuln&amp;quot; resultMap=“myResultMap”&amp;gt; select * from table where id = &amp;lt;b&amp;gt;$&amp;lt;/b&amp;gt;value&amp;lt;b&amp;gt;$&amp;lt;/b&amp;gt;&amp;lt;/select&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
The above query is called as follows:&lt;br /&gt;
 MyBean b = (MyBean)sqlMap.queryForObject(&amp;quot;vuln&amp;quot;, new Integer(1));&lt;br /&gt;
 &lt;br /&gt;
The SQL statement thus created, looks as follows:&lt;br /&gt;
&lt;br /&gt;
select * from table where id = 1&lt;br /&gt;
&lt;br /&gt;
The object passed as parameter is directly fed to the SQL query making it susceptible to SQL injection&amp;lt;br&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;b&amp;gt;Secure: &amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;select id=“vuln&amp;quot; resultMap=“myResultMap”&amp;gt; select * from table where id = &amp;lt;b&amp;gt;#&amp;lt;/b&amp;gt;value&amp;lt;b&amp;gt;#&amp;lt;/b&amp;gt;&amp;lt;/select&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Using this form instead generates the following SQL&lt;br /&gt;
&lt;br /&gt;
select * from table where id = ?&lt;br /&gt;
&lt;br /&gt;
The value of the parameter is sent directly to the driver and not used to modify the SQL statement itself.&amp;lt;br&amp;gt;&lt;br /&gt;
This approach thwarts SQL injection attacks by automatically escaping SQL meta-characters.&lt;br /&gt;
&lt;br /&gt;
==Spring JDBC==&lt;br /&gt;
==EJB 3.0==&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
*[1] [http://research.corsaire.com/whitepapers/060116-a-modular-approach-to-data-validation.pdf A Modular Approach to Data Validation]&lt;br /&gt;
*[2] [http://forum.hibernate.org/viewtopic.php?t=960817&amp;amp;start=0&amp;amp;postdays=0&amp;amp;postorder=asc&amp;amp;highlight= Topic: does Hibernate guard against SQL injection?]&lt;br /&gt;
&lt;br /&gt;
[[Category:OWASP Java Project]]&lt;/div&gt;</summary>
		<author><name>Stephendv</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Preventing_LDAP_Injection_in_Java&amp;diff=24438</id>
		<title>Preventing LDAP Injection in Java</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Preventing_LDAP_Injection_in_Java&amp;diff=24438"/>
				<updated>2008-01-14T16:24:49Z</updated>
		
		<summary type="html">&lt;p&gt;Stephendv: /* Status */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Status==&lt;br /&gt;
'''Broken code!  Needs to be corrected.'''&lt;br /&gt;
&lt;br /&gt;
==Approach==&lt;br /&gt;
The best way to prevent LDAP injection is to use a positive validation scheme for ensuring that the data going into your queries doesn't contain any attacks. You can read more in [[:Category:OWASP Guide Project|the OWASP Guide]] about input validation.&lt;br /&gt;
&lt;br /&gt;
However, in some cases, it is necessary to include special characters in input that is passed into an LDAP query.  In this case, using escaping can prevent the LDAP interpreter from thinking those special characters are actually LDAP query.  Rather, the encoding lets the interpreter treat those special characters as data.&lt;br /&gt;
&lt;br /&gt;
Here are a few methods for escaping certain meta-characters in LDAP queries. Both the distinguished name (DN) and the search filter have their own sets of meta-characters.  In the case of Java, it is also necessary to escape any JNDI meta-characters, since java uses JNDI to perform LDAP queries.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The examples below present Java methods that could be used to perform this escaping:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;em&amp;gt;Note: This is untested code&amp;lt;/em&amp;gt; --[[User:Stephendv|Stephendv]] 05:08, 10 July 2006 (EDT)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;em&amp;gt;The backslash replacement and &amp;quot;,&amp;quot; are not working&amp;lt;/em&amp;gt; --[[User:Thierry.deleeuw|Thierry.deleeuw]] 17:11, 29 April 2007 (EDT)&lt;br /&gt;
&lt;br /&gt;
  public String escapeDN (String name) {&lt;br /&gt;
        //From RFC 2253 and the / character for JNDI&lt;br /&gt;
        final char[] META_CHARS = {'+', '&amp;quot;', '&amp;lt;', '&amp;gt;', ';', '/'};&lt;br /&gt;
        String escapedStr = new String(name);&lt;br /&gt;
        //Backslash is both a Java and an LDAP escape character, so escape it first&lt;br /&gt;
        escapedStr = escapedStr.replaceAll(&amp;quot;\\\\&amp;quot;,&amp;quot;\\\\&amp;quot;); &lt;br /&gt;
        //Positional characters - see RFC 2253&lt;br /&gt;
        escapedStr = escapedStr.replaceAll(&amp;quot;^#&amp;quot;,&amp;quot;\\\\#&amp;quot;);&lt;br /&gt;
        escapedStr = escapedStr.replaceAll(&amp;quot;^ | $&amp;quot;,&amp;quot;\\\\ &amp;quot;);&lt;br /&gt;
        for (int i=0;i &amp;lt; META_CHARS.length;i++) {&lt;br /&gt;
            escapedStr = escapedStr.replaceAll(&amp;quot;\\&amp;quot;+META_CHARS[i],&amp;quot;\\\\&amp;quot; + META_CHARS[i]);&lt;br /&gt;
        }&lt;br /&gt;
        return escapedStr;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
Note, that the backslash character is a Java String literal and a regular expression escape character.&lt;br /&gt;
    &lt;br /&gt;
   public String escapeSearchFilter (String filter) {&lt;br /&gt;
        //From RFC 2254&lt;br /&gt;
        String escapedStr = new String(filter);&lt;br /&gt;
        escapedStr = escapedStr.replaceAll(&amp;quot;\\\\&amp;quot;,&amp;quot;\\\\5c&amp;quot;);&lt;br /&gt;
        escapedStr = escapedStr.replaceAll(&amp;quot;\\*&amp;quot;,&amp;quot;\\\\2a&amp;quot;);&lt;br /&gt;
        escapedStr = escapedStr.replaceAll(&amp;quot;\\(&amp;quot;,&amp;quot;\\\\28&amp;quot;);&lt;br /&gt;
        escapedStr = escapedStr.replaceAll(&amp;quot;\\)&amp;quot;,&amp;quot;\\\\29&amp;quot;);&lt;br /&gt;
        escapedStr = escapedStr.replaceAll(&amp;quot;\\&amp;quot;+Character.toString('\u0000'), &amp;quot;\\\\00&amp;quot;);&lt;br /&gt;
        return escapedStr;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
Optimized version of the previous code (about 8 times faster for escaping LDAP search and 13 times for escapeDN on my PC).--[[User:Thierry.deleeuw|Thierry.deleeuw]] 17:11, 29 April 2007 (EDT)&lt;br /&gt;
    public static String escapeDN(String name) {&lt;br /&gt;
        StringBuffer sb = new StringBuffer(); // If using JDK &amp;gt;= 1.5 consider using StringBuilder&lt;br /&gt;
        if ((name.length() &amp;gt; 0) &amp;amp;&amp;amp; ((name.charAt(0) == ' ') || (name.charAt(0) == '#'))) {&lt;br /&gt;
            sb.append('\\'); // add the leading backslash if needed&lt;br /&gt;
        }&lt;br /&gt;
        for (int i = 0; i &amp;lt; name.length(); i++) {&lt;br /&gt;
            char curChar = name.charAt(i);&lt;br /&gt;
            switch (curChar) {&lt;br /&gt;
                case '\\':&lt;br /&gt;
                    sb.append(&amp;quot;\\\\&amp;quot;);&lt;br /&gt;
                    break;&lt;br /&gt;
                case ',':&lt;br /&gt;
                    sb.append(&amp;quot;\\,&amp;quot;);&lt;br /&gt;
                    break;&lt;br /&gt;
                case '+':&lt;br /&gt;
                    sb.append(&amp;quot;\\+&amp;quot;);&lt;br /&gt;
                    break;&lt;br /&gt;
                case '&amp;quot;':&lt;br /&gt;
                    sb.append(&amp;quot;\\\&amp;quot;&amp;quot;);&lt;br /&gt;
                    break;&lt;br /&gt;
                case '&amp;lt;':&lt;br /&gt;
                    sb.append(&amp;quot;\\&amp;lt;&amp;quot;);&lt;br /&gt;
                    break;&lt;br /&gt;
                case '&amp;gt;':&lt;br /&gt;
                    sb.append(&amp;quot;\\&amp;gt;&amp;quot;);&lt;br /&gt;
                    break;&lt;br /&gt;
                case ';':&lt;br /&gt;
                    sb.append(&amp;quot;\\;&amp;quot;);&lt;br /&gt;
                    break;&lt;br /&gt;
                default:&lt;br /&gt;
                    sb.append(curChar);&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        if ((name.length() &amp;gt; 1) &amp;amp;&amp;amp; (name.charAt(name.length() - 1) == ' ')) {&lt;br /&gt;
            sb.insert(sb.length() - 1, '\\'); // add the trailing backslash if needed&lt;br /&gt;
        }&lt;br /&gt;
        return sb.toString();&lt;br /&gt;
    }&lt;br /&gt;
    public static final String escapeLDAPSearchFilter(String filter) {&lt;br /&gt;
        StringBuffer sb = new StringBuffer(); // If using JDK &amp;gt;= 1.5 consider using StringBuilder&lt;br /&gt;
        for (int i = 0; i &amp;lt; filter.length(); i++) {&lt;br /&gt;
            char curChar = filter.charAt(i);&lt;br /&gt;
            switch (curChar) {&lt;br /&gt;
                case '\\':&lt;br /&gt;
                    sb.append(&amp;quot;\\5c&amp;quot;);&lt;br /&gt;
                    break;&lt;br /&gt;
                case '*':&lt;br /&gt;
                    sb.append(&amp;quot;\\2a&amp;quot;);&lt;br /&gt;
                    break;&lt;br /&gt;
                case '(':&lt;br /&gt;
                    sb.append(&amp;quot;\\28&amp;quot;);&lt;br /&gt;
                    break;&lt;br /&gt;
                case ')':&lt;br /&gt;
                    sb.append(&amp;quot;\\29&amp;quot;);&lt;br /&gt;
                    break;&lt;br /&gt;
                case '\u0000': &lt;br /&gt;
                    sb.append(&amp;quot;\\00&amp;quot;); &lt;br /&gt;
                    break;&lt;br /&gt;
                default:&lt;br /&gt;
                    sb.append(curChar);&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        return sb.toString();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
Test class:&lt;br /&gt;
&lt;br /&gt;
        //escapeDN&lt;br /&gt;
        assertEquals(&amp;quot;No special characters to escape&amp;quot;, &amp;quot;Helloé&amp;quot;, escapeDN(&amp;quot;Helloé&amp;quot;));&lt;br /&gt;
        assertEquals(&amp;quot;leading #&amp;quot;, &amp;quot;\\# Helloé&amp;quot;, escapeDN(&amp;quot;# Helloé&amp;quot;));&lt;br /&gt;
        assertEquals(&amp;quot;leading space&amp;quot;, &amp;quot;\\ Helloé&amp;quot;, escapeDN(&amp;quot; Helloé&amp;quot;));&lt;br /&gt;
        assertEquals(&amp;quot;trailing space&amp;quot;, &amp;quot;Helloé\\ &amp;quot;, escapeDN(&amp;quot;Helloé &amp;quot;));&lt;br /&gt;
        assertEquals(&amp;quot;only 3 spaces&amp;quot;, &amp;quot;\\  \\ &amp;quot;, escapeDN(&amp;quot;   &amp;quot;));&lt;br /&gt;
        assertEquals(&amp;quot;Christmas Tree DN&amp;quot;, &amp;quot;\\ Hello\\\\ \\+ \\, \\\&amp;quot;World\\\&amp;quot; \\;\\ &amp;quot;, Test.escapeDN(&amp;quot; Hello\\ + , \&amp;quot;World\&amp;quot; ; &amp;quot;));&lt;br /&gt;
&lt;br /&gt;
        assertEquals(&amp;quot;No special characters to escape&amp;quot;, &amp;quot;Hi This is a test #çà&amp;quot;, SecTool.escapeLDAPSearchFilter(&amp;quot;Hi This is a test #çà&amp;quot;));&lt;br /&gt;
        assertEquals(&amp;quot;LDAP Christams Tree&amp;quot;, &amp;quot;Hi \\28This\\29 = is \\2a a \\5c test # ç à ô&amp;quot;, SecTool.escapeLDAPSearchFilter(&amp;quot;Hi (This) = is * a \\ test # ç à ô&amp;quot;));&lt;br /&gt;
&lt;br /&gt;
[[Category:OWASP Java Project]]&lt;/div&gt;</summary>
		<author><name>Stephendv</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Preventing_LDAP_Injection_in_Java&amp;diff=24437</id>
		<title>Preventing LDAP Injection in Java</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Preventing_LDAP_Injection_in_Java&amp;diff=24437"/>
				<updated>2008-01-14T16:05:54Z</updated>
		
		<summary type="html">&lt;p&gt;Stephendv: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Status==&lt;br /&gt;
Broken code&lt;br /&gt;
&lt;br /&gt;
==Approach==&lt;br /&gt;
The best way to prevent LDAP injection is to use a positive validation scheme for ensuring that the data going into your queries doesn't contain any attacks. You can read more in [[:Category:OWASP Guide Project|the OWASP Guide]] about input validation.&lt;br /&gt;
&lt;br /&gt;
However, in some cases, it is necessary to include special characters in input that is passed into an LDAP query.  In this case, using escaping can prevent the LDAP interpreter from thinking those special characters are actually LDAP query.  Rather, the encoding lets the interpreter treat those special characters as data.&lt;br /&gt;
&lt;br /&gt;
Here are a few methods for escaping certain meta-characters in LDAP queries. Both the distinguished name (DN) and the search filter have their own sets of meta-characters.  In the case of Java, it is also necessary to escape any JNDI meta-characters, since java uses JNDI to perform LDAP queries.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The examples below present Java methods that could be used to perform this escaping:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;em&amp;gt;Note: This is untested code&amp;lt;/em&amp;gt; --[[User:Stephendv|Stephendv]] 05:08, 10 July 2006 (EDT)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;em&amp;gt;The backslash replacement and &amp;quot;,&amp;quot; are not working&amp;lt;/em&amp;gt; --[[User:Thierry.deleeuw|Thierry.deleeuw]] 17:11, 29 April 2007 (EDT)&lt;br /&gt;
&lt;br /&gt;
  public String escapeDN (String name) {&lt;br /&gt;
        //From RFC 2253 and the / character for JNDI&lt;br /&gt;
        final char[] META_CHARS = {'+', '&amp;quot;', '&amp;lt;', '&amp;gt;', ';', '/'};&lt;br /&gt;
        String escapedStr = new String(name);&lt;br /&gt;
        //Backslash is both a Java and an LDAP escape character, so escape it first&lt;br /&gt;
        escapedStr = escapedStr.replaceAll(&amp;quot;\\\\&amp;quot;,&amp;quot;\\\\&amp;quot;); &lt;br /&gt;
        //Positional characters - see RFC 2253&lt;br /&gt;
        escapedStr = escapedStr.replaceAll(&amp;quot;^#&amp;quot;,&amp;quot;\\\\#&amp;quot;);&lt;br /&gt;
        escapedStr = escapedStr.replaceAll(&amp;quot;^ | $&amp;quot;,&amp;quot;\\\\ &amp;quot;);&lt;br /&gt;
        for (int i=0;i &amp;lt; META_CHARS.length;i++) {&lt;br /&gt;
            escapedStr = escapedStr.replaceAll(&amp;quot;\\&amp;quot;+META_CHARS[i],&amp;quot;\\\\&amp;quot; + META_CHARS[i]);&lt;br /&gt;
        }&lt;br /&gt;
        return escapedStr;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
Note, that the backslash character is a Java String literal and a regular expression escape character.&lt;br /&gt;
    &lt;br /&gt;
   public String escapeSearchFilter (String filter) {&lt;br /&gt;
        //From RFC 2254&lt;br /&gt;
        String escapedStr = new String(filter);&lt;br /&gt;
        escapedStr = escapedStr.replaceAll(&amp;quot;\\\\&amp;quot;,&amp;quot;\\\\5c&amp;quot;);&lt;br /&gt;
        escapedStr = escapedStr.replaceAll(&amp;quot;\\*&amp;quot;,&amp;quot;\\\\2a&amp;quot;);&lt;br /&gt;
        escapedStr = escapedStr.replaceAll(&amp;quot;\\(&amp;quot;,&amp;quot;\\\\28&amp;quot;);&lt;br /&gt;
        escapedStr = escapedStr.replaceAll(&amp;quot;\\)&amp;quot;,&amp;quot;\\\\29&amp;quot;);&lt;br /&gt;
        escapedStr = escapedStr.replaceAll(&amp;quot;\\&amp;quot;+Character.toString('\u0000'), &amp;quot;\\\\00&amp;quot;);&lt;br /&gt;
        return escapedStr;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
Optimized version of the previous code (about 8 times faster for escaping LDAP search and 13 times for escapeDN on my PC).--[[User:Thierry.deleeuw|Thierry.deleeuw]] 17:11, 29 April 2007 (EDT)&lt;br /&gt;
    public static String escapeDN(String name) {&lt;br /&gt;
        StringBuffer sb = new StringBuffer(); // If using JDK &amp;gt;= 1.5 consider using StringBuilder&lt;br /&gt;
        if ((name.length() &amp;gt; 0) &amp;amp;&amp;amp; ((name.charAt(0) == ' ') || (name.charAt(0) == '#'))) {&lt;br /&gt;
            sb.append('\\'); // add the leading backslash if needed&lt;br /&gt;
        }&lt;br /&gt;
        for (int i = 0; i &amp;lt; name.length(); i++) {&lt;br /&gt;
            char curChar = name.charAt(i);&lt;br /&gt;
            switch (curChar) {&lt;br /&gt;
                case '\\':&lt;br /&gt;
                    sb.append(&amp;quot;\\\\&amp;quot;);&lt;br /&gt;
                    break;&lt;br /&gt;
                case ',':&lt;br /&gt;
                    sb.append(&amp;quot;\\,&amp;quot;);&lt;br /&gt;
                    break;&lt;br /&gt;
                case '+':&lt;br /&gt;
                    sb.append(&amp;quot;\\+&amp;quot;);&lt;br /&gt;
                    break;&lt;br /&gt;
                case '&amp;quot;':&lt;br /&gt;
                    sb.append(&amp;quot;\\\&amp;quot;&amp;quot;);&lt;br /&gt;
                    break;&lt;br /&gt;
                case '&amp;lt;':&lt;br /&gt;
                    sb.append(&amp;quot;\\&amp;lt;&amp;quot;);&lt;br /&gt;
                    break;&lt;br /&gt;
                case '&amp;gt;':&lt;br /&gt;
                    sb.append(&amp;quot;\\&amp;gt;&amp;quot;);&lt;br /&gt;
                    break;&lt;br /&gt;
                case ';':&lt;br /&gt;
                    sb.append(&amp;quot;\\;&amp;quot;);&lt;br /&gt;
                    break;&lt;br /&gt;
                default:&lt;br /&gt;
                    sb.append(curChar);&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        if ((name.length() &amp;gt; 1) &amp;amp;&amp;amp; (name.charAt(name.length() - 1) == ' ')) {&lt;br /&gt;
            sb.insert(sb.length() - 1, '\\'); // add the trailing backslash if needed&lt;br /&gt;
        }&lt;br /&gt;
        return sb.toString();&lt;br /&gt;
    }&lt;br /&gt;
    public static final String escapeLDAPSearchFilter(String filter) {&lt;br /&gt;
        StringBuffer sb = new StringBuffer(); // If using JDK &amp;gt;= 1.5 consider using StringBuilder&lt;br /&gt;
        for (int i = 0; i &amp;lt; filter.length(); i++) {&lt;br /&gt;
            char curChar = filter.charAt(i);&lt;br /&gt;
            switch (curChar) {&lt;br /&gt;
                case '\\':&lt;br /&gt;
                    sb.append(&amp;quot;\\5c&amp;quot;);&lt;br /&gt;
                    break;&lt;br /&gt;
                case '*':&lt;br /&gt;
                    sb.append(&amp;quot;\\2a&amp;quot;);&lt;br /&gt;
                    break;&lt;br /&gt;
                case '(':&lt;br /&gt;
                    sb.append(&amp;quot;\\28&amp;quot;);&lt;br /&gt;
                    break;&lt;br /&gt;
                case ')':&lt;br /&gt;
                    sb.append(&amp;quot;\\29&amp;quot;);&lt;br /&gt;
                    break;&lt;br /&gt;
                case '\u0000': &lt;br /&gt;
                    sb.append(&amp;quot;\\00&amp;quot;); &lt;br /&gt;
                    break;&lt;br /&gt;
                default:&lt;br /&gt;
                    sb.append(curChar);&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        return sb.toString();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
Test class:&lt;br /&gt;
&lt;br /&gt;
        //escapeDN&lt;br /&gt;
        assertEquals(&amp;quot;No special characters to escape&amp;quot;, &amp;quot;Helloé&amp;quot;, escapeDN(&amp;quot;Helloé&amp;quot;));&lt;br /&gt;
        assertEquals(&amp;quot;leading #&amp;quot;, &amp;quot;\\# Helloé&amp;quot;, escapeDN(&amp;quot;# Helloé&amp;quot;));&lt;br /&gt;
        assertEquals(&amp;quot;leading space&amp;quot;, &amp;quot;\\ Helloé&amp;quot;, escapeDN(&amp;quot; Helloé&amp;quot;));&lt;br /&gt;
        assertEquals(&amp;quot;trailing space&amp;quot;, &amp;quot;Helloé\\ &amp;quot;, escapeDN(&amp;quot;Helloé &amp;quot;));&lt;br /&gt;
        assertEquals(&amp;quot;only 3 spaces&amp;quot;, &amp;quot;\\  \\ &amp;quot;, escapeDN(&amp;quot;   &amp;quot;));&lt;br /&gt;
        assertEquals(&amp;quot;Christmas Tree DN&amp;quot;, &amp;quot;\\ Hello\\\\ \\+ \\, \\\&amp;quot;World\\\&amp;quot; \\;\\ &amp;quot;, Test.escapeDN(&amp;quot; Hello\\ + , \&amp;quot;World\&amp;quot; ; &amp;quot;));&lt;br /&gt;
&lt;br /&gt;
        assertEquals(&amp;quot;No special characters to escape&amp;quot;, &amp;quot;Hi This is a test #çà&amp;quot;, SecTool.escapeLDAPSearchFilter(&amp;quot;Hi This is a test #çà&amp;quot;));&lt;br /&gt;
        assertEquals(&amp;quot;LDAP Christams Tree&amp;quot;, &amp;quot;Hi \\28This\\29 = is \\2a a \\5c test # ç à ô&amp;quot;, SecTool.escapeLDAPSearchFilter(&amp;quot;Hi (This) = is * a \\ test # ç à ô&amp;quot;));&lt;br /&gt;
&lt;br /&gt;
[[Category:OWASP Java Project]]&lt;/div&gt;</summary>
		<author><name>Stephendv</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=PDF_Attack_Filter_for_Java_EE&amp;diff=24435</id>
		<title>PDF Attack Filter for Java EE</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=PDF_Attack_Filter_for_Java_EE&amp;diff=24435"/>
				<updated>2008-01-14T15:57:18Z</updated>
		
		<summary type="html">&lt;p&gt;Stephendv: /* Overview */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Status==&lt;br /&gt;
Released 24/4/2007&lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
&lt;br /&gt;
This is a filter to block XSS attacks on PDF files served by Java EE applications. The details of the attack are discussed [http://www.gnucitizen.org/blog/danger-danger-danger/ elsewhere].  This filter implements a simple algorithm suggested by Amit Klein.  We've placed this software in the public domain to make it easy for anyone to use for any purpose. Please let us know if you're using it!&lt;br /&gt;
&lt;br /&gt;
As an alternative to this, you could change MIME type or the Content-Disposition Header as [http://www.adobe.com/support/security/advisories/apsa07-02.html Adobe security advisory]&lt;br /&gt;
&lt;br /&gt;
==Approach==&lt;br /&gt;
&lt;br /&gt;
This attack relies on having some javascript in an anchor after the url like this: http://www.site.com/file.pdf#blah=javascript:alert(document.cookie);&lt;br /&gt;
&lt;br /&gt;
So the idea is to strip off the anchor. Unfortunately for us, the browser doesn't send the anchor along with the HTTP request. So we can't just strip it off.&lt;br /&gt;
&lt;br /&gt;
Therefore, we're going to use a redirect to steer the browser to a link without the anchor containing the attack.  Well, actually it turns out that we have to overwrite the anchor with something else, so we're going to use &amp;quot;#a&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
But there's one last problem to overcome. Since the browser doesn't send the anchor, the new request will look exactly like the request generated by the redirect.  With no way of telling the original request from the one generated by our redirect, we'll create an infinite loop.&lt;br /&gt;
&lt;br /&gt;
So to differentiate them, we're going to add a temporary token to the URL in the redirect, which we'll verify when it arrives.  We don't want an attacker forging this token, so we're going to encrypt the user's source IP address along with a timestamp. If a request shows up for the PDF file without a valid token, we'll reject it. Or actually, we can force it to be saved to disk, thus preventing the attack from working.&lt;br /&gt;
&lt;br /&gt;
This way, only an attacker from the same IP address who can trick you into clicking a link within 10 seconds of creating it can attack you. Not perfect, but certainly raises the bar quite a bit.&lt;br /&gt;
&lt;br /&gt;
==Download==&lt;br /&gt;
&lt;br /&gt;
The source code (one file) and the compiled class file are in a single zip file.&lt;br /&gt;
&lt;br /&gt;
'''[http://www.owasp.org/images/5/59/PDFAttackFilter.zip DOWNLOAD]'''&lt;br /&gt;
&lt;br /&gt;
==Setup==&lt;br /&gt;
&lt;br /&gt;
The first step is to add the filter to our application. All we have to do is put the PDFAttackFilter class on our application's classpath, probably by putting it in the classes folder in WEB-INF. The class file should be in a folder structure that matches the package (org -&amp;gt; owasp -&amp;gt; filters -&amp;gt; PDFAttackFilter).  You can extract the class file from the zip file.&lt;br /&gt;
&lt;br /&gt;
Then we just have to add the following to our web.xml. You should paste this in right above your servlet definitions. You'll want to change the mapping so that it only applies to URL's that serve a PDF file. You could use *.pdf, but you may have servlets that stream PDF files that down't end in .pdf.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
	&amp;lt;filter&amp;gt;&lt;br /&gt;
	     &amp;lt;filter-name&amp;gt;PDFAttackFilter&amp;lt;/filter-name&amp;gt;&lt;br /&gt;
	     &amp;lt;filter-class&amp;gt;org.owasp.filters.PDFAttackFilter&amp;lt;/filter-class&amp;gt;&lt;br /&gt;
             &amp;lt;init-param&amp;gt;&lt;br /&gt;
                 &amp;lt;param-name&amp;gt;timeoutSeconds&amp;lt;/param-name&amp;gt;&lt;br /&gt;
                 &amp;lt;param-value&amp;gt;1&amp;lt;/param-value&amp;gt;&lt;br /&gt;
             &amp;lt;/init-param&amp;gt;&lt;br /&gt;
             &amp;lt;init-param&amp;gt;&lt;br /&gt;
                 &amp;lt;param-name&amp;gt;encryptionPassword&amp;lt;/param-name&amp;gt;&lt;br /&gt;
                 &amp;lt;param-value&amp;gt;password&amp;lt;/param-value&amp;gt;&lt;br /&gt;
             &amp;lt;/init-param&amp;gt;&lt;br /&gt;
             &amp;lt;init-param&amp;gt;&lt;br /&gt;
                 &amp;lt;param-name&amp;gt;PDFAttackTokenName&amp;lt;/param-name&amp;gt;&lt;br /&gt;
                 &amp;lt;param-value&amp;gt;PDFAttackToken&amp;lt;/param-value&amp;gt;&lt;br /&gt;
             &amp;lt;/init-param&amp;gt;&lt;br /&gt;
	  &amp;lt;/filter&amp;gt;&lt;br /&gt;
	       &lt;br /&gt;
	  &amp;lt;filter-mapping&amp;gt;&lt;br /&gt;
	     &amp;lt;filter-name&amp;gt;PDFAttackFilter&amp;lt;/filter-name&amp;gt;&lt;br /&gt;
	     &amp;lt;url-pattern&amp;gt;/*&amp;lt;/url-pattern&amp;gt;&lt;br /&gt;
	  &amp;lt;/filter-mapping&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Depending on your application, it may be difficult to map all the URLs that lead to PDF files. You can map multiple url-patterns to the filter if necessary. In theory, it might be possible to send the redirect only if a response with content-type application/pdf. Then you could map the filter to apply to ALL requests. If there is demand for this feature, let us know.&lt;br /&gt;
&lt;br /&gt;
==Source Code==&lt;br /&gt;
&lt;br /&gt;
This code has been only minimally tested. Please help us verify the approach and the implementation used here.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/**&lt;br /&gt;
 *  Software published by the Open Web Application Security Project (http://www.owasp.org)&lt;br /&gt;
 *  This software is in the public domain with no warranty.&lt;br /&gt;
 *&lt;br /&gt;
 * @author     Jeff Williams &amp;lt;a href=&amp;quot;http://www.aspectsecurity.com&amp;quot;&amp;gt;Aspect Security&amp;lt;/a&amp;gt;&lt;br /&gt;
 * @created    January 4, 2007&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
package org.owasp.filters;&lt;br /&gt;
&lt;br /&gt;
import java.io.IOException;&lt;br /&gt;
&lt;br /&gt;
import javax.crypto.Cipher;&lt;br /&gt;
import javax.crypto.SecretKey;&lt;br /&gt;
import javax.crypto.SecretKeyFactory;&lt;br /&gt;
import javax.crypto.spec.PBEParameterSpec;&lt;br /&gt;
import javax.servlet.Filter;&lt;br /&gt;
import javax.servlet.FilterChain;&lt;br /&gt;
import javax.servlet.FilterConfig;&lt;br /&gt;
import javax.servlet.ServletException;&lt;br /&gt;
import javax.servlet.ServletRequest;&lt;br /&gt;
import javax.servlet.ServletResponse;&lt;br /&gt;
import javax.servlet.http.HttpServletRequest;&lt;br /&gt;
import javax.servlet.http.HttpServletResponse;&lt;br /&gt;
&lt;br /&gt;
public class PDFAttackFilter implements Filter &lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
	private static sun.misc.BASE64Decoder decoder = new sun.misc.BASE64Decoder();&lt;br /&gt;
	private static sun.misc.BASE64Encoder encoder = new sun.misc.BASE64Encoder();&lt;br /&gt;
	private static byte[] salt = { (byte) 0x23, (byte) 0x3f, (byte) 0x28, (byte) 0x00, (byte) 0x11, (byte) 0xc2, (byte) 0xd1, (byte) 0xff };&lt;br /&gt;
	private static PBEParameterSpec ps = new PBEParameterSpec( salt, 20 );&lt;br /&gt;
	private static SecretKey secretKey;&lt;br /&gt;
	private static int timeoutSeconds = 10;&lt;br /&gt;
	private static String tokenName = &amp;quot;PDFAttackToken&amp;quot;;&lt;br /&gt;
	&lt;br /&gt;
	&lt;br /&gt;
	public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException&lt;br /&gt;
	{&lt;br /&gt;
		HttpServletRequest req = (HttpServletRequest)request;&lt;br /&gt;
		HttpServletResponse res = (HttpServletResponse)response;&lt;br /&gt;
		String token = req.getParameter( tokenName );&lt;br /&gt;
&lt;br /&gt;
		try&lt;br /&gt;
		{&lt;br /&gt;
&lt;br /&gt;
			// IF the URL doesn't contain token, then:&lt;br /&gt;
			//  calculate X=encrypt_with_key(server_time, client_IP_address)&lt;br /&gt;
			//  redirect to file.pdf?token=X&lt;br /&gt;
			//  add #a to the end of the url to eliminate any remaining anchors&lt;br /&gt;
			&lt;br /&gt;
			if ( token == null )&lt;br /&gt;
			{&lt;br /&gt;
				String etoken = createToken( req );&lt;br /&gt;
				String base = req.getRequestURI();&lt;br /&gt;
				String querystring = req.getQueryString();&lt;br /&gt;
				if ( querystring != null ) base += &amp;quot;?&amp;quot; + req.getQueryString();&lt;br /&gt;
				String appender = base.contains( &amp;quot;?&amp;quot; ) ? &amp;quot;&amp;amp;&amp;quot; : &amp;quot;?&amp;quot;;&lt;br /&gt;
				String url = base + appender + tokenName + &amp;quot;=&amp;quot; + etoken + &amp;quot;#a&amp;quot;;&lt;br /&gt;
				res.sendRedirect( res.encodeRedirectURL( url ) );&lt;br /&gt;
				return;&lt;br /&gt;
			}&lt;br /&gt;
	&lt;br /&gt;
			// ELSE IF the URL contains token, then:	&lt;br /&gt;
			// if decrypt(token_query).IP_address==client_IP_address and&lt;br /&gt;
			// decrypt(token_query).time&amp;gt;server_time-10sec&lt;br /&gt;
			//  serve the PDF resource as an in-line resource&lt;br /&gt;
			&lt;br /&gt;
			if ( checkToken( token, req ) )&lt;br /&gt;
			{&lt;br /&gt;
				chain.doFilter(req, res);&lt;br /&gt;
				return;&lt;br /&gt;
			}&lt;br /&gt;
	&lt;br /&gt;
			// ELSE IF the token doesn't match, then:&lt;br /&gt;
			// serve the PDF resource as a &amp;quot;save to disk&amp;quot; resource via a proper&lt;br /&gt;
			// choice of the Content-Type header (and/or an attachment, via&lt;br /&gt;
			// Content-Disposition).&lt;br /&gt;
&lt;br /&gt;
			res.addHeader(&amp;quot;Content-Disposition&amp;quot;, &amp;quot;Attachment&amp;quot; );				&lt;br /&gt;
			res.setContentType( &amp;quot;application/octet&amp;quot; );  // may be overwritten&lt;br /&gt;
			chain.doFilter(req, res);&lt;br /&gt;
		}&lt;br /&gt;
		catch( Exception e )&lt;br /&gt;
		{&lt;br /&gt;
			throw new ServletException( e );&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	public void destroy() {&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	public void init(FilterConfig filterConfig) throws ServletException&lt;br /&gt;
	{&lt;br /&gt;
		try&lt;br /&gt;
		{&lt;br /&gt;
			String tsparam = filterConfig.getInitParameter(&amp;quot;timeoutSeconds&amp;quot;);&lt;br /&gt;
			timeoutSeconds = Integer.parseInt(tsparam);&lt;br /&gt;
			&lt;br /&gt;
			String epparam = filterConfig.getInitParameter(&amp;quot;encryptionPassword&amp;quot;);&lt;br /&gt;
			char[] password = epparam.toCharArray();&lt;br /&gt;
			&lt;br /&gt;
			tokenName = filterConfig.getInitParameter(&amp;quot;PDFAttackTokenName&amp;quot;);&lt;br /&gt;
			&lt;br /&gt;
			SecretKeyFactory kf = SecretKeyFactory.getInstance( &amp;quot;PBEWithMD5AndDES&amp;quot; );&lt;br /&gt;
			secretKey = kf.generateSecret( new javax.crypto.spec.PBEKeySpec( password ) );&lt;br /&gt;
		}&lt;br /&gt;
		catch( Exception e )&lt;br /&gt;
		{&lt;br /&gt;
			throw new ServletException( e );&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	public String createToken( HttpServletRequest request ) throws Exception&lt;br /&gt;
	{&lt;br /&gt;
		String address = request.getRemoteAddr();&lt;br /&gt;
		String time = &amp;quot;&amp;quot;+System.currentTimeMillis();&lt;br /&gt;
		return encryptString( address + &amp;quot;|&amp;quot; + time );&lt;br /&gt;
	}&lt;br /&gt;
	&lt;br /&gt;
	public boolean checkToken( String etoken, HttpServletRequest request ) throws Exception&lt;br /&gt;
	{&lt;br /&gt;
		String token = decryptString( etoken );&lt;br /&gt;
		&lt;br /&gt;
		String currentAddress = request.getRemoteAddr();&lt;br /&gt;
		String tokenAddress = getAddressFromToken( token );&lt;br /&gt;
		&lt;br /&gt;
		long currentTime = System.currentTimeMillis();&lt;br /&gt;
		long tokenTime = getTimeFromToken( token );&lt;br /&gt;
		&lt;br /&gt;
		return (currentAddress.equals( tokenAddress )) &amp;amp;&amp;amp; (tokenTime &amp;gt; currentTime - timeoutSeconds * 1000);&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	public String getAddressFromToken( String token )&lt;br /&gt;
	{&lt;br /&gt;
		String address = token.substring( 0, token.indexOf(&amp;quot;|&amp;quot;) );&lt;br /&gt;
		return address;&lt;br /&gt;
	}&lt;br /&gt;
	&lt;br /&gt;
	public long getTimeFromToken( String token )&lt;br /&gt;
	{&lt;br /&gt;
		String date = token.substring( token.indexOf(&amp;quot;|&amp;quot;) + 1 );&lt;br /&gt;
		Long longdate = Long.parseLong( date );&lt;br /&gt;
		return longdate.longValue();&lt;br /&gt;
	}&lt;br /&gt;
	&lt;br /&gt;
	public synchronized String decryptString( String str ) throws Exception&lt;br /&gt;
	{&lt;br /&gt;
		// Cipher is not threadsafe, so create a new one each time&lt;br /&gt;
		Cipher passwordDecryptCipher = Cipher.getInstance( &amp;quot;PBEWithMD5AndDES/CBC/PKCS5Padding&amp;quot; );&lt;br /&gt;
		passwordDecryptCipher.init( Cipher.DECRYPT_MODE, secretKey, ps );&lt;br /&gt;
		byte[] dec = decoder.decodeBuffer( str.replace( '_', '+') );&lt;br /&gt;
		byte[] utf8 = passwordDecryptCipher.doFinal( dec );&lt;br /&gt;
		return new String( utf8, &amp;quot;UTF-8&amp;quot; );&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	public synchronized String encryptString( String str ) throws Exception&lt;br /&gt;
	{&lt;br /&gt;
		// Cipher is not threadsafe, so create a new one each time&lt;br /&gt;
		Cipher passwordEncryptCipher = Cipher.getInstance( &amp;quot;PBEWithMD5AndDES/CBC/PKCS5Padding&amp;quot; );&lt;br /&gt;
		passwordEncryptCipher.init( Cipher.ENCRYPT_MODE, secretKey, ps );&lt;br /&gt;
		byte[] utf8 = str.getBytes( &amp;quot;UTF-8&amp;quot; );&lt;br /&gt;
		byte[] enc = passwordEncryptCipher.doFinal( utf8 );&lt;br /&gt;
		return encoder.encode( enc ).replace( '+', '_' );&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Compile==&lt;br /&gt;
&lt;br /&gt;
There are not many dependencies here, just the standard Java EE environment. You can compile with:&lt;br /&gt;
&lt;br /&gt;
  javac -classpath j2ee.jar -d . *.java&lt;br /&gt;
&lt;br /&gt;
Then just copy the 'org' folder that gets created to the WEB-INF/classes folder.&lt;br /&gt;
&lt;br /&gt;
'''Comment: ''' In the decryptString method, it is necessary to strip the &amp;quot;#a&amp;quot; from the end of the str parameter, otherwise an IllegalBlockSizeException will be thrown with &amp;quot;Input length must be multiple of 8 when decrypting with padded cipher&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
[[Category:How To]]&lt;br /&gt;
[[Category:OWASP Java Project]]&lt;br /&gt;
[[Category:OWASP_Validation_Project]]&lt;br /&gt;
[[Category:Countermeasure]]&lt;/div&gt;</summary>
		<author><name>Stephendv</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=PDF_Attack_Filter_for_Java_EE&amp;diff=24433</id>
		<title>PDF Attack Filter for Java EE</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=PDF_Attack_Filter_for_Java_EE&amp;diff=24433"/>
				<updated>2008-01-14T15:31:11Z</updated>
		
		<summary type="html">&lt;p&gt;Stephendv: /* Overview */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Overview==&lt;br /&gt;
&lt;br /&gt;
This is a filter to block XSS attacks on PDF files served by Java EE applications. The details of the attack are discussed [http://www.gnucitizen.org/blog/danger-danger-danger/ elsewhere].  This filter implements a simple algorithm suggested by Amit Klein.  We've placed this software in the public domain to make it easy for anyone to use for any purpose. Please let us know if you're using it!&lt;br /&gt;
As an alternative to this, you could change MIME type or the Content-Disposition Header as [http://www.adobe.com/support/security/advisories/apsa07-02.html Adobe security advisory]&lt;br /&gt;
&lt;br /&gt;
==Approach==&lt;br /&gt;
&lt;br /&gt;
This attack relies on having some javascript in an anchor after the url like this: http://www.site.com/file.pdf#blah=javascript:alert(document.cookie);&lt;br /&gt;
&lt;br /&gt;
So the idea is to strip off the anchor. Unfortunately for us, the browser doesn't send the anchor along with the HTTP request. So we can't just strip it off.&lt;br /&gt;
&lt;br /&gt;
Therefore, we're going to use a redirect to steer the browser to a link without the anchor containing the attack.  Well, actually it turns out that we have to overwrite the anchor with something else, so we're going to use &amp;quot;#a&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
But there's one last problem to overcome. Since the browser doesn't send the anchor, the new request will look exactly like the request generated by the redirect.  With no way of telling the original request from the one generated by our redirect, we'll create an infinite loop.&lt;br /&gt;
&lt;br /&gt;
So to differentiate them, we're going to add a temporary token to the URL in the redirect, which we'll verify when it arrives.  We don't want an attacker forging this token, so we're going to encrypt the user's source IP address along with a timestamp. If a request shows up for the PDF file without a valid token, we'll reject it. Or actually, we can force it to be saved to disk, thus preventing the attack from working.&lt;br /&gt;
&lt;br /&gt;
This way, only an attacker from the same IP address who can trick you into clicking a link within 10 seconds of creating it can attack you. Not perfect, but certainly raises the bar quite a bit.&lt;br /&gt;
&lt;br /&gt;
==Download==&lt;br /&gt;
&lt;br /&gt;
The source code (one file) and the compiled class file are in a single zip file.&lt;br /&gt;
&lt;br /&gt;
'''[http://www.owasp.org/images/5/59/PDFAttackFilter.zip DOWNLOAD]'''&lt;br /&gt;
&lt;br /&gt;
==Setup==&lt;br /&gt;
&lt;br /&gt;
The first step is to add the filter to our application. All we have to do is put the PDFAttackFilter class on our application's classpath, probably by putting it in the classes folder in WEB-INF. The class file should be in a folder structure that matches the package (org -&amp;gt; owasp -&amp;gt; filters -&amp;gt; PDFAttackFilter).  You can extract the class file from the zip file.&lt;br /&gt;
&lt;br /&gt;
Then we just have to add the following to our web.xml. You should paste this in right above your servlet definitions. You'll want to change the mapping so that it only applies to URL's that serve a PDF file. You could use *.pdf, but you may have servlets that stream PDF files that down't end in .pdf.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
	&amp;lt;filter&amp;gt;&lt;br /&gt;
	     &amp;lt;filter-name&amp;gt;PDFAttackFilter&amp;lt;/filter-name&amp;gt;&lt;br /&gt;
	     &amp;lt;filter-class&amp;gt;org.owasp.filters.PDFAttackFilter&amp;lt;/filter-class&amp;gt;&lt;br /&gt;
             &amp;lt;init-param&amp;gt;&lt;br /&gt;
                 &amp;lt;param-name&amp;gt;timeoutSeconds&amp;lt;/param-name&amp;gt;&lt;br /&gt;
                 &amp;lt;param-value&amp;gt;1&amp;lt;/param-value&amp;gt;&lt;br /&gt;
             &amp;lt;/init-param&amp;gt;&lt;br /&gt;
             &amp;lt;init-param&amp;gt;&lt;br /&gt;
                 &amp;lt;param-name&amp;gt;encryptionPassword&amp;lt;/param-name&amp;gt;&lt;br /&gt;
                 &amp;lt;param-value&amp;gt;password&amp;lt;/param-value&amp;gt;&lt;br /&gt;
             &amp;lt;/init-param&amp;gt;&lt;br /&gt;
             &amp;lt;init-param&amp;gt;&lt;br /&gt;
                 &amp;lt;param-name&amp;gt;PDFAttackTokenName&amp;lt;/param-name&amp;gt;&lt;br /&gt;
                 &amp;lt;param-value&amp;gt;PDFAttackToken&amp;lt;/param-value&amp;gt;&lt;br /&gt;
             &amp;lt;/init-param&amp;gt;&lt;br /&gt;
	  &amp;lt;/filter&amp;gt;&lt;br /&gt;
	       &lt;br /&gt;
	  &amp;lt;filter-mapping&amp;gt;&lt;br /&gt;
	     &amp;lt;filter-name&amp;gt;PDFAttackFilter&amp;lt;/filter-name&amp;gt;&lt;br /&gt;
	     &amp;lt;url-pattern&amp;gt;/*&amp;lt;/url-pattern&amp;gt;&lt;br /&gt;
	  &amp;lt;/filter-mapping&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Depending on your application, it may be difficult to map all the URLs that lead to PDF files. You can map multiple url-patterns to the filter if necessary. In theory, it might be possible to send the redirect only if a response with content-type application/pdf. Then you could map the filter to apply to ALL requests. If there is demand for this feature, let us know.&lt;br /&gt;
&lt;br /&gt;
==Source Code==&lt;br /&gt;
&lt;br /&gt;
This code has been only minimally tested. Please help us verify the approach and the implementation used here.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/**&lt;br /&gt;
 *  Software published by the Open Web Application Security Project (http://www.owasp.org)&lt;br /&gt;
 *  This software is in the public domain with no warranty.&lt;br /&gt;
 *&lt;br /&gt;
 * @author     Jeff Williams &amp;lt;a href=&amp;quot;http://www.aspectsecurity.com&amp;quot;&amp;gt;Aspect Security&amp;lt;/a&amp;gt;&lt;br /&gt;
 * @created    January 4, 2007&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
package org.owasp.filters;&lt;br /&gt;
&lt;br /&gt;
import java.io.IOException;&lt;br /&gt;
&lt;br /&gt;
import javax.crypto.Cipher;&lt;br /&gt;
import javax.crypto.SecretKey;&lt;br /&gt;
import javax.crypto.SecretKeyFactory;&lt;br /&gt;
import javax.crypto.spec.PBEParameterSpec;&lt;br /&gt;
import javax.servlet.Filter;&lt;br /&gt;
import javax.servlet.FilterChain;&lt;br /&gt;
import javax.servlet.FilterConfig;&lt;br /&gt;
import javax.servlet.ServletException;&lt;br /&gt;
import javax.servlet.ServletRequest;&lt;br /&gt;
import javax.servlet.ServletResponse;&lt;br /&gt;
import javax.servlet.http.HttpServletRequest;&lt;br /&gt;
import javax.servlet.http.HttpServletResponse;&lt;br /&gt;
&lt;br /&gt;
public class PDFAttackFilter implements Filter &lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
	private static sun.misc.BASE64Decoder decoder = new sun.misc.BASE64Decoder();&lt;br /&gt;
	private static sun.misc.BASE64Encoder encoder = new sun.misc.BASE64Encoder();&lt;br /&gt;
	private static byte[] salt = { (byte) 0x23, (byte) 0x3f, (byte) 0x28, (byte) 0x00, (byte) 0x11, (byte) 0xc2, (byte) 0xd1, (byte) 0xff };&lt;br /&gt;
	private static PBEParameterSpec ps = new PBEParameterSpec( salt, 20 );&lt;br /&gt;
	private static SecretKey secretKey;&lt;br /&gt;
	private static int timeoutSeconds = 10;&lt;br /&gt;
	private static String tokenName = &amp;quot;PDFAttackToken&amp;quot;;&lt;br /&gt;
	&lt;br /&gt;
	&lt;br /&gt;
	public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException&lt;br /&gt;
	{&lt;br /&gt;
		HttpServletRequest req = (HttpServletRequest)request;&lt;br /&gt;
		HttpServletResponse res = (HttpServletResponse)response;&lt;br /&gt;
		String token = req.getParameter( tokenName );&lt;br /&gt;
&lt;br /&gt;
		try&lt;br /&gt;
		{&lt;br /&gt;
&lt;br /&gt;
			// IF the URL doesn't contain token, then:&lt;br /&gt;
			//  calculate X=encrypt_with_key(server_time, client_IP_address)&lt;br /&gt;
			//  redirect to file.pdf?token=X&lt;br /&gt;
			//  add #a to the end of the url to eliminate any remaining anchors&lt;br /&gt;
			&lt;br /&gt;
			if ( token == null )&lt;br /&gt;
			{&lt;br /&gt;
				String etoken = createToken( req );&lt;br /&gt;
				String base = req.getRequestURI();&lt;br /&gt;
				String querystring = req.getQueryString();&lt;br /&gt;
				if ( querystring != null ) base += &amp;quot;?&amp;quot; + req.getQueryString();&lt;br /&gt;
				String appender = base.contains( &amp;quot;?&amp;quot; ) ? &amp;quot;&amp;amp;&amp;quot; : &amp;quot;?&amp;quot;;&lt;br /&gt;
				String url = base + appender + tokenName + &amp;quot;=&amp;quot; + etoken + &amp;quot;#a&amp;quot;;&lt;br /&gt;
				res.sendRedirect( res.encodeRedirectURL( url ) );&lt;br /&gt;
				return;&lt;br /&gt;
			}&lt;br /&gt;
	&lt;br /&gt;
			// ELSE IF the URL contains token, then:	&lt;br /&gt;
			// if decrypt(token_query).IP_address==client_IP_address and&lt;br /&gt;
			// decrypt(token_query).time&amp;gt;server_time-10sec&lt;br /&gt;
			//  serve the PDF resource as an in-line resource&lt;br /&gt;
			&lt;br /&gt;
			if ( checkToken( token, req ) )&lt;br /&gt;
			{&lt;br /&gt;
				chain.doFilter(req, res);&lt;br /&gt;
				return;&lt;br /&gt;
			}&lt;br /&gt;
	&lt;br /&gt;
			// ELSE IF the token doesn't match, then:&lt;br /&gt;
			// serve the PDF resource as a &amp;quot;save to disk&amp;quot; resource via a proper&lt;br /&gt;
			// choice of the Content-Type header (and/or an attachment, via&lt;br /&gt;
			// Content-Disposition).&lt;br /&gt;
&lt;br /&gt;
			res.addHeader(&amp;quot;Content-Disposition&amp;quot;, &amp;quot;Attachment&amp;quot; );				&lt;br /&gt;
			res.setContentType( &amp;quot;application/octet&amp;quot; );  // may be overwritten&lt;br /&gt;
			chain.doFilter(req, res);&lt;br /&gt;
		}&lt;br /&gt;
		catch( Exception e )&lt;br /&gt;
		{&lt;br /&gt;
			throw new ServletException( e );&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	public void destroy() {&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	public void init(FilterConfig filterConfig) throws ServletException&lt;br /&gt;
	{&lt;br /&gt;
		try&lt;br /&gt;
		{&lt;br /&gt;
			String tsparam = filterConfig.getInitParameter(&amp;quot;timeoutSeconds&amp;quot;);&lt;br /&gt;
			timeoutSeconds = Integer.parseInt(tsparam);&lt;br /&gt;
			&lt;br /&gt;
			String epparam = filterConfig.getInitParameter(&amp;quot;encryptionPassword&amp;quot;);&lt;br /&gt;
			char[] password = epparam.toCharArray();&lt;br /&gt;
			&lt;br /&gt;
			tokenName = filterConfig.getInitParameter(&amp;quot;PDFAttackTokenName&amp;quot;);&lt;br /&gt;
			&lt;br /&gt;
			SecretKeyFactory kf = SecretKeyFactory.getInstance( &amp;quot;PBEWithMD5AndDES&amp;quot; );&lt;br /&gt;
			secretKey = kf.generateSecret( new javax.crypto.spec.PBEKeySpec( password ) );&lt;br /&gt;
		}&lt;br /&gt;
		catch( Exception e )&lt;br /&gt;
		{&lt;br /&gt;
			throw new ServletException( e );&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	public String createToken( HttpServletRequest request ) throws Exception&lt;br /&gt;
	{&lt;br /&gt;
		String address = request.getRemoteAddr();&lt;br /&gt;
		String time = &amp;quot;&amp;quot;+System.currentTimeMillis();&lt;br /&gt;
		return encryptString( address + &amp;quot;|&amp;quot; + time );&lt;br /&gt;
	}&lt;br /&gt;
	&lt;br /&gt;
	public boolean checkToken( String etoken, HttpServletRequest request ) throws Exception&lt;br /&gt;
	{&lt;br /&gt;
		String token = decryptString( etoken );&lt;br /&gt;
		&lt;br /&gt;
		String currentAddress = request.getRemoteAddr();&lt;br /&gt;
		String tokenAddress = getAddressFromToken( token );&lt;br /&gt;
		&lt;br /&gt;
		long currentTime = System.currentTimeMillis();&lt;br /&gt;
		long tokenTime = getTimeFromToken( token );&lt;br /&gt;
		&lt;br /&gt;
		return (currentAddress.equals( tokenAddress )) &amp;amp;&amp;amp; (tokenTime &amp;gt; currentTime - timeoutSeconds * 1000);&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	public String getAddressFromToken( String token )&lt;br /&gt;
	{&lt;br /&gt;
		String address = token.substring( 0, token.indexOf(&amp;quot;|&amp;quot;) );&lt;br /&gt;
		return address;&lt;br /&gt;
	}&lt;br /&gt;
	&lt;br /&gt;
	public long getTimeFromToken( String token )&lt;br /&gt;
	{&lt;br /&gt;
		String date = token.substring( token.indexOf(&amp;quot;|&amp;quot;) + 1 );&lt;br /&gt;
		Long longdate = Long.parseLong( date );&lt;br /&gt;
		return longdate.longValue();&lt;br /&gt;
	}&lt;br /&gt;
	&lt;br /&gt;
	public synchronized String decryptString( String str ) throws Exception&lt;br /&gt;
	{&lt;br /&gt;
		// Cipher is not threadsafe, so create a new one each time&lt;br /&gt;
		Cipher passwordDecryptCipher = Cipher.getInstance( &amp;quot;PBEWithMD5AndDES/CBC/PKCS5Padding&amp;quot; );&lt;br /&gt;
		passwordDecryptCipher.init( Cipher.DECRYPT_MODE, secretKey, ps );&lt;br /&gt;
		byte[] dec = decoder.decodeBuffer( str.replace( '_', '+') );&lt;br /&gt;
		byte[] utf8 = passwordDecryptCipher.doFinal( dec );&lt;br /&gt;
		return new String( utf8, &amp;quot;UTF-8&amp;quot; );&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	public synchronized String encryptString( String str ) throws Exception&lt;br /&gt;
	{&lt;br /&gt;
		// Cipher is not threadsafe, so create a new one each time&lt;br /&gt;
		Cipher passwordEncryptCipher = Cipher.getInstance( &amp;quot;PBEWithMD5AndDES/CBC/PKCS5Padding&amp;quot; );&lt;br /&gt;
		passwordEncryptCipher.init( Cipher.ENCRYPT_MODE, secretKey, ps );&lt;br /&gt;
		byte[] utf8 = str.getBytes( &amp;quot;UTF-8&amp;quot; );&lt;br /&gt;
		byte[] enc = passwordEncryptCipher.doFinal( utf8 );&lt;br /&gt;
		return encoder.encode( enc ).replace( '+', '_' );&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Compile==&lt;br /&gt;
&lt;br /&gt;
There are not many dependencies here, just the standard Java EE environment. You can compile with:&lt;br /&gt;
&lt;br /&gt;
  javac -classpath j2ee.jar -d . *.java&lt;br /&gt;
&lt;br /&gt;
Then just copy the 'org' folder that gets created to the WEB-INF/classes folder.&lt;br /&gt;
&lt;br /&gt;
'''Comment: ''' In the decryptString method, it is necessary to strip the &amp;quot;#a&amp;quot; from the end of the str parameter, otherwise an IllegalBlockSizeException will be thrown with &amp;quot;Input length must be multiple of 8 when decrypting with padded cipher&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
[[Category:How To]]&lt;br /&gt;
[[Category:OWASP Java Project]]&lt;br /&gt;
[[Category:OWASP_Validation_Project]]&lt;br /&gt;
[[Category:Countermeasure]]&lt;/div&gt;</summary>
		<author><name>Stephendv</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Java_gotchas&amp;diff=24432</id>
		<title>Java gotchas</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Java_gotchas&amp;diff=24432"/>
				<updated>2008-01-14T15:18:38Z</updated>
		
		<summary type="html">&lt;p&gt;Stephendv: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Status==&lt;br /&gt;
Released 14/1/2008&lt;br /&gt;
&lt;br /&gt;
== Equality ==&lt;br /&gt;
Object equality is tested using the == operator, while value equality is tested using the .equals(Object) method.  For example:&lt;br /&gt;
 String one = new String(&amp;quot;abc&amp;quot;);&lt;br /&gt;
 String two = new String(&amp;quot;abc&amp;quot;);&lt;br /&gt;
 String three = one;&lt;br /&gt;
 if (one != two) System.out.println(&amp;quot;The two objects are not the same.&amp;quot;);&lt;br /&gt;
 if (one.equals(two)) System.out.println(&amp;quot;But they do contain the same value&amp;quot;);&lt;br /&gt;
 if (one == three) System.out.println(&amp;quot;These two are the same, because they use the same reference.&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
The output is:&lt;br /&gt;
 The two objects are not the same.&lt;br /&gt;
 But they do contain the same value&lt;br /&gt;
 These two are the same, because they use the same reference.&lt;br /&gt;
&lt;br /&gt;
Also, be aware that:&lt;br /&gt;
&lt;br /&gt;
 String abc = &amp;quot;abc&amp;quot;&lt;br /&gt;
&lt;br /&gt;
and&lt;br /&gt;
&lt;br /&gt;
 String abc = new String(&amp;quot;abc&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
are different. For example, consider the following:&lt;br /&gt;
&lt;br /&gt;
 String letters = &amp;quot;abc&amp;quot;;&lt;br /&gt;
 String moreLetters = &amp;quot;abc&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
 System.out.println(letters==moreLetters);&lt;br /&gt;
&lt;br /&gt;
The output is:&lt;br /&gt;
&lt;br /&gt;
 true&lt;br /&gt;
&lt;br /&gt;
This is due to the compiler and runtime efficiency. In the compiled class file only one set of data &amp;quot;abc&amp;quot; is stored, not two. In this situation only one object is created, therefore the equality is true between these object. However, consider this:&lt;br /&gt;
&lt;br /&gt;
 String data = new String(&amp;quot;123&amp;quot;);&lt;br /&gt;
 String moreData = new String(&amp;quot;123&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
 System.out.println(data==moreData);&lt;br /&gt;
&lt;br /&gt;
The output is:&lt;br /&gt;
&lt;br /&gt;
 false&lt;br /&gt;
&lt;br /&gt;
Even though one set of data &amp;quot;123&amp;quot; is stored in the class this is still treated differently at runtime. An explicit instantiation is used to create the String objects. Therefore, in this case, two objects have been created, so the equality is false. It is important to note that &amp;quot;==&amp;quot; is always used for object equality and does not ever refer to the values in an object. Always use .equals when checking looking for a &amp;quot;meaningful&amp;quot; comparison.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Immutable Objects / Wrapper Class Caching ==&lt;br /&gt;
Since Java 5, wrapper class caching was introduced.  The following is an examination of the cache created by an inner class, IntegerCache, located in the Integer cache. For example, the following code will create a cache:&lt;br /&gt;
&lt;br /&gt;
 Integer myNumber = 10&lt;br /&gt;
or &lt;br /&gt;
 Integer myNumber = Integer.valueOf(10);&lt;br /&gt;
&lt;br /&gt;
256 Integer objects are created in the range of -128 to 127 which are all stored in an Integer array.  This caching functionality can be seen by looking at the inner class, IntegerCache, which is found in Integer:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 private static class IntegerCache &lt;br /&gt;
 {&lt;br /&gt;
   private IntegerCache(){}&lt;br /&gt;
   &lt;br /&gt;
   static final Integer cache[] = new Integer[-(-128) + 127 + 1];&lt;br /&gt;
 &lt;br /&gt;
   static &lt;br /&gt;
   {&lt;br /&gt;
     for(int i = 0; i &amp;lt; cache.length; i++)&lt;br /&gt;
     cache[i] = new Integer(i - 128); &lt;br /&gt;
   }&lt;br /&gt;
 }&lt;br /&gt;
    &lt;br /&gt;
 public static Integer valueOf(int i) &lt;br /&gt;
 {&lt;br /&gt;
	final int offset = 128;&lt;br /&gt;
	if (i &amp;gt;= -128 &amp;amp;&amp;amp; i &amp;lt;= 127) // must cache &lt;br /&gt;
        { &lt;br /&gt;
	    return IntegerCache.cache[i + offset];&lt;br /&gt;
	}&lt;br /&gt;
        return new Integer(i);&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So when creating an object using Integer.valueOf or directly assigning a value to an Integer within the range of -128 to 127 the same object will be returned. Therefore, consider the following example:&lt;br /&gt;
&lt;br /&gt;
 Integer i = 100;&lt;br /&gt;
 Integer p = 100;&lt;br /&gt;
 if (i == p)  System.out.println(&amp;quot;i and p are the same.&amp;quot;);&lt;br /&gt;
 if (i != p)   System.out.println(&amp;quot;i and p are different.&amp;quot;);	&lt;br /&gt;
 if(i.equals(p))  System.out.println(&amp;quot;i and p contain the same value.&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
The output is: &lt;br /&gt;
 i and p are the same.&lt;br /&gt;
 i and p contain the same value.&lt;br /&gt;
&lt;br /&gt;
It is important to note that object i and p only equate to true because they are the same object, the comparison is not based on the value, it is based on object equality. If Integer i and p are outside the range of -128 or 127 the cache is not used, therefore new objects are created. When doing a comparison for value always use the “.equals” method. It is also important to note that instantiating an Integer does not create this caching. So consider the following example:&lt;br /&gt;
&lt;br /&gt;
 Integer i = new Integer (100);&lt;br /&gt;
 Integer p = new Integer(100);&lt;br /&gt;
 if(i==p) System.out.println(“i and p are the same object”);&lt;br /&gt;
 if(i.equals(p)) System.out.println(“ i and p contain the same value”);&lt;br /&gt;
&lt;br /&gt;
In this circumstance, the output is only:&lt;br /&gt;
 &lt;br /&gt;
 i and p contain the same value&lt;br /&gt;
&lt;br /&gt;
Remember that “==” is always used for object equality, it has not been overloaded for comparing unboxed values.&lt;br /&gt;
&lt;br /&gt;
This behavior is documented in the [http://java.sun.com/docs/books/jls Java Language Specification] [http://java.sun.com/docs/books/jls/third_edition/html/conversions.html#5.1.7 section 5.1.7]. Quoting from there:&lt;br /&gt;
:If the value ''p'' being boxed is true, false, a byte, a char in the range \u0000 to \u007f, or an int or short number between -128 and 127, then let ''r1'' and ''r2'' be the results of any two boxing conversions of ''p''. It is always the case that ''r1'' == ''r2''.&lt;br /&gt;
&lt;br /&gt;
The other wrapper classes (Byte, Short, Long, Character) also contain this caching mechanism. The Byte, Short and Long all contain the same caching principle to the Integer object. The Character class caches from 0 to 127. The negative cache is not created for the Character wrapper as these values do not represent a corresponding character. There is no caching for the Float object.&lt;br /&gt;
&lt;br /&gt;
BigDecimal also uses caching but uses a different mechanism. While the other objects contain a inner class to deal with caching this is not true for BigDecimal, the caching is pre-defined in a static array and only covers 11 numbers, 0 to 10:&lt;br /&gt;
&lt;br /&gt;
 // Cache of common small BigDecimal values.&lt;br /&gt;
 private static final BigDecimal zeroThroughTen[] = {&lt;br /&gt;
 new BigDecimal(BigInteger.ZERO,		0,  0),&lt;br /&gt;
 new BigDecimal(BigInteger.ONE,		1,  0),&lt;br /&gt;
 new BigDecimal(BigInteger.valueOf(2),	2,  0),&lt;br /&gt;
 new BigDecimal(BigInteger.valueOf(3),	3,  0),&lt;br /&gt;
 new BigDecimal(BigInteger.valueOf(4),	4,  0),&lt;br /&gt;
 new BigDecimal(BigInteger.valueOf(5),	5,  0),&lt;br /&gt;
 new BigDecimal(BigInteger.valueOf(6),	6,  0),&lt;br /&gt;
 new BigDecimal(BigInteger.valueOf(7),	7,  0),&lt;br /&gt;
 new BigDecimal(BigInteger.valueOf(8),	8,  0),&lt;br /&gt;
 new BigDecimal(BigInteger.valueOf(9),	9,  0),&lt;br /&gt;
 new BigDecimal(BigInteger.TEN,		10, 0),&lt;br /&gt;
 };&lt;br /&gt;
&lt;br /&gt;
As per Java Language Specification(JLS) the values discussed above are stored as immutable wrapper objects. This caching has been created because it is assumed these values / objects are used more frequently.&lt;br /&gt;
&lt;br /&gt;
== Incrementing values ==&lt;br /&gt;
Be careful of the post-increment operator:&lt;br /&gt;
&lt;br /&gt;
  int x = 5;&lt;br /&gt;
  x = x++;&lt;br /&gt;
  System.out.println( x );&lt;br /&gt;
&lt;br /&gt;
The output is:&lt;br /&gt;
&lt;br /&gt;
 5&lt;br /&gt;
&lt;br /&gt;
Remember that the assignment completes before the increment, hence post-increment. Using the pre-increment will update the value&lt;br /&gt;
before the assignment. For example:&lt;br /&gt;
&lt;br /&gt;
 int x = 5;&lt;br /&gt;
 x = ++x;&lt;br /&gt;
 System.out.println( x );&lt;br /&gt;
&lt;br /&gt;
The output is:&lt;br /&gt;
&lt;br /&gt;
 6&lt;br /&gt;
&lt;br /&gt;
== Garbage Collection ==&lt;br /&gt;
&lt;br /&gt;
By overriding &amp;quot;finalize()&amp;quot; will allow you to define you own code for what is potentially the same concept as a destructor. There are a couple of important points to remember:&lt;br /&gt;
&lt;br /&gt;
* &amp;quot;finalize()&amp;quot; will only ever by called once (at most) by the Garbage Collector.&lt;br /&gt;
* It is never a guarantee that &amp;quot;finalize()&amp;quot; will be called i.e that an object will be garbage collected.&lt;br /&gt;
* By overriding &amp;quot;finalize()&amp;quot; you can prevent an object from ever being deleted. For example, the object passes a reference of itself to another object.&lt;br /&gt;
* Garbage collection behaviour differs between JVMs.&lt;br /&gt;
&lt;br /&gt;
== Boolean Assignment ==&lt;br /&gt;
&lt;br /&gt;
Everyone appreciates the difference between &amp;quot;==&amp;quot; and &amp;quot;=&amp;quot; in Java. However, typos and mistakes are made, often the compiler will catch them. However, consider the following:&lt;br /&gt;
&lt;br /&gt;
 boolean theTruth = false;&lt;br /&gt;
 if (theTruth = true)&lt;br /&gt;
 {&lt;br /&gt;
  System.out.println(&amp;quot;theTruth is true&amp;quot;);&lt;br /&gt;
 }&lt;br /&gt;
 else&lt;br /&gt;
 {&lt;br /&gt;
  System.out.println(&amp;quot;theTruth is false;&amp;quot;);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
The result of any assignment expression is the value of the variable following the assignment. Therefore, the above will always result in &amp;quot;theTruth is true&amp;quot;. This only applies to booleans, so for example the following will not compile and would therefore be caught by the compiler:&lt;br /&gt;
&lt;br /&gt;
 int i = 1;&lt;br /&gt;
 if(i=0) {}&lt;br /&gt;
&lt;br /&gt;
As &amp;quot;i&amp;quot; is and integer the comparison would evaluate to (i=0) as 0 is the result of the assignment. A boolean would be expected, due the &amp;quot;if&amp;quot; statement.&lt;br /&gt;
&lt;br /&gt;
== Conditions ==&lt;br /&gt;
&lt;br /&gt;
Be on the look out for any nested &amp;quot;else if&amp;quot;. Consider the following code example:&lt;br /&gt;
&lt;br /&gt;
 int x = 3;&lt;br /&gt;
 if (x==5) {}&lt;br /&gt;
 else if (x&amp;lt;9)&lt;br /&gt;
 {&lt;br /&gt;
   System.out.println(&amp;quot;x is less than 9&amp;quot;);&lt;br /&gt;
 }&lt;br /&gt;
 else if (x&amp;lt;6)&lt;br /&gt;
 {&lt;br /&gt;
   System.out.println(&amp;quot;x is less than 6&amp;quot;);&lt;br /&gt;
 }&lt;br /&gt;
 else&lt;br /&gt;
 {&lt;br /&gt;
   System.out.println(&amp;quot;else&amp;quot;);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Produces the output:&lt;br /&gt;
&lt;br /&gt;
 x is less then 9&lt;br /&gt;
 &lt;br /&gt;
So even though the second else if would equate to &amp;quot;true&amp;quot; it is never reached. This is because once an &amp;quot;else if&amp;quot; succeeds the remaining conditions will be not be processed.&lt;br /&gt;
&lt;br /&gt;
[[Category:OWASP Java Project]]&lt;/div&gt;</summary>
		<author><name>Stephendv</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Java_Server_Faces&amp;diff=24431</id>
		<title>Java Server Faces</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Java_Server_Faces&amp;diff=24431"/>
				<updated>2008-01-14T15:17:45Z</updated>
		
		<summary type="html">&lt;p&gt;Stephendv: /* Status */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Status==&lt;br /&gt;
Released 14/1/2008&lt;br /&gt;
&lt;br /&gt;
==Author==&lt;br /&gt;
Sam Reghenzi&lt;br /&gt;
==Web security.. before you start ==&lt;br /&gt;
&lt;br /&gt;
This document is about security in web applications developed using the Java Server Faces (JSF) framework. The reader should be aware of the meaning of common terms of both JSF (converters, validators, managed beans) and web security (injection etc.)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==JSF Standards and roles==&lt;br /&gt;
JavaServer Faces (JSF) is a Java-based Web application framework that implements the Model-View-Controller pattern and simplifies the development of web interfaces for Java EE applications.&lt;br /&gt;
&lt;br /&gt;
In a standard MVC JSF are meant to provide the V (of view) and part of the C (of Control). JSF components can present almost any basic interface model. The framework also provides part of the Control layer including:&lt;br /&gt;
* Navigation Handling &lt;br /&gt;
* Error Handling &lt;br /&gt;
* Action and event Management &lt;br /&gt;
* Input validation &lt;br /&gt;
* Value conversion &lt;br /&gt;
These elements are defined by the JSF standard (JCP 127) so that any attacker will have knowledge of the architecture and life cycle of a JSF based application. JSF does not implement it's own security model but instead relies on standard JEE security. This means that both application server security model, JAAS or other ACL implementations can be used with the JSF framework without any integration effort. But Access Control is just one part of security - all aspects should be implemented in a secure manner in order to consider the application itself secure.&lt;br /&gt;
&lt;br /&gt;
==Client-side state saving==&lt;br /&gt;
A JSF application can save the state of its components in the client response or on the server. Saving state on the client may be required because some users turn off cookies support, but it can increase response times when connections are slow. Saving state on the server may have the disadvantage of high memory consumption for the user, but it does minimize bandwidth requirements.&lt;br /&gt;
Since client-side state saving stores data in the client , it should be used wisely, or not used at all. An attacker that can manipulate a user's data could manage a data tampering or worst, a privilege escalation exploit. Unencrypted data is quite easy to manipulate and most of the client-side saved data are serialized Java objects  which can contain a wealth of sensitive data. If you plan to use client-side state saving carefully consider which information you decide to store in the POJO/DTO in order to minimise these risks.&lt;br /&gt;
==Components==&lt;br /&gt;
===Converters===&lt;br /&gt;
Converter could be a source of threat since it converts string in Java objects. An attacker could inject malicious code or tampered data to make the converter itself misbehave and expose protected data. The converter system is not insecure by itself, but conversion, since it is a security touch point for business logic and persistent data, should be handled carefully. Input should '''always''' be validated '''after''' being converted. In JSF lingo you should '''always''' have a validator if a conversion occurs. See next section on how to implement a security aware validator.&lt;br /&gt;
&lt;br /&gt;
===Validators===&lt;br /&gt;
Validation is your chance to verify that the input is as expected. This means that the input should be validated both from a domain view and from a security view. If input represents a string that in your domain should be from 10 to 254 characters long, the same string should be validated also to prevent SQL Injection and XSS attacks. Since many security checks are done using dictionary algorithms it's useful to have a validator that implements those checks and extends it to implement your domain validator.&lt;br /&gt;
For example:&lt;br /&gt;
&lt;br /&gt;
 public class TenToHundredsValidator extends SecureValidator() {&lt;br /&gt;
    public void validate(...) {&lt;br /&gt;
       &lt;br /&gt;
       super.validate(...); // Do security checks&lt;br /&gt;
       &lt;br /&gt;
       domainvalidate(....);&lt;br /&gt;
    }&lt;br /&gt;
 }          &lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===ManagedBeans===&lt;br /&gt;
Managed beans are the gears of JSF based application. Developers can access FacesContext statically and this is potentially dangerous. This is a common short cut for everything in the JSF layer, but manipulating this data could be harmful. Relying on security principals, and software engineering, is always a good approach.&lt;br /&gt;
Calls such as:&lt;br /&gt;
    FacesContext.getCurrentInstance().getExternalContext().getRequestParameter(&amp;quot;name&amp;quot;)&lt;br /&gt;
are dangerous because the whole validation stack is bypassed. You can read parameters but consider them as tainted input. Use Validators described above also if you are not in the validation phase . Validators are also an effective way to refactor your validation code and to prevent code repetition.&lt;br /&gt;
FacesContext  also allows access to user principal data; this data could be used to verify if the current user can actually execute the business logic in the managed Bean.&lt;br /&gt;
This practice should be adopted in favour of rendering or not the commandLinks that lead to the action of the managed Bean. A structured adoption of an execution based security framework , such as ACEGI (see the Appendix), could be a good enforcement of the security of the  managed bean.&lt;br /&gt;
===Custom components===&lt;br /&gt;
If the use of custom components is required in the application, the security depends on how the components are developed. Third party components should be delivered with a security report and support from the specific vendor or community.&lt;br /&gt;
If you develop custom components you should be aware of the same old security issues of web development:&lt;br /&gt;
* Do not thrust request parameter &lt;br /&gt;
* Do not thrust cookies &lt;br /&gt;
* Always consider that session could be hijacked &lt;br /&gt;
Since the component tree is assembled server side it can be trusted so if your custom component needs to read data from a sibling component it should be considered a safe operation although you will have to make assumptions on element names of the tree.&lt;br /&gt;
==Implementations==&lt;br /&gt;
Since more than one JSF Implementation exists, bugs of the implementation should be first on the security list.&lt;br /&gt;
&lt;br /&gt;
===MyFaces===&lt;br /&gt;
There aren't major or critical security bugs registered in the current stable release of MyFaces (1.1.5). Client state saving is still the weak point and should be used wisely. My Faces comes also with a Security Extension  (http://wiki.apache.org/myfaces/SecurityContext) that allows to safely and easily retrieve authenticated user details.&lt;br /&gt;
&lt;br /&gt;
The MyFaces resource filter could be a source of threat. It is designed to expose resources from a jar file and could therefore, be considered, potentially dangerous. Note there aren't any claimed security flaws nor exploits in the resource filter, but the nature of this component makes it a good target for attackers. Since all it has to do is serve data it is recommended that a dispatcher be added to the filter mapping element. This should lower the possibility of an attacker successfully manipulating the server request.&lt;br /&gt;
For more information see: http://myfaces.apache.org/tomahawk/extensionsFilter.htm&lt;br /&gt;
&lt;br /&gt;
There is also an easy way to enable encryption when using ''client save state''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;context-param&amp;gt;&lt;br /&gt;
        &amp;lt;param-name&amp;gt;org.apache.myfaces.secret&amp;lt;/param-name&amp;gt;&lt;br /&gt;
        &amp;lt;param-value&amp;gt;NzY1NDMyMTA=&amp;lt;/param-value&amp;gt;&lt;br /&gt;
    &amp;lt;/context-param&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Supported encryption methods are BlowFish, 3DES, AES and are definde bya a context parameter&lt;br /&gt;
&lt;br /&gt;
&amp;lt;context-param&amp;gt;&lt;br /&gt;
        &amp;lt;param-name&amp;gt;org.apache.myfaces.algorithm&amp;lt;/param-name&amp;gt;&lt;br /&gt;
        &amp;lt;param-value&amp;gt;Blowfish&amp;lt;/param-value&amp;gt;&lt;br /&gt;
    &amp;lt;/context-param&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can find mre info at http://wiki.apache.org/myfaces/Secure_Your_Application&lt;br /&gt;
&lt;br /&gt;
===SUN Reference Implementation===&lt;br /&gt;
Quoting from the documentation:&lt;br /&gt;
''There are several ways for a web application to store session state on the client tier. One possible solution is to use Cookies to store the state on the client. However, cookies have limitations in size and are not ideal in cases where you want to store session state on the client.  The state that needs to be stored on the client is first serialized into a byte array. This byte array is then encrypted using industrial-strength 3DES with cipher-block-chaining (CBC) and an initialization vector. To make the content tamper-resistant, we then create a message authentication code (using SHA1 algorithm) from the encrypted content and the initialization vector. The initialization vector, the message authentication code, and the encrypted content is then combined in a single byte array. Finally, this resulting byte array is converted into a base64 string which is stored in a hidden FORM field on the client.&lt;br /&gt;
This solution is secure because it uses a strong crypto algorithm and also uses a MAC for tamper-resistance. We also generate all the random numbers (for example, to generate the initialization vectors and the password) using the cryptographically-secure SecureRandom class. Note that the encryption keys are NEVER sent to the client or sent on the wire. These keys are used only on the server-side to encrypt and decrypt the state. One challenge is to decide what encryption keys to use. The encryption keys should not be known to the client, but still be associated with the client. We solve this problem by generating these keys from a password that is generated randomly and stored in the HttpSession. This strategy for key generation through password is pluggable in our solution and can be changed if needed.''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===ICE Faces===&lt;br /&gt;
&lt;br /&gt;
Starting from the idea that AJAX on Its Own Doesn't Corrupt Web Security ICE faces implements a component suite with ajax support by maintainig a coninus sync bettween the dom sent to the browser and a dom rapresentation on the server. javascript is used to send commands to the server and invoke the logic in the java layer. Since dom model and javascript is involved a Javascript debugging  tool with value injection or dom injection capability could be of some use in pick loking the app.&lt;br /&gt;
&lt;br /&gt;
As stated in ICEFaces manual &amp;quot; the client is untrusted, SO DON'T TRUST IT!!&amp;quot; : it means that is all ups to the application designer to implement a robust security logic behind the scenes.&lt;br /&gt;
In another point of view th developer could focus on implement server side security since with the server-side-dom architecture the thin client is even thinner.&lt;br /&gt;
&lt;br /&gt;
The component thath refresh the two dom , caled IntervalRenderer, uses  a persistent ServletRequest stored on the server. Unfortunately, this request does not contain sufficient information to perform the isUserInRole() check.&lt;br /&gt;
This kind of check is possible only on stadar render request phase. &lt;br /&gt;
&lt;br /&gt;
To address this, a small amount of integration will be required either between ICEfaces and acegi-security or ICEfaces and the application server.  Acegi-security (see appendix one ) is likely preferable as it will be more portable.&lt;br /&gt;
&lt;br /&gt;
==Apendix I==&lt;br /&gt;
&lt;br /&gt;
===ACEGI Integration===&lt;br /&gt;
&lt;br /&gt;
Acegi Security is a powerful, flexible security solution for enterprise software, with a particular emphasis on applications that use Spring. If used in combination with jsf, the managed beans could become more &amp;quot;security aware&amp;quot; since acegi do not only perform authentication but also authorization in business layer. Acegi is a convenient way to manage security in all the layers of our application. This is a valuable thing especially when authorization is strongly coupled with business logic (approval work flows etc).&lt;br /&gt;
&lt;br /&gt;
In order to use a custom JSF-Acegi login we have to provide a valid Security Context (''userName'' and ''password'' are properties of the managed bean)&lt;br /&gt;
&lt;br /&gt;
 UsernamePasswordAuthenticationToken authReq = new UsernamePasswordAuthenticationToken(userName, password);&lt;br /&gt;
 Authentication auth = getAuthenticationManager().authenticate(authReq);&lt;br /&gt;
 SecurityContext secCtx = SecurityContextHolder.getContext();&lt;br /&gt;
 secCtx.setAuthentication(auth);&lt;br /&gt;
&lt;br /&gt;
We can override the standard ACEGI navigation with custom, logic driven, navigation reading security context and routing the outcome.&lt;br /&gt;
&lt;br /&gt;
More information can be found at  here [http://www.javakaffee.de/blog/2006/07/04/jsfacegi-authentication-with-a-backing-bean/]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
ACEGI can be integrated also in the rendering via custom components [http://cagataycivici.wordpress.com/2006/01/19/acegi_jsf_components_hit_the/] which basically wrap the standard ACEGI tag library in JSF components. This conveniently solve the ''stage zero'' of profiling: display or not a widget in the page.&lt;br /&gt;
&lt;br /&gt;
Including a JSF based form for login in a page could be a little tricky, bu using MyFaces tomahawk components it can be done easely.&lt;br /&gt;
&lt;br /&gt;
The form will look like&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;%@ taglib uri=&amp;quot;http://myfaces.apache.org/tomahawk&amp;quot; prefix=&amp;quot;t&amp;quot;%&amp;gt;&lt;br /&gt;
 &amp;lt;t:inputText id=&amp;quot;j_username&amp;quot; forceId=&amp;quot;true&amp;quot; value=&amp;quot;#{backingBean.customerId}&amp;quot; size=&amp;quot;40&amp;quot; maxlength=&amp;quot;80&amp;quot;&amp;gt;&amp;lt;/t:inputText&amp;gt;&lt;br /&gt;
 &amp;lt;t:inputSecret id=&amp;quot;j_password&amp;quot; forceId=&amp;quot;true&amp;quot; value=&amp;quot;#{backingBean.password}&amp;quot; size=&amp;quot;40&amp;quot; maxlength=&amp;quot;80&amp;quot; redisplay=&amp;quot;true&amp;quot;&amp;gt;&amp;lt;/t:inputSecret&amp;gt;&lt;br /&gt;
 &amp;lt;h:commandButton action=&amp;quot;login&amp;quot; value=&amp;quot;#{messages.page_signon}&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;h:messages id=&amp;quot;messages&amp;quot; layout=&amp;quot;table&amp;quot; globalOnly=&amp;quot;true&amp;quot; showSummary=&amp;quot;true&amp;quot; showDetail=&amp;quot;false&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A navigation rule to follow ACEGI requirements&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;navigation-rule&amp;gt;&lt;br /&gt;
        &amp;lt;from-view-id&amp;gt;/login.jsp&amp;lt;/from-view-id&amp;gt;&lt;br /&gt;
        &amp;lt;navigation-case&amp;gt;&lt;br /&gt;
                &amp;lt;from-outcome&amp;gt;login&amp;lt;/from-outcome&amp;gt;&lt;br /&gt;
                &amp;lt;to-view-id&amp;gt;/j_acegi_security_check.jsp&amp;lt;/to-view-id&amp;gt;&lt;br /&gt;
        &amp;lt;/navigation-case&amp;gt;&lt;br /&gt;
 &amp;lt;/navigation-rule&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And finaly ACEGI is told which page do the login&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;bean id=&amp;quot;formAuthenticationProcessingFilter&amp;quot; class=&amp;quot;org.acegisecurity.ui.webapp.AuthenticationProcessingFilter&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;property name=&amp;quot;filterProcessesUrl&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;value&amp;gt;/j_acegi_security_check.jsp&amp;lt;/value&amp;gt;&lt;br /&gt;
        &amp;lt;/property&amp;gt;&lt;br /&gt;
        &amp;lt;property name=&amp;quot;authenticationFailureUrl&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;value&amp;gt;/login.faces&amp;lt;/value&amp;gt;&lt;br /&gt;
        &amp;lt;/property&amp;gt;&lt;br /&gt;
        ...&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:OWASP Java Project]]&lt;/div&gt;</summary>
		<author><name>Stephendv</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Talk:Java_Server_Faces&amp;diff=24430</id>
		<title>Talk:Java Server Faces</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Talk:Java_Server_Faces&amp;diff=24430"/>
				<updated>2008-01-14T15:16:34Z</updated>
		
		<summary type="html">&lt;p&gt;Stephendv: /* EUxx discussion */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== EUxx discussion ==&lt;br /&gt;
I think the blog by EUxx missed some of the details of the implementation.  Note that while the MAC and the IV are known, there is still a secret key known to the server used in the MAC that prevents the client from generating a new MAC.  This is a fairly common pattern.  You can see Inderjeet's response at:&lt;br /&gt;
http://weblogs.java.net/blog/inder/archive/2005/05/securing_webapp.html&lt;br /&gt;
&lt;br /&gt;
I think we should either take this section out, or expand on why its an issue.&lt;br /&gt;
[[User:Ebing|Ebing]] 14:30, 11 June 2007 (EDT)&lt;br /&gt;
&lt;br /&gt;
Moved it here, till the author can correct [[User:Stephendv|Stephendv]] 10:16, 14 January 2008 (EST)&lt;br /&gt;
&lt;br /&gt;
===EUxx===&lt;br /&gt;
http://jroller.com/page/eu stated the following:&lt;br /&gt;
''It seems there are few gaps in this claim. Data sent to the client look like this: [MAC][IV][ENCDATA] As you can see, MAC and IV values are known to the client. It means that nothing can stop client from tampering ENCDATA block and then generate a new MAC. This can be improved with using signature based on public key scheme instead of MAC. However that will increase amount of computations for building message data and will require to store public key in HttpSession. Another potential security issue is related to the usage of block cipher. By the nature of Object Serialization Stream Protocol, every encrypted plain text will have common patterns. More over, because client can indirectly control content of the encrypted data by submitting specially crafted requests to the server, that some data from request will be sent back in encrypted form). This can open the door for &amp;quot;known-text&amp;quot; attack and I'm not sure how good &amp;quot;industrial-strength&amp;quot; ciphers against such attacks. Again, this can be improved by generating secure key for every request, but it will create additional troubles on concurrent scenarios and will require that key will be distributed across the cluster on every change. So, I think that above issues has to be investigated more deep and proper security analysis must be done before suggesting any solution that is using some forms of cryptography.''&lt;/div&gt;</summary>
		<author><name>Stephendv</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Java_Server_Faces&amp;diff=24429</id>
		<title>Java Server Faces</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Java_Server_Faces&amp;diff=24429"/>
				<updated>2008-01-14T15:15:44Z</updated>
		
		<summary type="html">&lt;p&gt;Stephendv: /* EUxx */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Status==&lt;br /&gt;
'''Content to be finalised.  Needs reviewing'''&lt;br /&gt;
==Author==&lt;br /&gt;
Sam Reghenzi&lt;br /&gt;
==Web security.. before you start ==&lt;br /&gt;
&lt;br /&gt;
This document is about security in web applications developed using the Java Server Faces (JSF) framework. The reader should be aware of the meaning of common terms of both JSF (converters, validators, managed beans) and web security (injection etc.)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==JSF Standards and roles==&lt;br /&gt;
JavaServer Faces (JSF) is a Java-based Web application framework that implements the Model-View-Controller pattern and simplifies the development of web interfaces for Java EE applications.&lt;br /&gt;
&lt;br /&gt;
In a standard MVC JSF are meant to provide the V (of view) and part of the C (of Control). JSF components can present almost any basic interface model. The framework also provides part of the Control layer including:&lt;br /&gt;
* Navigation Handling &lt;br /&gt;
* Error Handling &lt;br /&gt;
* Action and event Management &lt;br /&gt;
* Input validation &lt;br /&gt;
* Value conversion &lt;br /&gt;
These elements are defined by the JSF standard (JCP 127) so that any attacker will have knowledge of the architecture and life cycle of a JSF based application. JSF does not implement it's own security model but instead relies on standard JEE security. This means that both application server security model, JAAS or other ACL implementations can be used with the JSF framework without any integration effort. But Access Control is just one part of security - all aspects should be implemented in a secure manner in order to consider the application itself secure.&lt;br /&gt;
&lt;br /&gt;
==Client-side state saving==&lt;br /&gt;
A JSF application can save the state of its components in the client response or on the server. Saving state on the client may be required because some users turn off cookies support, but it can increase response times when connections are slow. Saving state on the server may have the disadvantage of high memory consumption for the user, but it does minimize bandwidth requirements.&lt;br /&gt;
Since client-side state saving stores data in the client , it should be used wisely, or not used at all. An attacker that can manipulate a user's data could manage a data tampering or worst, a privilege escalation exploit. Unencrypted data is quite easy to manipulate and most of the client-side saved data are serialized Java objects  which can contain a wealth of sensitive data. If you plan to use client-side state saving carefully consider which information you decide to store in the POJO/DTO in order to minimise these risks.&lt;br /&gt;
==Components==&lt;br /&gt;
===Converters===&lt;br /&gt;
Converter could be a source of threat since it converts string in Java objects. An attacker could inject malicious code or tampered data to make the converter itself misbehave and expose protected data. The converter system is not insecure by itself, but conversion, since it is a security touch point for business logic and persistent data, should be handled carefully. Input should '''always''' be validated '''after''' being converted. In JSF lingo you should '''always''' have a validator if a conversion occurs. See next section on how to implement a security aware validator.&lt;br /&gt;
&lt;br /&gt;
===Validators===&lt;br /&gt;
Validation is your chance to verify that the input is as expected. This means that the input should be validated both from a domain view and from a security view. If input represents a string that in your domain should be from 10 to 254 characters long, the same string should be validated also to prevent SQL Injection and XSS attacks. Since many security checks are done using dictionary algorithms it's useful to have a validator that implements those checks and extends it to implement your domain validator.&lt;br /&gt;
For example:&lt;br /&gt;
&lt;br /&gt;
 public class TenToHundredsValidator extends SecureValidator() {&lt;br /&gt;
    public void validate(...) {&lt;br /&gt;
       &lt;br /&gt;
       super.validate(...); // Do security checks&lt;br /&gt;
       &lt;br /&gt;
       domainvalidate(....);&lt;br /&gt;
    }&lt;br /&gt;
 }          &lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===ManagedBeans===&lt;br /&gt;
Managed beans are the gears of JSF based application. Developers can access FacesContext statically and this is potentially dangerous. This is a common short cut for everything in the JSF layer, but manipulating this data could be harmful. Relying on security principals, and software engineering, is always a good approach.&lt;br /&gt;
Calls such as:&lt;br /&gt;
    FacesContext.getCurrentInstance().getExternalContext().getRequestParameter(&amp;quot;name&amp;quot;)&lt;br /&gt;
are dangerous because the whole validation stack is bypassed. You can read parameters but consider them as tainted input. Use Validators described above also if you are not in the validation phase . Validators are also an effective way to refactor your validation code and to prevent code repetition.&lt;br /&gt;
FacesContext  also allows access to user principal data; this data could be used to verify if the current user can actually execute the business logic in the managed Bean.&lt;br /&gt;
This practice should be adopted in favour of rendering or not the commandLinks that lead to the action of the managed Bean. A structured adoption of an execution based security framework , such as ACEGI (see the Appendix), could be a good enforcement of the security of the  managed bean.&lt;br /&gt;
===Custom components===&lt;br /&gt;
If the use of custom components is required in the application, the security depends on how the components are developed. Third party components should be delivered with a security report and support from the specific vendor or community.&lt;br /&gt;
If you develop custom components you should be aware of the same old security issues of web development:&lt;br /&gt;
* Do not thrust request parameter &lt;br /&gt;
* Do not thrust cookies &lt;br /&gt;
* Always consider that session could be hijacked &lt;br /&gt;
Since the component tree is assembled server side it can be trusted so if your custom component needs to read data from a sibling component it should be considered a safe operation although you will have to make assumptions on element names of the tree.&lt;br /&gt;
==Implementations==&lt;br /&gt;
Since more than one JSF Implementation exists, bugs of the implementation should be first on the security list.&lt;br /&gt;
&lt;br /&gt;
===MyFaces===&lt;br /&gt;
There aren't major or critical security bugs registered in the current stable release of MyFaces (1.1.5). Client state saving is still the weak point and should be used wisely. My Faces comes also with a Security Extension  (http://wiki.apache.org/myfaces/SecurityContext) that allows to safely and easily retrieve authenticated user details.&lt;br /&gt;
&lt;br /&gt;
The MyFaces resource filter could be a source of threat. It is designed to expose resources from a jar file and could therefore, be considered, potentially dangerous. Note there aren't any claimed security flaws nor exploits in the resource filter, but the nature of this component makes it a good target for attackers. Since all it has to do is serve data it is recommended that a dispatcher be added to the filter mapping element. This should lower the possibility of an attacker successfully manipulating the server request.&lt;br /&gt;
For more information see: http://myfaces.apache.org/tomahawk/extensionsFilter.htm&lt;br /&gt;
&lt;br /&gt;
There is also an easy way to enable encryption when using ''client save state''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;context-param&amp;gt;&lt;br /&gt;
        &amp;lt;param-name&amp;gt;org.apache.myfaces.secret&amp;lt;/param-name&amp;gt;&lt;br /&gt;
        &amp;lt;param-value&amp;gt;NzY1NDMyMTA=&amp;lt;/param-value&amp;gt;&lt;br /&gt;
    &amp;lt;/context-param&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Supported encryption methods are BlowFish, 3DES, AES and are definde bya a context parameter&lt;br /&gt;
&lt;br /&gt;
&amp;lt;context-param&amp;gt;&lt;br /&gt;
        &amp;lt;param-name&amp;gt;org.apache.myfaces.algorithm&amp;lt;/param-name&amp;gt;&lt;br /&gt;
        &amp;lt;param-value&amp;gt;Blowfish&amp;lt;/param-value&amp;gt;&lt;br /&gt;
    &amp;lt;/context-param&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can find mre info at http://wiki.apache.org/myfaces/Secure_Your_Application&lt;br /&gt;
&lt;br /&gt;
===SUN Reference Implementation===&lt;br /&gt;
Quoting from the documentation:&lt;br /&gt;
''There are several ways for a web application to store session state on the client tier. One possible solution is to use Cookies to store the state on the client. However, cookies have limitations in size and are not ideal in cases where you want to store session state on the client.  The state that needs to be stored on the client is first serialized into a byte array. This byte array is then encrypted using industrial-strength 3DES with cipher-block-chaining (CBC) and an initialization vector. To make the content tamper-resistant, we then create a message authentication code (using SHA1 algorithm) from the encrypted content and the initialization vector. The initialization vector, the message authentication code, and the encrypted content is then combined in a single byte array. Finally, this resulting byte array is converted into a base64 string which is stored in a hidden FORM field on the client.&lt;br /&gt;
This solution is secure because it uses a strong crypto algorithm and also uses a MAC for tamper-resistance. We also generate all the random numbers (for example, to generate the initialization vectors and the password) using the cryptographically-secure SecureRandom class. Note that the encryption keys are NEVER sent to the client or sent on the wire. These keys are used only on the server-side to encrypt and decrypt the state. One challenge is to decide what encryption keys to use. The encryption keys should not be known to the client, but still be associated with the client. We solve this problem by generating these keys from a password that is generated randomly and stored in the HttpSession. This strategy for key generation through password is pluggable in our solution and can be changed if needed.''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===ICE Faces===&lt;br /&gt;
&lt;br /&gt;
Starting from the idea that AJAX on Its Own Doesn't Corrupt Web Security ICE faces implements a component suite with ajax support by maintainig a coninus sync bettween the dom sent to the browser and a dom rapresentation on the server. javascript is used to send commands to the server and invoke the logic in the java layer. Since dom model and javascript is involved a Javascript debugging  tool with value injection or dom injection capability could be of some use in pick loking the app.&lt;br /&gt;
&lt;br /&gt;
As stated in ICEFaces manual &amp;quot; the client is untrusted, SO DON'T TRUST IT!!&amp;quot; : it means that is all ups to the application designer to implement a robust security logic behind the scenes.&lt;br /&gt;
In another point of view th developer could focus on implement server side security since with the server-side-dom architecture the thin client is even thinner.&lt;br /&gt;
&lt;br /&gt;
The component thath refresh the two dom , caled IntervalRenderer, uses  a persistent ServletRequest stored on the server. Unfortunately, this request does not contain sufficient information to perform the isUserInRole() check.&lt;br /&gt;
This kind of check is possible only on stadar render request phase. &lt;br /&gt;
&lt;br /&gt;
To address this, a small amount of integration will be required either between ICEfaces and acegi-security or ICEfaces and the application server.  Acegi-security (see appendix one ) is likely preferable as it will be more portable.&lt;br /&gt;
&lt;br /&gt;
==Apendix I==&lt;br /&gt;
&lt;br /&gt;
===ACEGI Integration===&lt;br /&gt;
&lt;br /&gt;
Acegi Security is a powerful, flexible security solution for enterprise software, with a particular emphasis on applications that use Spring. If used in combination with jsf, the managed beans could become more &amp;quot;security aware&amp;quot; since acegi do not only perform authentication but also authorization in business layer. Acegi is a convenient way to manage security in all the layers of our application. This is a valuable thing especially when authorization is strongly coupled with business logic (approval work flows etc).&lt;br /&gt;
&lt;br /&gt;
In order to use a custom JSF-Acegi login we have to provide a valid Security Context (''userName'' and ''password'' are properties of the managed bean)&lt;br /&gt;
&lt;br /&gt;
 UsernamePasswordAuthenticationToken authReq = new UsernamePasswordAuthenticationToken(userName, password);&lt;br /&gt;
 Authentication auth = getAuthenticationManager().authenticate(authReq);&lt;br /&gt;
 SecurityContext secCtx = SecurityContextHolder.getContext();&lt;br /&gt;
 secCtx.setAuthentication(auth);&lt;br /&gt;
&lt;br /&gt;
We can override the standard ACEGI navigation with custom, logic driven, navigation reading security context and routing the outcome.&lt;br /&gt;
&lt;br /&gt;
More information can be found at  here [http://www.javakaffee.de/blog/2006/07/04/jsfacegi-authentication-with-a-backing-bean/]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
ACEGI can be integrated also in the rendering via custom components [http://cagataycivici.wordpress.com/2006/01/19/acegi_jsf_components_hit_the/] which basically wrap the standard ACEGI tag library in JSF components. This conveniently solve the ''stage zero'' of profiling: display or not a widget in the page.&lt;br /&gt;
&lt;br /&gt;
Including a JSF based form for login in a page could be a little tricky, bu using MyFaces tomahawk components it can be done easely.&lt;br /&gt;
&lt;br /&gt;
The form will look like&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;%@ taglib uri=&amp;quot;http://myfaces.apache.org/tomahawk&amp;quot; prefix=&amp;quot;t&amp;quot;%&amp;gt;&lt;br /&gt;
 &amp;lt;t:inputText id=&amp;quot;j_username&amp;quot; forceId=&amp;quot;true&amp;quot; value=&amp;quot;#{backingBean.customerId}&amp;quot; size=&amp;quot;40&amp;quot; maxlength=&amp;quot;80&amp;quot;&amp;gt;&amp;lt;/t:inputText&amp;gt;&lt;br /&gt;
 &amp;lt;t:inputSecret id=&amp;quot;j_password&amp;quot; forceId=&amp;quot;true&amp;quot; value=&amp;quot;#{backingBean.password}&amp;quot; size=&amp;quot;40&amp;quot; maxlength=&amp;quot;80&amp;quot; redisplay=&amp;quot;true&amp;quot;&amp;gt;&amp;lt;/t:inputSecret&amp;gt;&lt;br /&gt;
 &amp;lt;h:commandButton action=&amp;quot;login&amp;quot; value=&amp;quot;#{messages.page_signon}&amp;quot;/&amp;gt;&lt;br /&gt;
 &amp;lt;h:messages id=&amp;quot;messages&amp;quot; layout=&amp;quot;table&amp;quot; globalOnly=&amp;quot;true&amp;quot; showSummary=&amp;quot;true&amp;quot; showDetail=&amp;quot;false&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A navigation rule to follow ACEGI requirements&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;navigation-rule&amp;gt;&lt;br /&gt;
        &amp;lt;from-view-id&amp;gt;/login.jsp&amp;lt;/from-view-id&amp;gt;&lt;br /&gt;
        &amp;lt;navigation-case&amp;gt;&lt;br /&gt;
                &amp;lt;from-outcome&amp;gt;login&amp;lt;/from-outcome&amp;gt;&lt;br /&gt;
                &amp;lt;to-view-id&amp;gt;/j_acegi_security_check.jsp&amp;lt;/to-view-id&amp;gt;&lt;br /&gt;
        &amp;lt;/navigation-case&amp;gt;&lt;br /&gt;
 &amp;lt;/navigation-rule&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And finaly ACEGI is told which page do the login&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;bean id=&amp;quot;formAuthenticationProcessingFilter&amp;quot; class=&amp;quot;org.acegisecurity.ui.webapp.AuthenticationProcessingFilter&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;property name=&amp;quot;filterProcessesUrl&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;value&amp;gt;/j_acegi_security_check.jsp&amp;lt;/value&amp;gt;&lt;br /&gt;
        &amp;lt;/property&amp;gt;&lt;br /&gt;
        &amp;lt;property name=&amp;quot;authenticationFailureUrl&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;value&amp;gt;/login.faces&amp;lt;/value&amp;gt;&lt;br /&gt;
        &amp;lt;/property&amp;gt;&lt;br /&gt;
        ...&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:OWASP Java Project]]&lt;/div&gt;</summary>
		<author><name>Stephendv</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Java_Security_Frameworks&amp;diff=24428</id>
		<title>Java Security Frameworks</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Java_Security_Frameworks&amp;diff=24428"/>
				<updated>2008-01-14T15:07:29Z</updated>
		
		<summary type="html">&lt;p&gt;Stephendv: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;A list of third party (i.e. not part of Java SE or EE) security frameworks.&lt;br /&gt;
&lt;br /&gt;
==Enterprise==&lt;br /&gt;
* [http://www.owasp.org/index.php/ESAPI OWASP Enterprise Security API] a new OWASP project to provide all essential security services under one roof.&lt;br /&gt;
&lt;br /&gt;
== Access Control (Authentication and Authorisation) ==&lt;br /&gt;
* [http://www.acegisecurity.org/ Acegi Security] - Acegi Security is a powerful, flexible security solution for enterprise software, with a particular emphasis on applications that use Spring. Using Acegi Security provides your applications with comprehensive authentication, authorization, instance-based access control, channel security and human user detection capabilities.&lt;br /&gt;
* [http://sourceforge.net/projects/jguard jGuard] - jGuard is written in java. his goal is to provide a security framework based on jaas (java authentication and authorization security) . this framework is written for web and standalone applications, to resolve simply, access control problems.&lt;br /&gt;
== Encryption ==&lt;br /&gt;
* [http://www.bouncycastle.org/ Bouncycastle] - Lightweight Java cryptography APIs&lt;br /&gt;
* [http://www.jasypt.org/ Jasypt] - Jasypt is a java library which allows the developer to add basic encryption capabilities to his/her projects with minimum effort, and without the need of having deep knowledge on how cryptography works.&lt;br /&gt;
&lt;br /&gt;
[[Category:OWASP Java Project]]&lt;/div&gt;</summary>
		<author><name>Stephendv</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=How_to_perform_HTML_entity_encoding_in_Java&amp;diff=24425</id>
		<title>How to perform HTML entity encoding in Java</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=How_to_perform_HTML_entity_encoding_in_Java&amp;diff=24425"/>
				<updated>2008-01-14T14:52:40Z</updated>
		
		<summary type="html">&lt;p&gt;Stephendv: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Status==&lt;br /&gt;
Released 14/1/2008&lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
&lt;br /&gt;
Injection attacks rely on the fact that interpreters take data and execute it as commands. If an attacker can modify the data that's sent to an interpreter, they may be able to make it misbehave. One way to help prevent this from happening is to encode the attacker's data in such a way that the interpreter will not get confused. [http://www.w3.org/TR/html401/sgml/entities.html HTML entity encoding] is just such an encoding mechanism for many interpreters.&lt;br /&gt;
&lt;br /&gt;
This is not a guarantee by the way. It's almost certain that someone, probably from the XML/Web Services world, will create an engine that performs HTML entity decoding automatically, thus reintroducing the injection threat.  However, for the time being, HTML entity encoding seems to work pretty well to prevent many types of injection.&lt;br /&gt;
&lt;br /&gt;
==Status==&lt;br /&gt;
Released 14/1/2007&lt;br /&gt;
&lt;br /&gt;
==Approach==&lt;br /&gt;
&lt;br /&gt;
We're going to implement a simple little method that encodes special characters. The nice .NET folks over at Microsoft had the foresight to build this into their platform, but the Java community seems to resist adding validation to the Java EE environment despite all the security issues that it could solve.  View layers such as Java Server Faces, Spring-MVC, WebWork and others automatically perform HTML encoding through custom tags.&lt;br /&gt;
&lt;br /&gt;
The best place for this method is in some kind of ValidationEngine, but since it's a good candidate for being static, it doesn't matter what class it ends up in that much.&lt;br /&gt;
&lt;br /&gt;
Note that this implementation doesn't produce the special characters like &amp;amp; lt; or &amp;amp; gt; - but it's not difficult to implement with a simple lookup table.&lt;br /&gt;
&lt;br /&gt;
    public static String HTMLEntityEncode( String s )&lt;br /&gt;
    {&lt;br /&gt;
        StringBuffer buf = new StringBuffer();&lt;br /&gt;
        int len = (s == null ? -1 : s.length());&lt;br /&gt;
 &lt;br /&gt;
        for ( int i = 0; i &amp;lt; len; i++ )&lt;br /&gt;
        {&lt;br /&gt;
            char c = s.charAt( i );&lt;br /&gt;
            if ( c&amp;gt;='a' &amp;amp;&amp;amp; c&amp;lt;='z' || c&amp;gt;='A' &amp;amp;&amp;amp; c&amp;lt;='Z' || c&amp;gt;='0' &amp;amp;&amp;amp; c&amp;lt;='9' )&lt;br /&gt;
            {&lt;br /&gt;
                buf.append( c );&lt;br /&gt;
            }&lt;br /&gt;
            else&lt;br /&gt;
            {&lt;br /&gt;
                buf.append( &amp;quot;&amp;amp;#&amp;quot; + (int)c + &amp;quot;;&amp;quot; );&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        return buf.toString();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
==Libraries==&lt;br /&gt;
* The Jakara Commons Lang package has a generic class for performing a wide range of [http://commons.apache.org/lang/api-release/org/apache/commons/lang/StringEscapeUtils.html String escaping functions]. &lt;br /&gt;
* jTidy includes an [http://jtidy.sourceforge.net/multiproject/jtidyservlet/apidocs/org/w3c/tidy/servlet/util/HTMLEncode.html HTMLEncode class] for performing HTML encoding.&lt;br /&gt;
&lt;br /&gt;
[[Category:How To]]&lt;br /&gt;
[[Category:OWASP Java Project]]&lt;br /&gt;
[[Category:OWASP Validation Project]]&lt;/div&gt;</summary>
		<author><name>Stephendv</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=How_to_perform_HTML_entity_encoding_in_Java&amp;diff=24424</id>
		<title>How to perform HTML entity encoding in Java</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=How_to_perform_HTML_entity_encoding_in_Java&amp;diff=24424"/>
				<updated>2008-01-14T14:52:19Z</updated>
		
		<summary type="html">&lt;p&gt;Stephendv: /* Overview */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Status&lt;br /&gt;
Released 14/1/2008&lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
&lt;br /&gt;
Injection attacks rely on the fact that interpreters take data and execute it as commands. If an attacker can modify the data that's sent to an interpreter, they may be able to make it misbehave. One way to help prevent this from happening is to encode the attacker's data in such a way that the interpreter will not get confused. [http://www.w3.org/TR/html401/sgml/entities.html HTML entity encoding] is just such an encoding mechanism for many interpreters.&lt;br /&gt;
&lt;br /&gt;
This is not a guarantee by the way. It's almost certain that someone, probably from the XML/Web Services world, will create an engine that performs HTML entity decoding automatically, thus reintroducing the injection threat.  However, for the time being, HTML entity encoding seems to work pretty well to prevent many types of injection.&lt;br /&gt;
&lt;br /&gt;
==Status==&lt;br /&gt;
Released 14/1/2007&lt;br /&gt;
&lt;br /&gt;
==Approach==&lt;br /&gt;
&lt;br /&gt;
We're going to implement a simple little method that encodes special characters. The nice .NET folks over at Microsoft had the foresight to build this into their platform, but the Java community seems to resist adding validation to the Java EE environment despite all the security issues that it could solve.  View layers such as Java Server Faces, Spring-MVC, WebWork and others automatically perform HTML encoding through custom tags.&lt;br /&gt;
&lt;br /&gt;
The best place for this method is in some kind of ValidationEngine, but since it's a good candidate for being static, it doesn't matter what class it ends up in that much.&lt;br /&gt;
&lt;br /&gt;
Note that this implementation doesn't produce the special characters like &amp;amp; lt; or &amp;amp; gt; - but it's not difficult to implement with a simple lookup table.&lt;br /&gt;
&lt;br /&gt;
    public static String HTMLEntityEncode( String s )&lt;br /&gt;
    {&lt;br /&gt;
        StringBuffer buf = new StringBuffer();&lt;br /&gt;
        int len = (s == null ? -1 : s.length());&lt;br /&gt;
 &lt;br /&gt;
        for ( int i = 0; i &amp;lt; len; i++ )&lt;br /&gt;
        {&lt;br /&gt;
            char c = s.charAt( i );&lt;br /&gt;
            if ( c&amp;gt;='a' &amp;amp;&amp;amp; c&amp;lt;='z' || c&amp;gt;='A' &amp;amp;&amp;amp; c&amp;lt;='Z' || c&amp;gt;='0' &amp;amp;&amp;amp; c&amp;lt;='9' )&lt;br /&gt;
            {&lt;br /&gt;
                buf.append( c );&lt;br /&gt;
            }&lt;br /&gt;
            else&lt;br /&gt;
            {&lt;br /&gt;
                buf.append( &amp;quot;&amp;amp;#&amp;quot; + (int)c + &amp;quot;;&amp;quot; );&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        return buf.toString();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
==Libraries==&lt;br /&gt;
* The Jakara Commons Lang package has a generic class for performing a wide range of [http://commons.apache.org/lang/api-release/org/apache/commons/lang/StringEscapeUtils.html String escaping functions]. &lt;br /&gt;
* jTidy includes an [http://jtidy.sourceforge.net/multiproject/jtidyservlet/apidocs/org/w3c/tidy/servlet/util/HTMLEncode.html HTMLEncode class] for performing HTML encoding.&lt;br /&gt;
&lt;br /&gt;
[[Category:How To]]&lt;br /&gt;
[[Category:OWASP Java Project]]&lt;br /&gt;
[[Category:OWASP Validation Project]]&lt;/div&gt;</summary>
		<author><name>Stephendv</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Talk:How_to_perform_HTML_entity_encoding_in_Java&amp;diff=24423</id>
		<title>Talk:How to perform HTML entity encoding in Java</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Talk:How_to_perform_HTML_entity_encoding_in_Java&amp;diff=24423"/>
				<updated>2008-01-14T14:51:11Z</updated>
		
		<summary type="html">&lt;p&gt;Stephendv: /* Status */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Status==&lt;br /&gt;
Released [[User:Stephendv|Stephendv]] 09:51, 14 January 2008 (EST)&lt;br /&gt;
&lt;br /&gt;
==Reviewers==&lt;br /&gt;
* Dave Read&lt;br /&gt;
&lt;br /&gt;
==General Discussion==&lt;br /&gt;
&lt;br /&gt;
The Apache Jakarta Commons Lang package (as of version 2.2) contains a StringEscapeUtils class that contains this functionality.  See the escapeHtml(String) method.  The documentation states: &lt;br /&gt;
&lt;br /&gt;
    Escapes the characters in a String using HTML entities.&lt;br /&gt;
&lt;br /&gt;
    Supports all known HTML 4.0 entities, including funky accents. Note that the commonly used apostrophe escape character (&amp;amp;apos;) is not a legal entity and so is not supported).&lt;/div&gt;</summary>
		<author><name>Stephendv</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Talk:How_to_perform_HTML_entity_encoding_in_Java&amp;diff=24422</id>
		<title>Talk:How to perform HTML entity encoding in Java</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Talk:How_to_perform_HTML_entity_encoding_in_Java&amp;diff=24422"/>
				<updated>2008-01-14T14:45:28Z</updated>
		
		<summary type="html">&lt;p&gt;Stephendv: /* Reviewers */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Status==&lt;br /&gt;
Needs review&lt;br /&gt;
&lt;br /&gt;
==Reviewers==&lt;br /&gt;
* Dave Read&lt;br /&gt;
&lt;br /&gt;
==General Discussion==&lt;br /&gt;
&lt;br /&gt;
The Apache Jakarta Commons Lang package (as of version 2.2) contains a StringEscapeUtils class that contains this functionality.  See the escapeHtml(String) method.  The documentation states: &lt;br /&gt;
&lt;br /&gt;
    Escapes the characters in a String using HTML entities.&lt;br /&gt;
&lt;br /&gt;
    Supports all known HTML 4.0 entities, including funky accents. Note that the commonly used apostrophe escape character (&amp;amp;apos;) is not a legal entity and so is not supported).&lt;/div&gt;</summary>
		<author><name>Stephendv</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=How_to_perform_HTML_entity_encoding_in_Java&amp;diff=24420</id>
		<title>How to perform HTML entity encoding in Java</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=How_to_perform_HTML_entity_encoding_in_Java&amp;diff=24420"/>
				<updated>2008-01-14T14:38:12Z</updated>
		
		<summary type="html">&lt;p&gt;Stephendv: /* Approach */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Overview==&lt;br /&gt;
&lt;br /&gt;
Injection attacks rely on the fact that interpreters take data and execute it as commands. If an attacker can modify the data that's sent to an interpreter, they may be able to make it misbehave. One way to help prevent this from happening is to encode the attacker's data in such a way that the interpreter will not get confused. [http://www.w3.org/TR/html401/sgml/entities.html HTML entity encoding] is just such an encoding mechanism for many interpreters.&lt;br /&gt;
&lt;br /&gt;
This is not a guarantee by the way. It's almost certain that someone, probably from the XML/Web Services world, will create an engine that performs HTML entity decoding automatically, thus reintroducing the injection threat.  However, for the time being, HTML entity encoding seems to work pretty well to prevent many types of injection.&lt;br /&gt;
&lt;br /&gt;
==Status==&lt;br /&gt;
Released 14/1/2007&lt;br /&gt;
&lt;br /&gt;
==Approach==&lt;br /&gt;
&lt;br /&gt;
We're going to implement a simple little method that encodes special characters. The nice .NET folks over at Microsoft had the foresight to build this into their platform, but the Java community seems to resist adding validation to the Java EE environment despite all the security issues that it could solve.  View layers such as Java Server Faces, Spring-MVC, WebWork and others automatically perform HTML encoding through custom tags.&lt;br /&gt;
&lt;br /&gt;
The best place for this method is in some kind of ValidationEngine, but since it's a good candidate for being static, it doesn't matter what class it ends up in that much.&lt;br /&gt;
&lt;br /&gt;
Note that this implementation doesn't produce the special characters like &amp;amp; lt; or &amp;amp; gt; - but it's not difficult to implement with a simple lookup table.&lt;br /&gt;
&lt;br /&gt;
    public static String HTMLEntityEncode( String s )&lt;br /&gt;
    {&lt;br /&gt;
        StringBuffer buf = new StringBuffer();&lt;br /&gt;
        int len = (s == null ? -1 : s.length());&lt;br /&gt;
 &lt;br /&gt;
        for ( int i = 0; i &amp;lt; len; i++ )&lt;br /&gt;
        {&lt;br /&gt;
            char c = s.charAt( i );&lt;br /&gt;
            if ( c&amp;gt;='a' &amp;amp;&amp;amp; c&amp;lt;='z' || c&amp;gt;='A' &amp;amp;&amp;amp; c&amp;lt;='Z' || c&amp;gt;='0' &amp;amp;&amp;amp; c&amp;lt;='9' )&lt;br /&gt;
            {&lt;br /&gt;
                buf.append( c );&lt;br /&gt;
            }&lt;br /&gt;
            else&lt;br /&gt;
            {&lt;br /&gt;
                buf.append( &amp;quot;&amp;amp;#&amp;quot; + (int)c + &amp;quot;;&amp;quot; );&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        return buf.toString();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
==Libraries==&lt;br /&gt;
* The Jakara Commons Lang package has a generic class for performing a wide range of [http://commons.apache.org/lang/api-release/org/apache/commons/lang/StringEscapeUtils.html String escaping functions]. &lt;br /&gt;
* jTidy includes an [http://jtidy.sourceforge.net/multiproject/jtidyservlet/apidocs/org/w3c/tidy/servlet/util/HTMLEncode.html HTMLEncode class] for performing HTML encoding.&lt;br /&gt;
&lt;br /&gt;
[[Category:How To]]&lt;br /&gt;
[[Category:OWASP Java Project]]&lt;br /&gt;
[[Category:OWASP Validation Project]]&lt;/div&gt;</summary>
		<author><name>Stephendv</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Talk:How_to_add_validation_logic_to_HttpServletRequest&amp;diff=24418</id>
		<title>Talk:How to add validation logic to HttpServletRequest</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Talk:How_to_add_validation_logic_to_HttpServletRequest&amp;diff=24418"/>
				<updated>2008-01-14T14:27:54Z</updated>
		
		<summary type="html">&lt;p&gt;Stephendv: /* Status */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Status==&lt;br /&gt;
Reviewed and released [[User:Stephendv|Stephendv]] 09:27, 14 January 2008 (EST)&lt;br /&gt;
&lt;br /&gt;
==Reviewers==&lt;br /&gt;
* Stephen de Vries&lt;br /&gt;
&lt;br /&gt;
==General Discussion==&lt;/div&gt;</summary>
		<author><name>Stephendv</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Talk:How_to_add_validation_logic_to_HttpServletRequest&amp;diff=24415</id>
		<title>Talk:How to add validation logic to HttpServletRequest</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Talk:How_to_add_validation_logic_to_HttpServletRequest&amp;diff=24415"/>
				<updated>2008-01-14T14:22:32Z</updated>
		
		<summary type="html">&lt;p&gt;Stephendv: /* Reviewers */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Status==&lt;br /&gt;
Needs review&lt;br /&gt;
&lt;br /&gt;
==Reviewers==&lt;br /&gt;
* Stephen de Vries&lt;br /&gt;
&lt;br /&gt;
==General Discussion==&lt;/div&gt;</summary>
		<author><name>Stephendv</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Hashing_Java&amp;diff=24414</id>
		<title>Hashing Java</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Hashing_Java&amp;diff=24414"/>
				<updated>2008-01-14T13:10:45Z</updated>
		
		<summary type="html">&lt;p&gt;Stephendv: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Status ==&lt;br /&gt;
Released 14/1/2008&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
Most of today’s applications use login/password in order to authenticate. Users often use the same login/password for different kinds of applications. If the couple is stolen, everybody can access all the applications the user has access to. &lt;br /&gt;
&lt;br /&gt;
Too often passwords are stored as clear text. Thus the password can be read directly by the database’s administrator, super users or SQL Injection attack etc. The backup media is also vulnerable. &lt;br /&gt;
In order to solve this problem, passwords must be stored encrypted. Two kinds of encryption are available:&lt;br /&gt;
* One way functions (SHA-256 SHA-1 MD5, ..;) also known as Hashing functions&lt;br /&gt;
* Reversible encryption functions (DES, AES, …). &lt;br /&gt;
However, the reversible property of encryption function is useless for credentials storing (cf. OWASP Guide v2.0.1) :&lt;br /&gt;
&lt;br /&gt;
''Passwords are secrets. There is no reason to decrypt them under any circumstances. Helpdesk staff should be able to set new passwords (with an audit trail, obviously), not read back old passwords. Therefore, there is no reason to store passwords in a reversible form.''&lt;br /&gt;
&lt;br /&gt;
==Definition of  cryptographic Hashing function:==&lt;br /&gt;
A Hash function creates a fixed length small fingerprint (or message digest) from an unlimited input string.&lt;br /&gt;
&lt;br /&gt;
hash(X) -&amp;gt;Y          X is a infinite set and Y is a finite set.&lt;br /&gt;
&lt;br /&gt;
A good cryptographic Hash function must have these properties: &lt;br /&gt;
* Preimage  resistant : From the function output y it must impossible to compute the input x such that hash(x)=y. &lt;br /&gt;
* Second preimage  resistant : from an input x1 it must impossible to compute another input x2 (different of x1) such that hash(x1)=hash(x2).&lt;br /&gt;
* Collision resistant : It must be difficult to find two inputs x1 and x2 (x1&amp;lt;&amp;gt;x2) such that hash(x1)=hash(x2).&lt;br /&gt;
&lt;br /&gt;
'''Sample java code :''' &lt;br /&gt;
  import java.security.MessageDigest;&lt;br /&gt;
  &lt;br /&gt;
  public byte[] getHash(String password) throws NoSuchAlgorithmException {&lt;br /&gt;
        MessageDigest digest = MessageDigest.getInstance(&amp;quot;SHA-1&amp;quot;);&lt;br /&gt;
        digest.reset();&lt;br /&gt;
        byte[] input = digest.digest(password.getBytes(&amp;quot;UTF-8&amp;quot;));&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
==Credential storage.==&lt;br /&gt;
&lt;br /&gt;
If the password’s digest is stored in a database, an attacker should be unable to recover the password thanks to the preimage resistance. The only way to go past this would be a [[Brute force attack|brute force attack]], i.e. computing the hash of all possible passwords or a dictionary attack, i.e. computing all the often used password.&lt;br /&gt;
&lt;br /&gt;
==Why add salt ? ==&lt;br /&gt;
&lt;br /&gt;
There are two drawbacks to choosing to only store the password’s hash: &lt;br /&gt;
*	It is possible to identify two identical passwords.&lt;br /&gt;
*	Due to the birthday paradox (http://en.wikipedia.org/wiki/Birthday_paradox), the attacker can find a password very quickly especially if the number of password is important in the database.&lt;br /&gt;
&lt;br /&gt;
In order to solve these problems, a salt can be concatenated to the password before the digest operation. &lt;br /&gt;
&lt;br /&gt;
A salt is a random number of a fixed length. This salt must be different for each stored entry. It must be stored as clear text next to the hashed password.&lt;br /&gt;
&lt;br /&gt;
In this configuration, an attacker must handle a brute force attack on each individual password. The database is now birthday attack resistant.&lt;br /&gt;
&lt;br /&gt;
A 64 bits salt is recommended in RSA PKCS5 standard.&lt;br /&gt;
&lt;br /&gt;
'''Sample java code :''' &lt;br /&gt;
  import java.security.MessageDigest;&lt;br /&gt;
  &lt;br /&gt;
  &lt;br /&gt;
  public byte[] getHash(String password, byte[] salt) throws NoSuchAlgorithmException {&lt;br /&gt;
        MessageDigest digest = MessageDigest.getInstance(&amp;quot;SHA-256&amp;quot;);&lt;br /&gt;
        digest.reset();&lt;br /&gt;
        digest.update(salt);&lt;br /&gt;
        return digest.digest(password.getBytes(&amp;quot;UTF-8&amp;quot;));&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
==Hardening against the attacker's attack==&lt;br /&gt;
&lt;br /&gt;
To slow down the computation it is recommended to iterate the hash operation n times. While hashing the password n times does slow down hashing for both attackers and typical users, typical users don't really notice it being that hashing is such a small percentage of their total time interacting with the system. On the other hand, an attacker trying to crack passwords spends nearly 100% of their time hashing so hashing n times gives the appearance of slowing the attacker down by a factor of n while not noticeably affecting the typical user. &lt;br /&gt;
A minimum of 1000 operations is recommended in RSA PKCS5 standard.&lt;br /&gt;
&lt;br /&gt;
The stored password looks like this :&lt;br /&gt;
		Hash(hash(hash(hash(……….hash(password||salt)))))))))))))))&lt;br /&gt;
&lt;br /&gt;
To authenticate a user, the operation same as above must be performed, followed by a comparison of the two hashes.&lt;br /&gt;
&lt;br /&gt;
The hash function you need to use depends of your security policy. SHA-256 or SHA-512 is recommended for long term storage.&lt;br /&gt;
&lt;br /&gt;
'''Sample java code :''' &lt;br /&gt;
  import java.security.*;&lt;br /&gt;
  &lt;br /&gt;
  &lt;br /&gt;
   public byte[] getHash(int iterationNb, String password, byte[] salt) throws NoSuchAlgorithmException {&lt;br /&gt;
        MessageDigest digest = MessageDigest.getInstance(&amp;quot;SHA-1&amp;quot;);&lt;br /&gt;
        digest.reset();&lt;br /&gt;
        digest.update(salt);&lt;br /&gt;
        byte[] input = digest.digest(password.getBytes(&amp;quot;UTF-8&amp;quot;));&lt;br /&gt;
        for (int i = 0; i &amp;lt; iterationNb; i++) {&lt;br /&gt;
            digest.reset();&lt;br /&gt;
            input = digest.digest(input);&lt;br /&gt;
        }&lt;br /&gt;
        return input;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
==Complete Java Sample==&lt;br /&gt;
In order to create the table needed by this application, call the method creerTable().&lt;br /&gt;
It creates a TABLE called CREDENTIAL, with these fields : &lt;br /&gt;
* LOGIN VARCHAR (100)  PRIMARY KEY&lt;br /&gt;
* PASSWORD VARCHAR (32)&lt;br /&gt;
* SALT VARCHAR (32)&lt;br /&gt;
&lt;br /&gt;
In this database, the password and the salt are stored in Base64 representation.&lt;br /&gt;
&lt;br /&gt;
The method ''authenticate'' is used in order to authenticate a user, the method ''createUser'' is used to create a new user.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  package org.psafix.memopwd;&lt;br /&gt;
  &lt;br /&gt;
  import java.security.MessageDigest;&lt;br /&gt;
  import java.security.NoSuchAlgorithmException;&lt;br /&gt;
  import java.io.IOException;&lt;br /&gt;
  import sun.misc.BASE64Decoder;&lt;br /&gt;
  import sun.misc.BASE64Encoder;&lt;br /&gt;
  import java.sql.*;&lt;br /&gt;
  import java.util.Arrays;&lt;br /&gt;
  import java.security.SecureRandom;&lt;br /&gt;
  &lt;br /&gt;
  public class Owasp {&lt;br /&gt;
    private final static int ITERATION_NUMBER = 1000;&lt;br /&gt;
  &lt;br /&gt;
    public Owasp() {&lt;br /&gt;
    }&lt;br /&gt;
  &lt;br /&gt;
    /**&lt;br /&gt;
     * Authenticates the user with a given login and password&lt;br /&gt;
     * If password and/or login is null then always returns false.&lt;br /&gt;
     * If the user does not exist in the database returns false.&lt;br /&gt;
     * @param con Connection An open connection to a databse&lt;br /&gt;
     * @param login String The login of the user&lt;br /&gt;
     * @param password String The password of the user&lt;br /&gt;
     * @return boolean Returns true if the user is authenticated, false otherwise&lt;br /&gt;
     * @throws SQLException If the database is inconsistent or unavailable (&lt;br /&gt;
     *           (Two users with the same login, salt or digested password altered etc.)&lt;br /&gt;
     * @throws NoSuchAlgorithmException If the algorithm SHA-1 is not supported by the JVM&lt;br /&gt;
     */&lt;br /&gt;
    public boolean authenticate(Connection con, String login, String password)&lt;br /&gt;
            throws SQLException, NoSuchAlgorithmException{&lt;br /&gt;
        boolean authenticated=false;&lt;br /&gt;
        PreparedStatement ps = null;&lt;br /&gt;
        ResultSet rs = null;&lt;br /&gt;
        try {&lt;br /&gt;
            boolean userExist = true;&lt;br /&gt;
            // INPUT VALIDATION&lt;br /&gt;
            if (login==null||password==null){&lt;br /&gt;
                // TIME RESISTANT ATTACK&lt;br /&gt;
                // Computation time is equal to the time needed by a legitimate user&lt;br /&gt;
                userExist = false;&lt;br /&gt;
                login=&amp;quot;&amp;quot;;&lt;br /&gt;
                password=&amp;quot;&amp;quot;;&lt;br /&gt;
            }&lt;br /&gt;
  &lt;br /&gt;
            ps = con.prepareStatement(&amp;quot;SELECT PASSWORD, SALT FROM CREDENTIAL WHERE LOGIN = ?&amp;quot;);&lt;br /&gt;
            ps.setString(1, login);&lt;br /&gt;
            rs = ps.executeQuery();&lt;br /&gt;
            String digest, salt;&lt;br /&gt;
            if (rs.next()) {&lt;br /&gt;
                digest = rs.getString(&amp;quot;PASSWORD&amp;quot;);&lt;br /&gt;
                salt = rs.getString(&amp;quot;SALT&amp;quot;);&lt;br /&gt;
                // DATABASE VALIDATION&lt;br /&gt;
                if (digest == null || salt == null) {&lt;br /&gt;
                    throw new SQLException(&amp;quot;Database inconsistant Salt or Digested Password altered&amp;quot;);&lt;br /&gt;
                }&lt;br /&gt;
                if (rs.next()) { // Should not append, because login is the primary key&lt;br /&gt;
                    throw new SQLException(&amp;quot;Database inconsistent two CREDENTIALS with the same LOGIN&amp;quot;);&lt;br /&gt;
                }&lt;br /&gt;
            } else { // TIME RESISTANT ATTACK (Even if the user does not exist the&lt;br /&gt;
                // Computation time is equal to the time needed for a legitimate user&lt;br /&gt;
                digest = &amp;quot;000000000000000000000000000=&amp;quot;;&lt;br /&gt;
                salt = &amp;quot;00000000000=&amp;quot;;&lt;br /&gt;
                userExist = false;&lt;br /&gt;
            }&lt;br /&gt;
  &lt;br /&gt;
            byte[] bDigest = base64ToByte(digest);&lt;br /&gt;
            byte[] bSalt = base64ToByte(salt);&lt;br /&gt;
  &lt;br /&gt;
            // Compute the new DIGEST&lt;br /&gt;
            byte[] proposedDigest = getHash(ITERATION_NUMBER, password, bSalt);&lt;br /&gt;
  &lt;br /&gt;
            return Arrays.equals(proposedDigest, bDigest) &amp;amp;&amp;amp; userExist;&lt;br /&gt;
        } catch (IOException ex){&lt;br /&gt;
            throw new SQLException(&amp;quot;Database inconsistant Salt or Digested Password altered&amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
        finally{&lt;br /&gt;
            close(rs);&lt;br /&gt;
            close(ps);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
  &lt;br /&gt;
  &lt;br /&gt;
  &lt;br /&gt;
    /**&lt;br /&gt;
     * Inserts a new user in the database&lt;br /&gt;
     * @param con Connection An open connection to a databse&lt;br /&gt;
     * @param login String The login of the user&lt;br /&gt;
     * @param password String The password of the user&lt;br /&gt;
     * @return boolean Returns true if the login and password are ok (not null and length(login)&amp;lt;=100&lt;br /&gt;
     * @throws SQLException If the database is unavailable&lt;br /&gt;
     * @throws NoSuchAlgorithmException If the algorithm SHA-1 or the SecureRandom is not supported by the JVM&lt;br /&gt;
     */&lt;br /&gt;
    public boolean createUser(Connection con, String login, String password)&lt;br /&gt;
            throws SQLException, NoSuchAlgorithmException&lt;br /&gt;
    {&lt;br /&gt;
        PreparedStatement ps = null;&lt;br /&gt;
        try {&lt;br /&gt;
            if (login!=null&amp;amp;&amp;amp;password!=null&amp;amp;&amp;amp;login.length()&amp;lt;=100){&lt;br /&gt;
                // Uses a secure Random not a simple Random&lt;br /&gt;
                SecureRandom random = SecureRandom.getInstance(&amp;quot;SHA1PRNG&amp;quot;);&lt;br /&gt;
                // Salt generation 64 bits long&lt;br /&gt;
                byte[] bSalt = new byte[8];&lt;br /&gt;
                random.nextBytes(bSalt);&lt;br /&gt;
                // Digest computation&lt;br /&gt;
                byte[] bDigest = getHash(ITERATION_NUMBER,password,bSalt);&lt;br /&gt;
                String sDigest = byteToBase64(bDigest);&lt;br /&gt;
                String sSalt = byteToBase64(bSalt);&lt;br /&gt;
  &lt;br /&gt;
                ps = con.prepareStatement(&amp;quot;INSERT INTO CREDENTIAL (LOGIN, PASSWORD, SALT) VALUES (?,?,?)&amp;quot;);&lt;br /&gt;
                ps.setString(1,login);&lt;br /&gt;
                ps.setString(2,sDigest);&lt;br /&gt;
                ps.setString(3,sSalt);&lt;br /&gt;
                ps.executeUpdate();&lt;br /&gt;
                return true;&lt;br /&gt;
            } else {&lt;br /&gt;
                return false;&lt;br /&gt;
            }&lt;br /&gt;
        } finally {&lt;br /&gt;
            close(ps);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
  &lt;br /&gt;
  &lt;br /&gt;
    /**&lt;br /&gt;
     * From a password, a number of iterations and a salt,&lt;br /&gt;
     * returns the corresponding digest&lt;br /&gt;
     * @param iterationNb int The number of iterations of the algorithm&lt;br /&gt;
     * @param password String The password to encrypt&lt;br /&gt;
     * @param salt byte[] The salt&lt;br /&gt;
     * @return byte[] The digested password&lt;br /&gt;
     * @throws NoSuchAlgorithmException If the algorithm doesn't exist&lt;br /&gt;
     */&lt;br /&gt;
    public byte[] getHash(int iterationNb, String password, byte[] salt) throws NoSuchAlgorithmException {&lt;br /&gt;
        MessageDigest digest = MessageDigest.getInstance(&amp;quot;SHA-1&amp;quot;);&lt;br /&gt;
        digest.reset();&lt;br /&gt;
        digest.update(salt);&lt;br /&gt;
        byte[] input = digest.digest(password.getBytes(&amp;quot;UTF-8&amp;quot;));&lt;br /&gt;
        for (int i = 0; i &amp;lt; iterationNb; i++) {&lt;br /&gt;
            digest.reset();&lt;br /&gt;
            input = digest.digest(input);&lt;br /&gt;
        }&lt;br /&gt;
        return input;&lt;br /&gt;
    }&lt;br /&gt;
  &lt;br /&gt;
  &lt;br /&gt;
    public void creerTable(Connection con) throws SQLException{&lt;br /&gt;
        Statement st = null;&lt;br /&gt;
        try {&lt;br /&gt;
            st = con.createStatement();&lt;br /&gt;
            st.execute(&amp;quot;CREATE TABLE CREDENTIAL (LOGIN VARCHAR(100) PRIMARY KEY, PASSWORD VARCHAR(32) NOT NULL, SALT VARCHAR(32) NOT NULL)&amp;quot;);&lt;br /&gt;
        } finally {&lt;br /&gt;
            close(st);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
  &lt;br /&gt;
  &lt;br /&gt;
  &lt;br /&gt;
    /**&lt;br /&gt;
     * Closes the current statement&lt;br /&gt;
     * @param ps Statement&lt;br /&gt;
     */&lt;br /&gt;
    public void close(Statement ps) {&lt;br /&gt;
        if (ps!=null){&lt;br /&gt;
            try {&lt;br /&gt;
                ps.close();&lt;br /&gt;
            } catch (SQLException ignore) {&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
  &lt;br /&gt;
    /**&lt;br /&gt;
     * Closes the current resultset&lt;br /&gt;
     * @param ps Statement&lt;br /&gt;
     */&lt;br /&gt;
    public void close(ResultSet rs) {&lt;br /&gt;
        if (rs!=null){&lt;br /&gt;
            try {&lt;br /&gt;
                rs.close();&lt;br /&gt;
            } catch (SQLException ignore) {&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
  &lt;br /&gt;
  &lt;br /&gt;
    /**&lt;br /&gt;
     * From a base 64 representation, returns the corresponding byte[] &lt;br /&gt;
     * @param data String The base64 representation&lt;br /&gt;
     * @return byte[]&lt;br /&gt;
     * @throws IOException&lt;br /&gt;
     */&lt;br /&gt;
    public static byte[] base64ToByte(String data) throws IOException {&lt;br /&gt;
        BASE64Decoder decoder = new BASE64Decoder();&lt;br /&gt;
        return decoder.decodeBuffer(data);&lt;br /&gt;
    }&lt;br /&gt;
  &lt;br /&gt;
    /**&lt;br /&gt;
     * From a byte[] returns a base 64 representation&lt;br /&gt;
     * @param data byte[]&lt;br /&gt;
     * @return String&lt;br /&gt;
     * @throws IOException&lt;br /&gt;
     */&lt;br /&gt;
    public static String byteToBase64(byte[] data){&lt;br /&gt;
        BASE64Encoder endecoder = new BASE64Encoder();&lt;br /&gt;
        return endecoder.encode(data);&lt;br /&gt;
    }&lt;br /&gt;
  &lt;br /&gt;
  &lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:OWASP Java Project]]&lt;/div&gt;</summary>
		<author><name>Stephendv</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Talk:Hashing_Java&amp;diff=24413</id>
		<title>Talk:Hashing Java</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Talk:Hashing_Java&amp;diff=24413"/>
				<updated>2008-01-14T13:10:00Z</updated>
		
		<summary type="html">&lt;p&gt;Stephendv: /* Reviewers */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Status==&lt;br /&gt;
Needs review&lt;br /&gt;
&lt;br /&gt;
==Reviewers==&lt;br /&gt;
* Neil Smithline&lt;br /&gt;
&lt;br /&gt;
==General Discussion==&lt;br /&gt;
I use a very similar scheme in my applications, but 2 points that came to mind whilst reading.&lt;br /&gt;
#Iterations of at least 1000 times seemed a bit excessive, but it is in the standard and I'm in no way qualified to critise.&lt;br /&gt;
#Instead of storing salt in it's own field I usually include it amongst the password (i.e characters 2, 4, 7, 13, 17, 19) to make it that bit harder to even find the salt value.  I generally hex encode the hashes as well to make them a bit easier to work with.  Assuming decompiled code is available (as an attacker has gained access to the password hashes) this extra salt hiding may not serve any useless purpose.&lt;br /&gt;
:--------------&lt;br /&gt;
:I think that the above comment about hiding the bits in the password should just tossed. First, it is basically arguing security by obscurity - never a good practice. Second, it states that the bit hiding isn't helpful when the source code is available. Being that this article is discussing hashing in &amp;quot;Java&amp;quot; specifically and Java decompilation is a well-known and freely available technology, it seems that there is no need to mention hiding of the salt unless it is in reference to other languages. Eg: &amp;quot;In languages other than Java, where obtaining the source code can be difficult and reading the machine code is awkward, hiding the bits of the salt within the hashed password might provide some extra security.(And comments probably should be signed. Four tilde's &amp;quot;~ ~ ~ ~&amp;quot;, without the intervening spaces, adds your username and timestamps the comment.)&lt;br /&gt;
:[[User:Neil Smithline|Neil Smithline]] 16:46, 13 April 2007 (EDT)&lt;br /&gt;
::I'm advocating information hiding, not security by obscurity, albeit a fine line.  The case where source is available makes it a pointless exercise from a security perspective, but imagine a badly written webapp provides access to the database.  Showing the use of different salts and then making the salt value obvious allows an attacker to perform dictionary attacks.  Hiding the salt within the encrypted password makes this almost impossible. [[User:Dledmonds|Darren]] 12:34, 17 April 2007 (EDT)&lt;br /&gt;
&lt;br /&gt;
== Huh? Repetitive hashing only affects the attacker?  ==&lt;br /&gt;
&lt;br /&gt;
The article states ([[Hashing_Java#Hardening against the attacker's attack]]):&lt;br /&gt;
:To slow down the computation it is recommended to iterate the hash operation n times. Because hashing is a fast operation, it slows down by a n factor an attacker but not a legitimate user. &lt;br /&gt;
I find the second sentence so awkward to parse that I'm not sure if it is incorrect, I'm mis-parsing it, or I'm not understanding what it is saying. My understanding is that doing the hash ''n'' times slows down both the attacker, the user, and anyone else who wants to hash, by a factor of ''n'' every time they hash. The key here is that most of what a typical user does is not authentication, and most of authentication is not password validation. Other tasks such as database lookups, permission gathering, and session initialization tend to be much slower than password validation (which likely happens entirely in memory in a tight loop and thereby flies by comparison to the DB-based operations). So, while hashing the password ''n'' times does slow down '''hashing''' for both attackers '''and''' typical users, typical users don't really notice it being that hashing is such a small percentage of their total time interacting with the system. On the other hand, an attacker trying to crack passwords spends nearly 100% of their time hashing so hashing ''n'' times '''gives the appearance''' of slowing the attacker down by a factor of ''n'' while not noticeably affecting the typical user.&lt;br /&gt;
&lt;br /&gt;
If someone else takes a look at my comment and the article and agrees, then it should probably just be changed. I would have done this myself but I'm concerned (although not very concerned) that I might be misunderstanding the text.&lt;br /&gt;
&lt;br /&gt;
[[User:Neil Smithline|Neil Smithline]] 17:09, 13 April 2007 (EDT)&lt;br /&gt;
&lt;br /&gt;
Agree, have changed it - [[User:Stephendv|Stephendv]] 08:06, 14 January 2008 (EST)&lt;br /&gt;
&lt;br /&gt;
== Char to byte ==&lt;br /&gt;
&lt;br /&gt;
password.getBytes() should be password.getBytes(&amp;quot;UTF-8&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
Changed. [[User:Stephendv|Stephendv]] 08:09, 14 January 2008 (EST)&lt;/div&gt;</summary>
		<author><name>Stephendv</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Talk:Hashing_Java&amp;diff=24412</id>
		<title>Talk:Hashing Java</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Talk:Hashing_Java&amp;diff=24412"/>
				<updated>2008-01-14T13:09:31Z</updated>
		
		<summary type="html">&lt;p&gt;Stephendv: /* Char to byte */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Status==&lt;br /&gt;
Needs review&lt;br /&gt;
&lt;br /&gt;
==Reviewers==&lt;br /&gt;
* ?&lt;br /&gt;
&lt;br /&gt;
==General Discussion==&lt;br /&gt;
I use a very similar scheme in my applications, but 2 points that came to mind whilst reading.&lt;br /&gt;
#Iterations of at least 1000 times seemed a bit excessive, but it is in the standard and I'm in no way qualified to critise.&lt;br /&gt;
#Instead of storing salt in it's own field I usually include it amongst the password (i.e characters 2, 4, 7, 13, 17, 19) to make it that bit harder to even find the salt value.  I generally hex encode the hashes as well to make them a bit easier to work with.  Assuming decompiled code is available (as an attacker has gained access to the password hashes) this extra salt hiding may not serve any useless purpose.&lt;br /&gt;
:--------------&lt;br /&gt;
:I think that the above comment about hiding the bits in the password should just tossed. First, it is basically arguing security by obscurity - never a good practice. Second, it states that the bit hiding isn't helpful when the source code is available. Being that this article is discussing hashing in &amp;quot;Java&amp;quot; specifically and Java decompilation is a well-known and freely available technology, it seems that there is no need to mention hiding of the salt unless it is in reference to other languages. Eg: &amp;quot;In languages other than Java, where obtaining the source code can be difficult and reading the machine code is awkward, hiding the bits of the salt within the hashed password might provide some extra security.(And comments probably should be signed. Four tilde's &amp;quot;~ ~ ~ ~&amp;quot;, without the intervening spaces, adds your username and timestamps the comment.)&lt;br /&gt;
:[[User:Neil Smithline|Neil Smithline]] 16:46, 13 April 2007 (EDT)&lt;br /&gt;
::I'm advocating information hiding, not security by obscurity, albeit a fine line.  The case where source is available makes it a pointless exercise from a security perspective, but imagine a badly written webapp provides access to the database.  Showing the use of different salts and then making the salt value obvious allows an attacker to perform dictionary attacks.  Hiding the salt within the encrypted password makes this almost impossible. [[User:Dledmonds|Darren]] 12:34, 17 April 2007 (EDT)&lt;br /&gt;
&lt;br /&gt;
== Huh? Repetitive hashing only affects the attacker?  ==&lt;br /&gt;
&lt;br /&gt;
The article states ([[Hashing_Java#Hardening against the attacker's attack]]):&lt;br /&gt;
:To slow down the computation it is recommended to iterate the hash operation n times. Because hashing is a fast operation, it slows down by a n factor an attacker but not a legitimate user. &lt;br /&gt;
I find the second sentence so awkward to parse that I'm not sure if it is incorrect, I'm mis-parsing it, or I'm not understanding what it is saying. My understanding is that doing the hash ''n'' times slows down both the attacker, the user, and anyone else who wants to hash, by a factor of ''n'' every time they hash. The key here is that most of what a typical user does is not authentication, and most of authentication is not password validation. Other tasks such as database lookups, permission gathering, and session initialization tend to be much slower than password validation (which likely happens entirely in memory in a tight loop and thereby flies by comparison to the DB-based operations). So, while hashing the password ''n'' times does slow down '''hashing''' for both attackers '''and''' typical users, typical users don't really notice it being that hashing is such a small percentage of their total time interacting with the system. On the other hand, an attacker trying to crack passwords spends nearly 100% of their time hashing so hashing ''n'' times '''gives the appearance''' of slowing the attacker down by a factor of ''n'' while not noticeably affecting the typical user.&lt;br /&gt;
&lt;br /&gt;
If someone else takes a look at my comment and the article and agrees, then it should probably just be changed. I would have done this myself but I'm concerned (although not very concerned) that I might be misunderstanding the text.&lt;br /&gt;
&lt;br /&gt;
[[User:Neil Smithline|Neil Smithline]] 17:09, 13 April 2007 (EDT)&lt;br /&gt;
&lt;br /&gt;
Agree, have changed it - [[User:Stephendv|Stephendv]] 08:06, 14 January 2008 (EST)&lt;br /&gt;
&lt;br /&gt;
== Char to byte ==&lt;br /&gt;
&lt;br /&gt;
password.getBytes() should be password.getBytes(&amp;quot;UTF-8&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
Changed. [[User:Stephendv|Stephendv]] 08:09, 14 January 2008 (EST)&lt;/div&gt;</summary>
		<author><name>Stephendv</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Talk:Hashing_Java&amp;diff=24411</id>
		<title>Talk:Hashing Java</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Talk:Hashing_Java&amp;diff=24411"/>
				<updated>2008-01-14T13:06:05Z</updated>
		
		<summary type="html">&lt;p&gt;Stephendv: /* Huh? Repetitive hashing only affects the attacker? */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Status==&lt;br /&gt;
Needs review&lt;br /&gt;
&lt;br /&gt;
==Reviewers==&lt;br /&gt;
* ?&lt;br /&gt;
&lt;br /&gt;
==General Discussion==&lt;br /&gt;
I use a very similar scheme in my applications, but 2 points that came to mind whilst reading.&lt;br /&gt;
#Iterations of at least 1000 times seemed a bit excessive, but it is in the standard and I'm in no way qualified to critise.&lt;br /&gt;
#Instead of storing salt in it's own field I usually include it amongst the password (i.e characters 2, 4, 7, 13, 17, 19) to make it that bit harder to even find the salt value.  I generally hex encode the hashes as well to make them a bit easier to work with.  Assuming decompiled code is available (as an attacker has gained access to the password hashes) this extra salt hiding may not serve any useless purpose.&lt;br /&gt;
:--------------&lt;br /&gt;
:I think that the above comment about hiding the bits in the password should just tossed. First, it is basically arguing security by obscurity - never a good practice. Second, it states that the bit hiding isn't helpful when the source code is available. Being that this article is discussing hashing in &amp;quot;Java&amp;quot; specifically and Java decompilation is a well-known and freely available technology, it seems that there is no need to mention hiding of the salt unless it is in reference to other languages. Eg: &amp;quot;In languages other than Java, where obtaining the source code can be difficult and reading the machine code is awkward, hiding the bits of the salt within the hashed password might provide some extra security.(And comments probably should be signed. Four tilde's &amp;quot;~ ~ ~ ~&amp;quot;, without the intervening spaces, adds your username and timestamps the comment.)&lt;br /&gt;
:[[User:Neil Smithline|Neil Smithline]] 16:46, 13 April 2007 (EDT)&lt;br /&gt;
::I'm advocating information hiding, not security by obscurity, albeit a fine line.  The case where source is available makes it a pointless exercise from a security perspective, but imagine a badly written webapp provides access to the database.  Showing the use of different salts and then making the salt value obvious allows an attacker to perform dictionary attacks.  Hiding the salt within the encrypted password makes this almost impossible. [[User:Dledmonds|Darren]] 12:34, 17 April 2007 (EDT)&lt;br /&gt;
&lt;br /&gt;
== Huh? Repetitive hashing only affects the attacker?  ==&lt;br /&gt;
&lt;br /&gt;
The article states ([[Hashing_Java#Hardening against the attacker's attack]]):&lt;br /&gt;
:To slow down the computation it is recommended to iterate the hash operation n times. Because hashing is a fast operation, it slows down by a n factor an attacker but not a legitimate user. &lt;br /&gt;
I find the second sentence so awkward to parse that I'm not sure if it is incorrect, I'm mis-parsing it, or I'm not understanding what it is saying. My understanding is that doing the hash ''n'' times slows down both the attacker, the user, and anyone else who wants to hash, by a factor of ''n'' every time they hash. The key here is that most of what a typical user does is not authentication, and most of authentication is not password validation. Other tasks such as database lookups, permission gathering, and session initialization tend to be much slower than password validation (which likely happens entirely in memory in a tight loop and thereby flies by comparison to the DB-based operations). So, while hashing the password ''n'' times does slow down '''hashing''' for both attackers '''and''' typical users, typical users don't really notice it being that hashing is such a small percentage of their total time interacting with the system. On the other hand, an attacker trying to crack passwords spends nearly 100% of their time hashing so hashing ''n'' times '''gives the appearance''' of slowing the attacker down by a factor of ''n'' while not noticeably affecting the typical user.&lt;br /&gt;
&lt;br /&gt;
If someone else takes a look at my comment and the article and agrees, then it should probably just be changed. I would have done this myself but I'm concerned (although not very concerned) that I might be misunderstanding the text.&lt;br /&gt;
&lt;br /&gt;
[[User:Neil Smithline|Neil Smithline]] 17:09, 13 April 2007 (EDT)&lt;br /&gt;
&lt;br /&gt;
Agree, have changed it - [[User:Stephendv|Stephendv]] 08:06, 14 January 2008 (EST)&lt;br /&gt;
&lt;br /&gt;
== Char to byte ==&lt;br /&gt;
&lt;br /&gt;
password.getBytes() should be password.getBytes(&amp;quot;UTF-8&amp;quot;)&lt;/div&gt;</summary>
		<author><name>Stephendv</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Hashing_Java&amp;diff=24410</id>
		<title>Hashing Java</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Hashing_Java&amp;diff=24410"/>
				<updated>2008-01-14T13:05:25Z</updated>
		
		<summary type="html">&lt;p&gt;Stephendv: /* Hardening against the attacker's attack */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction :==&lt;br /&gt;
&lt;br /&gt;
Most of today’s applications use login/password in order to authenticate. Users often use the same login/password for different kinds of applications. If the couple is stolen, everybody can access all the applications the user has access to. &lt;br /&gt;
&lt;br /&gt;
Too often passwords are stored as clear text. Thus the password can be read directly by the database’s administrator, super users or SQL Injection attack etc. The backup media is also vulnerable. &lt;br /&gt;
In order to solve this problem, passwords must be stored encrypted. Two kinds of encryption are available:&lt;br /&gt;
* One way functions (SHA-256 SHA-1 MD5, ..;) also known as Hashing functions&lt;br /&gt;
* Reversible encryption functions (DES, AES, …). &lt;br /&gt;
However, the reversible property of encryption function is useless for credentials storing (cf. OWASP Guide v2.0.1) :&lt;br /&gt;
&lt;br /&gt;
''Passwords are secrets. There is no reason to decrypt them under any circumstances. Helpdesk staff should be able to set new passwords (with an audit trail, obviously), not read back old passwords. Therefore, there is no reason to store passwords in a reversible form.''&lt;br /&gt;
&lt;br /&gt;
==Definition of  cryptographic Hashing function:==&lt;br /&gt;
A Hash function creates a fixed length small fingerprint (or message digest) from an unlimited input string.&lt;br /&gt;
&lt;br /&gt;
hash(X) -&amp;gt;Y          X is a infinite set and Y is a finite set.&lt;br /&gt;
&lt;br /&gt;
A good cryptographic Hash function must have these properties: &lt;br /&gt;
* Preimage  resistant : From the function output y it must impossible to compute the input x such that hash(x)=y. &lt;br /&gt;
* Second preimage  resistant : from an input x1 it must impossible to compute another input x2 (different of x1) such that hash(x1)=hash(x2).&lt;br /&gt;
* Collision resistant : It must be difficult to find two inputs x1 and x2 (x1&amp;lt;&amp;gt;x2) such that hash(x1)=hash(x2).&lt;br /&gt;
&lt;br /&gt;
'''Sample java code :''' &lt;br /&gt;
  import java.security.MessageDigest;&lt;br /&gt;
  &lt;br /&gt;
  public byte[] getHash(String password) throws NoSuchAlgorithmException {&lt;br /&gt;
        MessageDigest digest = MessageDigest.getInstance(&amp;quot;SHA-1&amp;quot;);&lt;br /&gt;
        digest.reset();&lt;br /&gt;
        byte[] input = digest.digest(password.getBytes());&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
==Credential storage.==&lt;br /&gt;
&lt;br /&gt;
If the password’s digest is stored in a database, an attacker should be unable to recover the password thanks to the preimage resistance. The only way to go past this would be a [[Brute force attack|brute force attack]], i.e. computing the hash of all possible passwords or a dictionary attack, i.e. computing all the often used password.&lt;br /&gt;
&lt;br /&gt;
==Why add salt ? ==&lt;br /&gt;
&lt;br /&gt;
There are two drawbacks to choosing to only store the password’s hash: &lt;br /&gt;
*	It is possible to identify two identical passwords.&lt;br /&gt;
*	Due to the birthday paradox (http://en.wikipedia.org/wiki/Birthday_paradox), the attacker can find a password very quickly especially if the number of password is important in the database.&lt;br /&gt;
&lt;br /&gt;
In order to solve these problems, a salt can be concatenated to the password before the digest operation. &lt;br /&gt;
&lt;br /&gt;
A salt is a random number of a fixed length. This salt must be different for each stored entry. It must be stored as clear text next to the hashed password.&lt;br /&gt;
&lt;br /&gt;
In this configuration, an attacker must handle a brute force attack on each individual password. The database is now birthday attack resistant.&lt;br /&gt;
&lt;br /&gt;
A 64 bits salt is recommended in RSA PKCS5 standard.&lt;br /&gt;
&lt;br /&gt;
'''Sample java code :''' &lt;br /&gt;
  import java.security.MessageDigest;&lt;br /&gt;
  &lt;br /&gt;
  &lt;br /&gt;
  public byte[] getHash(String password, byte[] salt) throws NoSuchAlgorithmException {&lt;br /&gt;
        MessageDigest digest = MessageDigest.getInstance(&amp;quot;SHA-256&amp;quot;);&lt;br /&gt;
        digest.reset();&lt;br /&gt;
        digest.update(salt);&lt;br /&gt;
        return digest.digest(password.getBytes());&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
==Hardening against the attacker's attack==&lt;br /&gt;
&lt;br /&gt;
To slow down the computation it is recommended to iterate the hash operation n times. While hashing the password n times does slow down hashing for both attackers and typical users, typical users don't really notice it being that hashing is such a small percentage of their total time interacting with the system. On the other hand, an attacker trying to crack passwords spends nearly 100% of their time hashing so hashing n times gives the appearance of slowing the attacker down by a factor of n while not noticeably affecting the typical user. &lt;br /&gt;
A minimum of 1000 operations is recommended in RSA PKCS5 standard.&lt;br /&gt;
&lt;br /&gt;
The stored password looks like this :&lt;br /&gt;
		Hash(hash(hash(hash(……….hash(password||salt)))))))))))))))&lt;br /&gt;
&lt;br /&gt;
To authenticate a user, the operation same as above must be performed, followed by a comparison of the two hashes.&lt;br /&gt;
&lt;br /&gt;
The hash function you need to use depends of your security policy. SHA-256 or SHA-512 is recommended for long term storage.&lt;br /&gt;
&lt;br /&gt;
'''Sample java code :''' &lt;br /&gt;
  import java.security.*;&lt;br /&gt;
  &lt;br /&gt;
  &lt;br /&gt;
   public byte[] getHash(int iterationNb, String password, byte[] salt) throws NoSuchAlgorithmException {&lt;br /&gt;
        MessageDigest digest = MessageDigest.getInstance(&amp;quot;SHA-1&amp;quot;);&lt;br /&gt;
        digest.reset();&lt;br /&gt;
        digest.update(salt);&lt;br /&gt;
        byte[] input = digest.digest(password.getBytes());&lt;br /&gt;
        for (int i = 0; i &amp;lt; iterationNb; i++) {&lt;br /&gt;
            digest.reset();&lt;br /&gt;
            input = digest.digest(input);&lt;br /&gt;
        }&lt;br /&gt;
        return input;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
==Complete Java Sample==&lt;br /&gt;
In order to create the table needed by this application, call the method creerTable().&lt;br /&gt;
It creates a TABLE called CREDENTIAL, with these fields : &lt;br /&gt;
* LOGIN VARCHAR (100)  PRIMARY KEY&lt;br /&gt;
* PASSWORD VARCHAR (32)&lt;br /&gt;
* SALT VARCHAR (32)&lt;br /&gt;
&lt;br /&gt;
In this database, the password and the salt are stored in Base64 representation.&lt;br /&gt;
&lt;br /&gt;
The method ''authenticate'' is used in order to authenticate a user, the method ''createUser'' is used to create a new user.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  package org.psafix.memopwd;&lt;br /&gt;
  &lt;br /&gt;
  import java.security.MessageDigest;&lt;br /&gt;
  import java.security.NoSuchAlgorithmException;&lt;br /&gt;
  import java.io.IOException;&lt;br /&gt;
  import sun.misc.BASE64Decoder;&lt;br /&gt;
  import sun.misc.BASE64Encoder;&lt;br /&gt;
  import java.sql.*;&lt;br /&gt;
  import java.util.Arrays;&lt;br /&gt;
  import java.security.SecureRandom;&lt;br /&gt;
  &lt;br /&gt;
  public class Owasp {&lt;br /&gt;
    private final static int ITERATION_NUMBER = 1000;&lt;br /&gt;
  &lt;br /&gt;
    public Owasp() {&lt;br /&gt;
    }&lt;br /&gt;
  &lt;br /&gt;
    /**&lt;br /&gt;
     * Authenticates the user with a given login and password&lt;br /&gt;
     * If password and/or login is null then always returns false.&lt;br /&gt;
     * If the user does not exist in the database returns false.&lt;br /&gt;
     * @param con Connection An open connection to a databse&lt;br /&gt;
     * @param login String The login of the user&lt;br /&gt;
     * @param password String The password of the user&lt;br /&gt;
     * @return boolean Returns true if the user is authenticated, false otherwise&lt;br /&gt;
     * @throws SQLException If the database is inconsistent or unavailable (&lt;br /&gt;
     *           (Two users with the same login, salt or digested password altered etc.)&lt;br /&gt;
     * @throws NoSuchAlgorithmException If the algorithm SHA-1 is not supported by the JVM&lt;br /&gt;
     */&lt;br /&gt;
    public boolean authenticate(Connection con, String login, String password)&lt;br /&gt;
            throws SQLException, NoSuchAlgorithmException{&lt;br /&gt;
        boolean authenticated=false;&lt;br /&gt;
        PreparedStatement ps = null;&lt;br /&gt;
        ResultSet rs = null;&lt;br /&gt;
        try {&lt;br /&gt;
            boolean userExist = true;&lt;br /&gt;
            // INPUT VALIDATION&lt;br /&gt;
            if (login==null||password==null){&lt;br /&gt;
                // TIME RESISTANT ATTACK&lt;br /&gt;
                // Computation time is equal to the time needed by a legitimate user&lt;br /&gt;
                userExist = false;&lt;br /&gt;
                login=&amp;quot;&amp;quot;;&lt;br /&gt;
                password=&amp;quot;&amp;quot;;&lt;br /&gt;
            }&lt;br /&gt;
  &lt;br /&gt;
            ps = con.prepareStatement(&amp;quot;SELECT PASSWORD, SALT FROM CREDENTIAL WHERE LOGIN = ?&amp;quot;);&lt;br /&gt;
            ps.setString(1, login);&lt;br /&gt;
            rs = ps.executeQuery();&lt;br /&gt;
            String digest, salt;&lt;br /&gt;
            if (rs.next()) {&lt;br /&gt;
                digest = rs.getString(&amp;quot;PASSWORD&amp;quot;);&lt;br /&gt;
                salt = rs.getString(&amp;quot;SALT&amp;quot;);&lt;br /&gt;
                // DATABASE VALIDATION&lt;br /&gt;
                if (digest == null || salt == null) {&lt;br /&gt;
                    throw new SQLException(&amp;quot;Database inconsistant Salt or Digested Password altered&amp;quot;);&lt;br /&gt;
                }&lt;br /&gt;
                if (rs.next()) { // Should not append, because login is the primary key&lt;br /&gt;
                    throw new SQLException(&amp;quot;Database inconsistent two CREDENTIALS with the same LOGIN&amp;quot;);&lt;br /&gt;
                }&lt;br /&gt;
            } else { // TIME RESISTANT ATTACK (Even if the user does not exist the&lt;br /&gt;
                // Computation time is equal to the time needed for a legitimate user&lt;br /&gt;
                digest = &amp;quot;000000000000000000000000000=&amp;quot;;&lt;br /&gt;
                salt = &amp;quot;00000000000=&amp;quot;;&lt;br /&gt;
                userExist = false;&lt;br /&gt;
            }&lt;br /&gt;
  &lt;br /&gt;
            byte[] bDigest = base64ToByte(digest);&lt;br /&gt;
            byte[] bSalt = base64ToByte(salt);&lt;br /&gt;
  &lt;br /&gt;
            // Compute the new DIGEST&lt;br /&gt;
            byte[] proposedDigest = getHash(ITERATION_NUMBER, password, bSalt);&lt;br /&gt;
  &lt;br /&gt;
            return Arrays.equals(proposedDigest, bDigest) &amp;amp;&amp;amp; userExist;&lt;br /&gt;
        } catch (IOException ex){&lt;br /&gt;
            throw new SQLException(&amp;quot;Database inconsistant Salt or Digested Password altered&amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
        finally{&lt;br /&gt;
            close(rs);&lt;br /&gt;
            close(ps);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
  &lt;br /&gt;
  &lt;br /&gt;
  &lt;br /&gt;
    /**&lt;br /&gt;
     * Inserts a new user in the database&lt;br /&gt;
     * @param con Connection An open connection to a databse&lt;br /&gt;
     * @param login String The login of the user&lt;br /&gt;
     * @param password String The password of the user&lt;br /&gt;
     * @return boolean Returns true if the login and password are ok (not null and length(login)&amp;lt;=100&lt;br /&gt;
     * @throws SQLException If the database is unavailable&lt;br /&gt;
     * @throws NoSuchAlgorithmException If the algorithm SHA-1 or the SecureRandom is not supported by the JVM&lt;br /&gt;
     */&lt;br /&gt;
    public boolean createUser(Connection con, String login, String password)&lt;br /&gt;
            throws SQLException, NoSuchAlgorithmException&lt;br /&gt;
    {&lt;br /&gt;
        PreparedStatement ps = null;&lt;br /&gt;
        try {&lt;br /&gt;
            if (login!=null&amp;amp;&amp;amp;password!=null&amp;amp;&amp;amp;login.length()&amp;lt;=100){&lt;br /&gt;
                // Uses a secure Random not a simple Random&lt;br /&gt;
                SecureRandom random = SecureRandom.getInstance(&amp;quot;SHA1PRNG&amp;quot;);&lt;br /&gt;
                // Salt generation 64 bits long&lt;br /&gt;
                byte[] bSalt = new byte[8];&lt;br /&gt;
                random.nextBytes(bSalt);&lt;br /&gt;
                // Digest computation&lt;br /&gt;
                byte[] bDigest = getHash(ITERATION_NUMBER,password,bSalt);&lt;br /&gt;
                String sDigest = byteToBase64(bDigest);&lt;br /&gt;
                String sSalt = byteToBase64(bSalt);&lt;br /&gt;
  &lt;br /&gt;
                ps = con.prepareStatement(&amp;quot;INSERT INTO CREDENTIAL (LOGIN, PASSWORD, SALT) VALUES (?,?,?)&amp;quot;);&lt;br /&gt;
                ps.setString(1,login);&lt;br /&gt;
                ps.setString(2,sDigest);&lt;br /&gt;
                ps.setString(3,sSalt);&lt;br /&gt;
                ps.executeUpdate();&lt;br /&gt;
                return true;&lt;br /&gt;
            } else {&lt;br /&gt;
                return false;&lt;br /&gt;
            }&lt;br /&gt;
        } finally {&lt;br /&gt;
            close(ps);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
  &lt;br /&gt;
  &lt;br /&gt;
    /**&lt;br /&gt;
     * From a password, a number of iterations and a salt,&lt;br /&gt;
     * returns the corresponding digest&lt;br /&gt;
     * @param iterationNb int The number of iterations of the algorithm&lt;br /&gt;
     * @param password String The password to encrypt&lt;br /&gt;
     * @param salt byte[] The salt&lt;br /&gt;
     * @return byte[] The digested password&lt;br /&gt;
     * @throws NoSuchAlgorithmException If the algorithm doesn't exist&lt;br /&gt;
     */&lt;br /&gt;
    public byte[] getHash(int iterationNb, String password, byte[] salt) throws NoSuchAlgorithmException {&lt;br /&gt;
        MessageDigest digest = MessageDigest.getInstance(&amp;quot;SHA-1&amp;quot;);&lt;br /&gt;
        digest.reset();&lt;br /&gt;
        digest.update(salt);&lt;br /&gt;
        byte[] input = digest.digest(password.getBytes());&lt;br /&gt;
        for (int i = 0; i &amp;lt; iterationNb; i++) {&lt;br /&gt;
            digest.reset();&lt;br /&gt;
            input = digest.digest(input);&lt;br /&gt;
        }&lt;br /&gt;
        return input;&lt;br /&gt;
    }&lt;br /&gt;
  &lt;br /&gt;
  &lt;br /&gt;
    public void creerTable(Connection con) throws SQLException{&lt;br /&gt;
        Statement st = null;&lt;br /&gt;
        try {&lt;br /&gt;
            st = con.createStatement();&lt;br /&gt;
            st.execute(&amp;quot;CREATE TABLE CREDENTIAL (LOGIN VARCHAR(100) PRIMARY KEY, PASSWORD VARCHAR(32) NOT NULL, SALT VARCHAR(32) NOT NULL)&amp;quot;);&lt;br /&gt;
        } finally {&lt;br /&gt;
            close(st);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
  &lt;br /&gt;
  &lt;br /&gt;
  &lt;br /&gt;
    /**&lt;br /&gt;
     * Closes the current statement&lt;br /&gt;
     * @param ps Statement&lt;br /&gt;
     */&lt;br /&gt;
    public void close(Statement ps) {&lt;br /&gt;
        if (ps!=null){&lt;br /&gt;
            try {&lt;br /&gt;
                ps.close();&lt;br /&gt;
            } catch (SQLException ignore) {&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
  &lt;br /&gt;
    /**&lt;br /&gt;
     * Closes the current resultset&lt;br /&gt;
     * @param ps Statement&lt;br /&gt;
     */&lt;br /&gt;
    public void close(ResultSet rs) {&lt;br /&gt;
        if (rs!=null){&lt;br /&gt;
            try {&lt;br /&gt;
                rs.close();&lt;br /&gt;
            } catch (SQLException ignore) {&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
  &lt;br /&gt;
  &lt;br /&gt;
    /**&lt;br /&gt;
     * From a base 64 representation, returns the corresponding byte[] &lt;br /&gt;
     * @param data String The base64 representation&lt;br /&gt;
     * @return byte[]&lt;br /&gt;
     * @throws IOException&lt;br /&gt;
     */&lt;br /&gt;
    public static byte[] base64ToByte(String data) throws IOException {&lt;br /&gt;
        BASE64Decoder decoder = new BASE64Decoder();&lt;br /&gt;
        return decoder.decodeBuffer(data);&lt;br /&gt;
    }&lt;br /&gt;
  &lt;br /&gt;
    /**&lt;br /&gt;
     * From a byte[] returns a base 64 representation&lt;br /&gt;
     * @param data byte[]&lt;br /&gt;
     * @return String&lt;br /&gt;
     * @throws IOException&lt;br /&gt;
     */&lt;br /&gt;
    public static String byteToBase64(byte[] data){&lt;br /&gt;
        BASE64Encoder endecoder = new BASE64Encoder();&lt;br /&gt;
        return endecoder.encode(data);&lt;br /&gt;
    }&lt;br /&gt;
  &lt;br /&gt;
  &lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:OWASP Java Project]]&lt;/div&gt;</summary>
		<author><name>Stephendv</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Hacking_Java_Clients&amp;diff=24409</id>
		<title>Hacking Java Clients</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Hacking_Java_Clients&amp;diff=24409"/>
				<updated>2008-01-14T12:56:56Z</updated>
		
		<summary type="html">&lt;p&gt;Stephendv: /* Hacking Java Clients */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Status ==&lt;br /&gt;
Released 14/1/2008&lt;br /&gt;
&lt;br /&gt;
== Hacking Java Clients ==&lt;br /&gt;
When performing a security assessment of client-server Java applications, it is sometimes necessary to modify the client component in order to properly understand and assess the security mechanisms in place.  Typical examples are systems that employ a communication channel that can't be intercepted with tools such as the personal proxies (WebScarab, Paros, etc.).  A convenient means of accessing the internals of a Java program is to have an interactive scripting environment (BeanShell, Jython, JRuby, Groovy, etc.) that exposes the internal objects and allows you to perform arbitrary operations on these objects.  The following [http://research.corsaire.com/whitepapers/060816-assessing-java-clients-with-the-beanshell.pdf white paper] outlines this technique.  &lt;br /&gt;
&lt;br /&gt;
There are a number of techniques that can be used to insert such an interpreter, these include:&lt;br /&gt;
# Recompile the source code and include the interpreter into the app. (Of course, you'll need access to the source and a build environment)&lt;br /&gt;
# Insert the interpreter using inheritance (as described in the white-paper mentioned above).&lt;br /&gt;
# Insert the interpreter by directly manipulating the byte-code&lt;br /&gt;
# Use [http://www.adaptj.com/root/main/stacktrace this tool]&lt;br /&gt;
# Use [http://www.fasterj.com/articles/hotpatch1.shtml a new feature implemented by Java 6]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:OWASP Java Project]]&lt;/div&gt;</summary>
		<author><name>Stephendv</name></author>	</entry>

	</feed>