 -- A deadly 2014 Listeria outbreak linked to caramel apples has puzzled researchers attempting to understand how the favorite Halloween treat could be the source of the deadly bacteria.

The 2014 outbreak left at least seven dead and 35 infected, according to the U.S. Centers for Disease Control and Prevention.

Now, thanks to a new study, scientists think they have cracked the code on how Listeria bacteria can quickly grow on caramel apples even though it rarely grows easily on apples or caramel.

The scientists had been puzzled about why the outbreak was linked to apples, which traditionally are too acidic for Listeria bacteria to grow quickly. Additionally, caramel doesn't often grow the bacteria because of low water content, according to the study.

The new study published this week in the medical journal mBio examines how the Listeria monocytogenes could grow in large numbers. To figure out how the desserts developed the bacteria, the team from the University of Wisconsin-Madison's Food Research Institute swabbed the apples with the bacteria, then dipped the apples in caramel and, using either sticks or tongs, allowed them to cool.

The apples were then stored for four to six weeks at temperatures ranging from 77 to 44.6 degrees. The researchers were surprised to find that even dipping the apple in hot caramel did not kill all the surface bacteria. And the coating of caramel created an ideal layer for bacteria to grow.

Because Listeria bacteria can grow even in refrigerated temperatures, researchers found that the apples could potentially have caused infection if they were consumed weeks after being made.

"If someone ate those apples fresh, they probably would not get sick," lead study co-author Kathleen Glass, associate director of the Food Research Institute, said in a statement. "But because caramel-dipped apples are typically set out at room temperature for multiple days, maybe up to two weeks, it is enough time for the bacteria to grow."

Additionally, in the apples with sticks, researchers found that bacteria concentrations were found around the stick inside the apple. They theorized that the stick pushed the bacteria into the apple where it was protected from hot caramel and could grow.

Dr. William Schaffner, an infectious disease expert at Vanderbilt University in Nashville, Tennessee, said that while cases of Listeria linked to caramel apples remain low, those concerned can trade in the sweet treat for a fresh apple that is carefully washed with soap in the sink.

He explained that Listeria can be an infection difficult to pin down because the incubation period can be weeks.

"Listeria is an infection that also is a little bit tricky because it can have a long incubation period," Schaffner explained to ABC News. "But Listeria can smolder after you ingest it, you can be sick up to a month later. The illness is characterized by diarrhea, abdominal pain, fever, chills."

In rare cases, the infection can cause meningitis or swelling of the brain and is associated with miscarriage in pregnant women.