We’re planning to build a web application that needs to be highly secure because a lot of money and reputation is at risk. Therefore I’m looking for tools and technologies that help in that endeavor. The tools and technologies should help prevent things like SQL injection, cross-site scripting vulnerabilities, remote code execution etc.
Our team has a solid knowledge about such vulnerabilities. But every developer makes mistakes, and a simple mistake shouldn’t lead to a security vulnerability. They should be prevented or detected by web application framework, application server, programming language, security library, code analyzer etc.
A simple example: If you insert data into HTML, it needs to be escaped so it’s properly displayed and not misused for injecting scripts. Some web application frameworks put this burden on the developers. If they forget the escaping in one place, they’ve got a security problem. A good tool wouldn’t just do the escaping automatically, it would even prevent the developers from doing it forcefully.
I’m not looking for recommendations regarding the firewall (we have a good one), hardening the operating system (that’s part of the plan), use of encrypted communication (it will be the only option) and secure authentication (a hardware token will be used). Rather, the recommendations should center around the application server and the web application software to be built.
We also fully understand that writing secure software is more than just technology: It involves knowledgable people, management attention, time and money and software quality processes. So far, this is not the problem and not the focus of this question.
I should mention that we have a certain bias towards Java and .NET.
So what tools and technologies or combinations thereof can you recommend us?
Background
The vulnerabilities you mentioned all stem from a confusion of data with control (or code, if you’d prefer). They arise in practice because many programming languages and APIs aren’t equipped to encode the semantics of domain-specific languages like SQL, HTML, and the system shell. For example, nearly all XSS vulnerabilities occur because a programmer prints out an un-sanitized string and the programming language or API doesn’t have enough information to detect that the string was user-submitted and should have had its control characters escaped. Fortunately, there are language extensions and APIs that do separate data from control and can eliminate nearly all of these attacks.
SQL Injections
Cross-site Scripting (XSS)
Many of the techniques for preventing XSS attacks are similar in spirit to defenses against SQL injections. Only this time, the target is the web browser instead of the database. Either way, we don’t want data to be mistakenly interpreted as control.
Remote Code Execution
I don’t have much to say on this topic, but try to minimize
system()-like calls as much as possible. If you have to make calls to other binaries, apply good security practices such as using a whitelist where possible and using well-vetted sanitization functions where appropriate. Some APIs, like Python’s Popen, do a nice job of ensuring that arguments aren’t treated as shell control characters. Finally, with Java and C#, buffer overflow exploits are highly unlikely. It’s not a formal guarantee, but billion-dollar companies run Java servers all the time.Best Practices
Ultimately, you should consider using an API or language features that are designed for the task at hand, whether it is creating a SQL query or building an HTML page. Not only do these languages and APIs increase your confidence with regard to security, but they often facilitate programming as well. Compared with the old-school tactic of concatenating a bunch of strings, we now have LINQ and XML literals that arguably make code easier to write, easier to read, and also easier to verify. I’m a fan of language enhancements and APIs that improve both code quality and programmer productivity!