Opioid use is often illegal, and some have called the widespread use of these drugs an epidemic.
That said, enforcement can be tricky. These aren't illegal substances all on their own, like cocaine or heroin. If you have a prescription, they are completely percent legal. There are safe ways to use them. Medical professionals are involved.
This can make things harder for the authorities because simply finding the drugs doesn't mean the law was broken. There's far more to it than that.
Naturally, this could also lead to false arrests. Police officers are human. They make mistakes. Someone who has legally obtained opioids for a real medical issue could theoretically be arrested if the authorities think the drugs were obtained and/or used illegally.
To help streamline the process, the Department of Justice has created a special unit that looks directly for abuse and fraud. One of their main focuses is cracking down on alleged health care fraud.
This could include, for example, the so-called pill mills that will give out prescription drugs to those who either abuse them or then sell the pills illegally. In some cases, doctors could even be involved by writing out prescriptions to people who don't need them in order to bring in money on the side.
With a situation this complex, there are a ton of factors that have to be taken into account with every arrest. The government clearly knows that, as the formation of the unit shows, but there's no perfect system. Those who have been arrested must know about all of the legal defense options that they have moving forward.
Source: FindLaw, "DOJ Launches New Opioid Fraud and Abuse Detection Unit," Christopher Coble, accessed Oct. 20, 2017