Google extensions could aid Java security

Borrowing a technique from Eiffel, Google is adding Design-By-Contract functionality to Java

Google is developing a set of extensions for Java that should aid in better securing Java programs against buffer overflow attacks.

Last Friday, Google announced that it open sourced a project that its engineers were working on to add a new functionality into Java called Contracts, or Design-By-Contract (DBC).

Google's implementation, called Contracts For Java, or Cofoja for short, is based off of Modern Jass, a set of Java annotations developed by Johannes Rieken.

Primarily touted as a technique to ease programming, Contracts could also provide an easy way for developers to guard against buffer overflow attacks, the researchers said.

One of the oldest techniques in the attacker's virtual arsenal, buffer overflows remain a problem. In December, Microsoft identified 2.6 million possible attacks that could be waged using a stack-based buffer overflow in the JRE (Java Runtime Engine).

In a nutshell, Contracts requires that each time a method is called in a running program, any values passed to the method must meet a set of predefined criteria. Likewise, each time a method returns a value, it must also meet a set of criteria.

"DBC should be understood as a contract between components of a software," said Rieken, in an e-mail interview.

The researchers borrowed the idea from another language, Eiffel, where the concept is known as Design-By-Contract (DBC). Eiffel advocates claim DBC makes that language more secure than most.

In their blog post announcing the release, the Google developers touted Contracts as a way to ease Java programming, as it helps pinpoint bugs in a complex body of malfunctioning code.

But Contracts can also help make Java code more secure, said Andreas Leitner, a testing software engineer at Google and member of the Cofoja team, in an e-mail.

"By annotating your code with contracts you are much more likely to reveal bugs in earlier phases of development," Leitner said. It could be particularly helpful in finding bugs that don't crash a program but nonetheless put them into "funny states," Leitner said. Such states could possibly "be exploited by attackers to gain ownership of data or machines," he said.

Even without DBC, Java already has a number of advantages over many other languages in terms of security, because it runs in a sandbox and requires programmers to define the data types of variables before they are used. However, DBC could provide additional security by preventing buffer overflow-styled attacks, where a program could be crashed or otherwise manipulated by the injection of a larger-than-expected input value.

A contract "can ensure that an input doesn't exceed a certain length," Rieken said. It could also ensure that invariant values remain the same when they are called.

"Such checks [are] for situations where the programmer usually says 'it wasn't meant to be used like that,'" he said.

The Google developers behind Cofoja are working on the project during the 20 percent of work time that Google allows its employees to pursue individual projects.

Join the PC World newsletter!

Error: Please check your email address.

Tags application developmentLanguages and standardsGooglesecuritysoftwareExploits / vulnerabilitiesOracle

Our Back to Business guide highlights the best products for you to boost your productivity at home, on the road, at the office, or in the classroom.

Keep up with the latest tech news, reviews and previews by subscribing to the Good Gear Guide newsletter.

Joab Jackson

IDG News Service
Show Comments

Most Popular Reviews

Latest News Articles

Resources

PCW Evaluation Team

Azadeh Williams

HP OfficeJet Pro 8730

A smarter way to print for busy small business owners, combining speedy printing with scanning and copying, making it easier to produce high quality documents and images at a touch of a button.

Andrew Grant

HP OfficeJet Pro 8730

I've had a multifunction printer in the office going on 10 years now. It was a neat bit of kit back in the day -- print, copy, scan, fax -- when printing over WiFi felt a bit like magic. It’s seen better days though and an upgrade’s well overdue. This HP OfficeJet Pro 8730 looks like it ticks all the same boxes: print, copy, scan, and fax. (Really? Does anyone fax anything any more? I guess it's good to know the facility’s there, just in case.) Printing over WiFi is more-or- less standard these days.

Ed Dawson

HP OfficeJet Pro 8730

As a freelance writer who is always on the go, I like my technology to be both efficient and effective so I can do my job well. The HP OfficeJet Pro 8730 Inkjet Printer ticks all the boxes in terms of form factor, performance and user interface.

Michael Hargreaves

Windows 10 for Business / Dell XPS 13

I’d happily recommend this touchscreen laptop and Windows 10 as a great way to get serious work done at a desk or on the road.

Aysha Strobbe

Windows 10 / HP Spectre x360

Ultimately, I think the Windows 10 environment is excellent for me as it caters for so many different uses. The inclusion of the Xbox app is also great for when you need some downtime too!

Mark Escubio

Windows 10 / Lenovo Yoga 910

For me, the Xbox Play Anywhere is a great new feature as it allows you to play your current Xbox games with higher resolutions and better graphics without forking out extra cash for another copy. Although available titles are still scarce, but I’m sure it will grow in time.

Featured Content

Latest Jobs

Don’t have an account? Sign up here

Don't have an account? Sign up now

Forgot password?