US researchers have created a new system that can quickly comb through tens of thousands of lines of application code to find security flaws in popular web-based apps.
The system, developed at the Massachusetts Institute of Technology (MIT), uses a technique called static analysis, which seeks to describe, in a very general way, how data flows through a program.
"The classic example of this is if you wanted to do an abstract analysis of a program that manipulates integers, you might divide the integers into the positive integers, the negative integers, and zero," said Daniel Jackson, an MIT professor and the co-author of the study.
The static analysis would then evaluate every operation in the program according to its effect on integers' signs. Adding two positives yields a positive; adding two negatives yields a negative; multiplying two negatives yields a positive; and so on.
"The problem with this is that it can't be completely accurate, because you lose information," Jackson said. "If you add a positive and a negative integer, you don't know whether the answer will be positive, negative, or zero. Most work on static analysis is focused on trying to make the analysis more scalable and accurate to overcome those sorts of problems," he added.
With web applications, however, the cost of accuracy is prohibitively high. "The program under analysis is just huge," he said.
"Even if you wrote a small program, it sits atop a vast edifice of libraries and plug-ins and frameworks. So when you look at something like a web application written in language like Ruby on Rails, if you try to do a conventional static analysis, you typically find yourself mired in this huge bog. And this makes it really infeasible in practice."
That vast edifice of libraries, however, also gave Jackson and his former student Joseph Near, a way to make static analysis of programs written in Ruby on Rails practical. They exploited some peculiarities of the popular web programming framework to develop their system called "Space".
The researchers will present their results at the International Conference on Software Engineering to be held in Austin, Texas, in May this year. In his PhD work, Near used this general machinery to build three different debuggers for Ruby on Rails applications, each requiring different degrees of programmer involvement.
Near identified seven different ways in which web applications typically control access to data. Some data are publicly available, some are available only to users who are currently logged in, some are private to individual users, some users -- administrators -- have access to select aspects of everyone's data, and so on.
For each of these data-access patterns, Near developed a simple logical model that describes what operations a user can perform on what data, under what circumstances. From the descriptions generated by the hacked libraries, Space can automatically determine whether the program adheres to those models.
If it does not, there's likely to be a security flaw. In tests on 50 popular web applications written using Ruby on Rails, the system found 23 previously undiagnosed security flaws, and it took no more than 64 seconds to analyse any given program.