The dietary laws that forbid Jews and Muslims from eating pork date back millennia—but when they were laid down, nobody conceived of detection tools that could find minuscule traces of the forbidden foods.

Malaysia is the latest country to find itself with a tainted food scandal, after the government’s halal inspectors—who ensure that foods adhere to Islamic dietary laws—used a DNA test to find trace elements of pork in Cadbury chocolate bars. That forced corporate snack giant Mondelez, Cadbury’s parent company, to issue a recall of Cadbury Dairy Milk Hazelnut and Cadbury Dairy Milk Roast bars, and triggered the ire of Muslim groups.

“They stuffed pigs into our mouths, then apologized,” said Azwanddin of the non-profit group Hamzah Jaringan Melayu Malaysia, who threatened to sue Mondelez. “This cannot be allowed.” More than 20 Malay-Muslim groups called for a boycott of Cadbury.

Malaysia’s Islamic Development Department, known as Jakim, began using DNA tests to certify halal products in 2010. It announced in 2011 that it had detected pig DNA in Heinz’s HP Sauce and Tabasco hot sauce, though both companies disputed the finding. Commercial DNA tests can detect as little as 5 picograms (trillionths of a gram) of porcine DNA.

The supply chain of industrial food products is mind-bogglingly complex, with dozens of ingredients drawn from around the world, which provides many opportunities for unwanted ingredients to contaminate them. But how do traces of pork actually get into a chocolate bar? One possibility is that industrial food packaging sometimes uses lubricants and stabilizers (known as stearates) that are made from animal derivatives, including pigs in some cases.

“Cross contamination can be an issue because the stearate can effectively ‘leak’ into the food,” said Bill Thompson, CEO of the lab testing firm Genetic ID Europe, in an interview with FoodProductionDaily.com in 2012.

For the food industry, halal scandals are bad PR and even worse for the bottom line—the halal food industry is estimated to be worth hundreds of billions of dollars worldwide. Malaysia is seen as the global leader for halal certification, with exports of $9.8 billion last year. Manufacturers should probably get used to having their products put under the microscope—literally.