How does Content Security Policy (CSP) work?

The Content-Security-Policy meta-tag allows you to reduce the risk of XSS attacks by allowing you to define where resources can be loaded from, preventing browsers from loading data from any other locations. This makes it harder for an attacker to inject malicious code into your site. I banged my head against a brick wall trying … Read more

SPA best practices for authentication and session management

This question has been addressed, in a slightly different form, at length, here: RESTful Authentication But this addresses it from the server-side. Let’s look at this from the client-side. Before we do that, though, there’s an important prelude: Javascript Crypto is Hopeless Matasano’s article on this is famous, but the lessons contained therein are pretty … Read more

PreparedStatement IN clause alternatives?

An analysis of the various options available, and the pros and cons of each is available in Jeanne Boyarsky’s Batching Select Statements in JDBC entry on JavaRanch Journal. The suggested options are: Prepare SELECT my_column FROM my_table WHERE search_column = ?, execute it for each value and UNION the results client-side. Requires only one prepared … Read more

Why am I suddenly getting a “Blocked loading mixed active content” issue in Firefox?

I found this blog post which cleared up a few things. To quote the most relevant bit: Mixed Active Content is now blocked by default in Firefox 23! What is Mixed Content? When a user visits a page served over HTTP, their connection is open for eavesdropping and man-in-the-middle (MITM) attacks. When a user visits … Read more

Why would one omit the close tag?

Sending headers earlier than the normal course may have far reaching consequences. Below are just a few of them that happened to come to my mind at the moment: While current PHP releases may have output buffering on, the actual production servers you will be deploying your code on are far more important than any … Read more

Worst security hole you’ve seen? [closed]

From early days of online stores: Getting a 90% discount by entering .1 in the quantity field of the shopping cart. The software properly calculated the total cost as .1 * cost, and the human packing the order simply glossed over the odd “.” in front of the quantity to pack 🙂

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)