The police need one of two things to be able to legally search your car: they need either your permission or probable cause to suspect that searching your vehicle will reveal that you are breaking the law. For example, if a police officer pulls you over and smells drugs in your car, they have probable cause to search the vehicle. If they look into your ashtray and see what appears to be a half burned marijuana cigarette, they then have probable cause to search your vehicle. When it comes down to it, all a police officer needs to search your car is a reason and they’re very good at coming up with them.
There are instances, however, when you can prevent an officer from searching your vehicle. For example, it’s common for police officers to ask you if you know why you were pulled over when they pull you over. Admitting to anything is admitting to breaking the law and, in most cases, that gives them probable cause to search your vehicle. It’s always best to say that you have no idea why you are being pulled over.
If a police officer wants to, they can call in a drug sniffing dog to search your vehicle. Unfortunately, it’s very easy for a police officer to just say that the dog smells something contraband in your vehicle and to demand to search the rest of it. Technically, you have a fourth amendment right against unreasonable search and seizure; this is why there has to be probable cause to search your goods. In practice, however, a police officer can usually find a reason that gives them sufficient authority to search your vehicle. If you are being pulled over and charged with a crime or your vehicle is being towed away, the officer has the right to look through everything in your vehicle