Pretty involved, actually. Forensically finding the problem was right out of CSI.
http://www3.epa.gov/otaq/cert/documents/vw-nov-caa-09-18-15.pdf
"Alleged Violations
Each VW vehicle identified by the table below has AECDs that were not described in the
application for the COC that purportedly covers the vehicle. Specifically, VW manufactured ana
installed software in the electronic control module (ECM) of these vehicles that sensed when the
vehicle was being tested for compliance with EPA emission standards. For ease of reference, the
EPA is calling this the "switch." The "switch" senses whether the vehicle is being tested or not
based on various inputs including the position of the steering wheel, vehicle speed, the duration
of the engine's operation, and barometric pressure. These inputs precisely track the parameters of
the federal test procedure used for emission testing for EPA certification purposes. During EPA
emission testing, the vehicles' ECM ran software which produced compliant emission results
under an ECM calibration that VW referred to as the "dyno calibration" (referring to the
equipment used in emissions testing, called a dynamometer). At all other times during normal
vehicle operation, the "switch" was activated and the vehicle ECM software ran a separate "road
calibration" which reduced the effectiveness of the emission control system (specifically the
selective catalytic reduction or the lean NOx trap). As a result, emissions of NOx increased by a
factor of 10 to 40 times above the EPA compliant levels, depending on the type of drive cycle
(e.g., city, highway)."