The security deposit is considered the lawful property of the tenant, until the landlord establishes a right to it.
Tenants are entitled to a refund of the deposit paid at the end of the tenancy where there is no rent or bills owing and there has been no damage to the dwelling beyond normal wear and tear.
Landlords are required to refund the deposit promptly less any deductions in respect of outstanding rent or other charges or taxes and damage in excess of normal wear and tear. If the rent, charges or taxes or the damage amounts to below the value of the deposit then the landlord should return the excess. The onus is on a landlord to show why a deposit should be retained.
A short guide to security deposits can be found here.