I think it depends a lot on where you live, but in most cases they get to decide how much they're taking out of your deposit.
If you think you're being unfairly charged and your landlord won't budge, the only real recourse you have is to take them to small claims court. If your apartment was in great shape when you moved out (and you can prove it) and your deposit isn't being returned, you probably have a case, or if the place was in the same shape when you moved in as it was when you moved out.
In this case, the burden of proof might be on the landlord, especially if they didn't do an inspection at the beginning of the tenancy.
Keep in mind, though, your entire security deposit is almost never returned because landlords will use some of it to clean the place up and make routine repairs. That should be a set amount that was specified in your lease.