Even if they lit it, you should’ve definitely told them to either go in a different room, or put it out completely. To be honest, you put yourself at risk by allowing them since it’s a class A drug so never feel bad saying no. Especially in your own home.
And I don’t know specifically about cocaine but I know passive smoking of cannabis definitely effects them and can cause them to die from dehydration (saw it on a different thread).
Can You Get A Hamster High? - Neeness
Also, rats, pigs and monkeys are largely used in animal testing since their nervous system and basic anatomy is so similar to ours, and given that rats are closely related to hamsters my best guess is that they do get affected by passive inhalation of cocaine too.
I should also add, being a class A drug means in humans using it would mean you get a ‘comedown’ some time after, where you can get chills, dehydration, fatigue, basically feeling really ill and for us it’s recommended to flush it out your system. Keep in mind hamsters can not throw up, so the only way for it to be okay is to drink and pee it out.
Please never allow this to happen again, it’s dangerous for your hammie and puts you at risk.