If somebody does something illegal in your car or puts you at legal risk can you sue them? Or am I liable because I have them permission to enter the car?
The question would be standing.
For you to sue someone, usually you must have been affected by their acts and you do sue them to get compensated/to get something done. So to sue them you should have to argue how their drug usage affected you. A risk that did not materialize is not a damage.
Now, you talk about a "legal risk". As a rule of thumb, your legal risks come from your actions. If YOU allowed me to use drugs in your car and that did mean that YOU did broke a law, then it is not my fault that you broke the law (it will be my fault the laws that I did broke). Conversely, if allowing me to use drugs did not break any law, you would not be in trouble even if I was breaking it next to you.
Obviously, you cannot ask me to pay the damages of your actions.
But then, if consuming drugs in a car is illegal you could denounce them to law enforcement (police officers), there it would be a matter that they are breaking a law and it is up to the state to punish them (if they consider it worthwhile and they have enough evidence). But it will not be your decision but the state's (usually in the USA in the persons of the police officers first and the District Attorney later on).
And even if using drugs in a car is not illegal, you can ask those persons to leave and, if they do refuse then they are breaking the law by trespassing. You may denounce them to the police that will force them to leave and may decide to arrest them/initiate criminal proceedings (again based on the decision of the police officers and the DA, although if you are ok with that people simply leaving the car it is unlikely that the state would press charges).
To the second question "Or am I liable because I have them permission to enter the car?"
You're not likely to be prosecuted for any crime committed by someone who borrowed your car as long as there was no reason to believe you were involved in the planning of the crime.
You do risk losing your car though. If someone is arrested while driving your car, it will certainly be impounded and cost you money to get it out (several hundred dollars in most places). Also, many US jurisdictions allow a vehicle used in the commission of a crime (including drug use) to be confiscated (asset forfeiture) and made the possession of the arresting agency. There are almost no protections against asset forfeiture except to try and convince the agency not to take your car. I've been through this and was able to convince the arresting officer that she should allow me to keep my car. I still had to pay to get it out of impound.
As to whether you can sue prior to any of that happening, I don't know. You could sue to recover your losses if any of that did happen, but being placed at risk of that happening might not be legal standing to sue.