Poppy seeds show up on drug tests because they can be contaminated with opiates like morphine and codeine from the latex of the poppy seed pod during harvesting. Although the seeds themselves do not contain opiates, this contamination causes drug tests, which are very sensitive, to sometimes detect these opiates in urine after consuming poppy seed-containing foods. The amount of opiates depends on how thoroughly the seeds are cleaned and processed, the variety of the poppy plant, and environmental factors where the plants are grown. Because of this, eating poppy seeds can occasionally lead to positive drug test results for opiates like morphine and codeine, even though the opiate levels are not high enough to cause intoxication.
Drug tests set specific cutoffs to differentiate between poppy seed ingestion and drug abuse, but variability in opiate content of seeds and food products makes it difficult to always distinguish the source of opiates detected.