For the 16 years that Dr. Brian Westerberg, a Canadian surgeon, worked volunteer missions at the Mulago National Referral Hospital in Kampala, Uganda, scarcity was the norm. The patients usually exceeded the 1,500 allotted beds. Running water was once cut off when the debt-ridden hospital was unable to pay its bills. On some of his early trips, Westerberg even brought over drugs from Canada in order to treat patients. But as low-cost generics made in India and China became widely available through Uganda’s government and international aid agencies in the early 2000s, it seemed at first like the supply issue had been solved.

Then on February 7, 2013, Westerberg examined a feverish 13-year-old boy who had fluid oozing from an ear infection. He suspected bacterial meningitis, though he couldn’t confirm his diagnosis because the CT scanner had broken down. The boy was given intravenous ceftriaxone, a broad-spectrum antibiotic that Westerberg believed would cure him. But after four days of treatment, the ear had only gotten worse. As Westerberg prepared to operate, the boy had a seizure. With the CT scanner working again, Westerberg ordered an urgent scan, which revealed small abscesses in the boy’s skull, likely caused by the infection.

When a hospital neurosurgeon looked at the images and confidently declared that surgery was unnecessary and the swelling and abscesses would abate with effective antibiotic treatment, Westerberg was confused. They had already treated the boy with intravenous ceftriaxone, which hadn’t worked. His confusion deepened when his colleague suggested that they switch the boy to a more expensive version of the drug. Why swap one ceftriaxone for another?

Most people assume that a drug is a drug — that Lipitor, for example, or a generic version, is the same anywhere in the world, so long as it’s made by a reputable drug company that has been inspected and approved by regulators. That, at least, is the logic that has driven the global generic-drug revolution: that drug companies in countries like India and China can make low-cost, high-quality drugs for markets around the world. These companies have been hailed as public-health heroes and global equalizers, by making the same cures available to the wealthy and impoverished.

But many of the generic drug companies that Americans and Africans alike depend on, which I spent a decade investigating, hold a dark secret: they routinely adjust their manufacturing standards depending on the country buying their drugs, a practice that could endanger not just those who take the lower-quality medicine but the population at large.

These companies send their highest-quality drugs to markets with the most vigilant regulators, such as the U.S. and the European Union. They send their worst drugs — made with lower-quality ingredients and less scrupulous testing — to countries with the weakest review.

The U.S. drug supply is not immune to quality crises — over the last ten months, dozens of versions of the generic blood pressure drugs valsartan, losartan and irbesartan have been subject to sweeping recalls. The active ingredients in some, manufactured in China, contained a probable carcinogen once used in the production of liquid rocket fuel. But the patients who suffer most are those in so-called “R.O.W. markets” — the generic-drug industry’s shorthand for “Rest of World.” In swaths of Africa, Southeast Asia and other areas with developing markets, some generic drug companies have made a cold calculation: they can sell their cheapest drugs where they will be least likely to get caught.

Read the rest of Katherine Eban’s article at TIME