I was arrested for possession of cocaine, but it was just dust residue. Can they do that?

Maybe not. There is such a thing as the doctrine of “usable quantities” of illegal drugs. Consult an experienced drug lawyer in your area to see if that doctrine is effective in your jurisdiction. It would likely need the services of a defense expert toxicologist to put such a defense in though, and that can be expensive.

The concept is that especially with cocaine, minute particles of it cover so much of modern society, that it should not be used as a basis for conviction if it isn’t even enough to use to get high. The prime example is with currency. Narcotics officers used to testify that finding cocaine residue on money found in a defendant’s possession proves that he was selling cocaine, because they know that dealers usually put their cash drug money in with the drugs. However, one alert defense attorney had random money from the wallets of the judge and court personnel tested and most all of it was contaminated with cocaine. So now, sometimes “non-usable quantities” can be shown to avoid a conviction.