Youth culture killed my dog http://www.papermountain.org/blog/index.cgi Constantly one step behind the next big thing en-us Common Web Security Anti-Patterns http://www.papermountain.org/blog/index.cgi/Tech/Programming/CommonWebSecurityAntiPatterns.html <p>The following is from a handout I used for a presentation to a group of Java programmers. In retrospect I don't think I like the <a href="http://c2.com/cgi/wiki?AntiPattern">anti-pattern</a> format, but hopefully you will find it helpful in spite of that.</p> <b>Name</b>: Trusting form data<br/> <b>Problem</b>: Preserving state across a series of web pages and form submissions.<br/> <b>Supposed Solution</b>: Store information in hidden form fields.<br/> <b>Exploit</b>: The values of the hidden fields can be easily changed by an attacker to subvert the application. The application will then use the altered data in calculations that should only performed with trusted data.<br/> <b>Example</b>: The data stored in the hidden field is the price of an item in an ecommerce system. A criminal organization exploits this to purchase a large number of expensive items at a 100% "discount".<br/> <b>Alternative Solutions</b>: <ul> <li>Only accept data from forms when it doesn't matter if it is tampered with. For example instead of storing the price in an ecommerce system, only store the product id then look up the price using the product id as a key.</li> <li>Use a framework such as <a href="http://lakeshore.sourceforge.net">Lakeshore</a> that abstracts away the problem of managing state across pages.</li> <li>In cases where sensitive data must stored on the client side (e.g. a price quote) the sensitive data must be cryptographically signed. A signature can be generated by concatenating the sensitive data with a secret and calculating a one way hash. This signature is then always passed with the sensitive data allowing any tampering to be detected.</li> </ul> <b>Name</b>: SQL Injection<br/> <b>Problem</b>: User supplied data must be used in queries against a database.<br/> <b>Supposed Solution</b>: Just substitute the user input into an SQL template and execute it.<br/> <b>Exploit</b>: An attacker can carefully craft the supplied data to execute arbitrary SQL. The details vary by database vendor, but for Oracle the key concept is starting the SQL to be inserted with a single quote.<br/> <b>Example</b>: An ecommerce system allows the catalog of products to be to searched based on a user supplied string by simply inserting the user supplied string into a query. The attacker enters the following as a search criteria: <code>x' UNION SELECT table_name FROM user_tables WHERE 'x'='x</code>. This will allow the attacker to obtain the name of the table that credit card information is stored in then use the same technique to retrieve all of the credit card numbers stored in the system.<br/> <b>Alternative Solutions</b>: <ul> <li>Don't execute SQL using raw JDBC calls. Use a library such as <a href="http://sqlprocessor.sourceforge.net">SQLProcessor</a> that always uses prepared statements. This is sufficient for applications that use Oracle databases, but may not be for other databases.</li> <li>Escape single quotes in user input before using it in an SQL statement.</li> </ul> <b>Further reading</b>: <a href="http://www.securityfocus.com/infocus/1644">http://www.securityfocus.com/infocus/1644</a><br/> <br/> <b>Name</b>: Cross Site Scripting (xss)<br/> <b>Problem</b>: User supplied data is displayed to other users<br/> <b>Exploit</b>: An attacker can carefully craft the data so that it does a wide variety of malicious things when another user views the data.<br/> <b>Example</b>: An ecommerce system displays the names and addresses of problem orders on a screen accessible by an administrative user. The attacker enters javascript for his address that will steal the viewing user's JSESSIONID cookie and post it to a logging URL controlled by the attacker. When the administrator views the attacker's order his JSESSIONID is stolen and the attacker can then impersonate the administrator.<br/> <b>Alternative Solutions</b>: <ul> <li>Filter out dangerous characters from user supplied input before storing it.</li> <li>Encode all user supplied input before displaying it to other users</li> </ul> <b>Further reading<b>: <ul> <li><a href="http://www.cgisecurity.com/articles/xss-faq.shtml">http://www.cgisecurity.com/articles/xss-faq.shtml</a></li> <li><a href="http://www.dwheeler.com/secure-programs/Secure-Programs-HOWTO/cross-site-malicious-content.html">http://www.dwheeler.com/secure-programs/Secure-Programs-HOWTO/cross-site-malicious-content.html</a></li> </ul> Nice quote http://www.papermountain.org/blog/index.cgi/Tech/Programming/NiceQuote.rdoc <pre> Methodologies do not succeed because they are aligned with some platonic Right Way to build software. Methodologies succeed because people make them succeed. </pre> <a href="http://www.testing.com/cgi-bin/blog/2004/07/24#methodology-and-ontology">www.testing.com/cgi-bin/blog/2004/07/24#methodology-and-ontology</a> Seaside gets DHTML http://www.papermountain.org/blog/index.cgi/Tech/Programming/SeasideDHTML.rdoc I knew that things like autocomplete on text fields were possible, but I thought they would be clunky in practice. Even after seeing gmail in action I still didn&#8217;t get it. Well, I get it now. Try typing some things in the &quot;Live Search&quot; box on the right side of this <a href="http://www.creatimation.net/journal/live-request">page</a>. <p> And now it comes to Seaside: </p> <pre> What this means, effectively, is that invoking this handler makes a request in the background, which the webserver can respond to by returning a new version of any part of the current page that it likes. That part of the page gets swapped out seamlessly for the new version. The thing I like about this is that it gives all the power to the server side: only after having processed the request does the decision have to be made about what parts of the page are affected and need to be redrawn, and those parts can be sent back to the client. </pre> <p> <a href="http://www.cincomsmalltalk.com/userblogs/avi/blogView?showComments=true&entry=3268075684">www.cincomsmalltalk.com/userblogs/avi/blogView?showComments=true&entry=3268075684</a> </p> <p> So now I would like to get this going in <a href="http://borges.rubyforge.org/">Borges</a>. If I don&#8217;t have something posted by Monday, call me out on it. </p> Reflections on reflection - Henk Barendregt http://www.papermountain.org/blog/index.cgi/Tech/Programming/Reflections.rdoc <a href="http://lambda-the-ultimate.org/node/view/91">lambda-the-ultimate.org/node/view/91</a>