For the second time in recent years, prosecutors across Massachusetts are confronting the possibility that thousands of drug investigations may have been built on flawed scientific ground — raising the specter of convictions being thrown out.
That potential emerged amid disclosures that a former chemist at a Department of Public Health lab in Amherst was regularly high on the job and dipped into the lab’s stash of drugs for her own use. Those revelations have cast doubt upon tests performed at the now-shuttered lab.
Identifying defendants whose cases were affected — and figuring out how to reverse the damage — promises to be an expensive and complicated process, officials said.
Berkshire District Attorney David E. Capeless, president of the Massachusetts District Attorneys Association, said legislators will need to provide prosecutors with additional money so they can review cases.
“There is an extensive number of cases involved,’’ Capeless said.
Governor Charlie Baker said he expected to put resources aside to address the problem.
“We certainly believe we are going to have a big responsibility to work with the courts and with others to make sure that people who are affected by this have the appropriate opportunity to engage in that conversation,” Baker said during a press availability Tuesday.
The findings about the lab came from an investigation by Attorney General Maura Healey. The chemist at the center of the probe, Sonja Farak, testified she was under the influence of illicit drugs during her eight years working at the Amherst lab.
But the Healey inquiry also identified potential systemic flaws in practices at the laboratory. Chemists routinely identified prescription drugs only by visual examination, according to the attorney general’s report. And instead of purchasing certified drug samples called “primary standards” for chemists to compare to unknown evidence samples, the lab manager acknowledged making his own reference drugs.
“This is not a one-off, or a ‘bad apple’ issue,” said Thomas E. Workman Jr., a forensic scientist who teaches scientific evidence at University of Massachusetts Law School. “This is a problem with a procedure that invites this kind of misuse.”
Capeless said his office funneled thousands of cases through the Amherst lab, but is primarily concerned about 1,800 samples that underwent testing to determine whether the substances were illegal drugs.
“I can tell you right now I have a concern about every case that went through the Amherst lab,’’ he said, pointing to the totality of flaws found and not just Farak’s actions. “Based on what she did, but also the more recent revelations about what her co-workers engaged in, it’s very disturbing.’’
When Farak was prosecuted after her arrest in 2013, officials contended that her actions would have minimal impact on drug cases, and that she was involved in testing drug samples only from Worcester County and western jurisdictions.
But prosecutors now know otherwise.
Suffolk District Attorney Daniel F. Conley’s office has identified slightly more than 500 cases in which Farak was involved in the testing of drugs — mostly suspected marijuana or prescription pills — dating to 2005. In that year alone, she was involved in 197 cases.
Farak continued to test drugs from Suffolk County over the intervening years and was last involved in 2009, when she examined seven cases, Conley spokesman Jake Wark wrote in an e-mail. He said because most drug cases are resolved through a guilty plea, there was only a “very, very small’’ chance she testified in Suffolk drug cases.
Farak admitted in grand jury testimony during the attorney general’s investigation that she testified while under the influence of drugs a number of times.
A total of 1,500 drug samples were sent to the Amherst lab in recent years from the Suffolk district attorney’s office, and Conley’s office is reviewing how to respond to the second case involving public health lab workers who potentially undermined criminal cases.
Another former state chemist, Annie Dookhan, was arrested in September 2012 and found to have fabricated evidence in thousands of samples she tested at the public health lab in Jamaica Plain, possibly tainting as many as 40,000 cases and leading to her conviction. Dookhan was paroled in April.
Norfolk County District Attorney Michael W. Morrissey said Farak is listed as the testing chemist in 300 cases, and about 2,000 drug samples — involving up to 800 criminal prosecutions — ended up in the Amherst lab over the years.
“As we are provided additional information, we continue to review cases and identify others,’’ Morrissey spokesman David Traub wrote in an e-mail. He said Farak never testified in Norfolk County.
Essex County District Attorney Jonathan Blodgett’s office said Farak tested 190 samples from his jurisdiction during her career in Amherst and that the office did not send other samples to the Amherst lab.
Farak played a role in about 100 cases handled by Plymouth County District Attorney Timothy J. Cruz’s office, a spokeswoman said; the chemist also handled about 400 cases in Middlesex County, according to a spokeswoman for Middlesex District Attorney Marian T. Ryan. Middlesex sent about 2,000 cases to the lab, the spokeswoman said.
Other district attorneys offices said they were still collecting data on Farak’s potential role in their jurisdictions, or did not respond to Globe requests for information.
Prosecutors said they will use lessons from the Dookhan case — in which retesting, in some instances, confirmed the presence of illegal drugs — as they confront problems linked to the Amherst lab.
The state court system, which was forced to create special court sessions to deal with the Dookhan-related cases, is preparing to do the same for Amherst lab cases, a Trial Court spokeswoman wrote in an e-mail.
Northwestern District Attorney David E. Sullivan, whose jurisdiction includes Amherst, expressed frustration he will not be able to prosecute Farak because she reached an immunity agreement with Healey’s office. He called the flaws identified in the lab “quite concerning.’’