Like visiting a junk yard to find cheap parts for an aging vehicle, researchers from the Massachusetts Institute of Technology have come up with a way to fix buggy software by inserting working code from another program.
Using a system they call CodePhage, the researchers were able to fix flaws in seven common open-source programs by using, in each case, functionality taken from between two and four “donor” programs.
Fixing such errors can help make code more secure, since malicious hackers often exploit flaws to gain entry to a system. CodePhage can recognize and fix common programming errors such as out of bounds access, integer overflows, and divide-by-zero errors.
The researchers describe their approach in Monday’s edition of the journal Phys.Org. They also discussed it at a programming conference put on last month by the Association for Computing Machinery.
To fix a buggy program, CodePhage requires two sample inputs, one that causes the program to crash, and another that does not.
It runs those inputs through a second program, known as the donor program, that has similar functionality. The Internet is awash with open source software that could provide parts for donor programs, though there’s no particular reason the donor code needs to be open source.
Watching the donor program process the crash-free input, CodePhage notates all the actions taken. It then runs the input that caused the original program to crash, again notating the actions, in symbolic logic. CodePhage then analyzes how the two inputs were handled differently, and uses that information to correct the original program.
In many cases, the program being analyzed lacks the required security check present in the donor program. Up to 80 percent of a typical application can be code for conducting security checks. CodePhage could reduce the time developers spend writing those checks, by inserting them automatically into the build process, the researchers said.
MIT isn’t the only organization looking for novel ways to repair vulnerable software. Earlier this year, security vendor Qualys released software that can apply virtual patches to known vulnerabilities, eliminating the need to wait for the software vendor to patch the problem.