A team of researchers led by the University of California-San Diego has finally figured out how Volkswagen was able to fool U.S. and European emission test for at least six years.

Their discovery, to be presented 38th IEEE Symposium on Security and Privacy, was made after a year-long investigation prompted Environmental Protection Agency's decision to put the company on notice in 2015 for violating the Clean Air Act.

"We were able to find the smoking gun. We found the system and how it was used," said Kirill Levchenko, a computer scientist at UC San Diego and lead investigator of the research team, in a press release. "We found evidence of the fraud right there in public view."

The researchers noted that the secret behind Volkswagen's ability to cheat emission tests lies in a code running on the cars' onboard computers. The code allowed the onboard computers to determine if the car is undergoing emission test. If the computer detected that the vehicle's emission is being tested, it will activate the car's emission curbing systems, significantly reducing the amount of pollutants emitted by the vehicle. After the test, the code will deactivate all the systems at play.

For their investigations, the researchers examined 900 versions of the code. Out of those versions, the researchers found 400 that included information to circumvent emission tests. The researchers noted a specific piece of code labeled as the "acoustic condition". Normally, this code controls the sound the engine makes. However, the code becomes a euphemism for conditions occurring during an emission tests.

In a standard emission test, the car is placed on a chassis equipped with a dynamometer that measures the power outage of the engine. During the test, the vehicle follows a precisely defined speed profile that mimics real driving on an urban route with frequent stops.

The conditions of the tests were both standardized and public, making it easier for car manufacturers to develop a defeat system that circumvent the test. In Volkswagen's case, their code allows as many as 10 different profiles for potential tests. When one of the profiles is met and the onboard computer determined that the vehicle is undergoing a test, it will activate its emission-curbing system, reducing the amount of nitrogen oxide emitted by the car. Without this defeat system, the researchers claim that the nitrogen oxide emission of Volkswagen could reach 40 times the amount allowed under EPA regulations.