In California, the law reads:
The Return of the Deposit
If a tenant damages the property, the landlord can deduct the cost of fixing it from the security deposit. But if the tenant returns the rental in substantially the same condition in which it was rented (lessreasonable wear and tear), the landlord must return the deposit. A landlord can't make tenants pay for painting, new carpets or curtains, unless there was serious damage. The landlord is allowed to deduct the cost of cleaning if necessary to put the unit back to the same level of cleanliness it was in at the time the property was leased (less reasonable wear and tear).