I believe what happens is the lender foreclosing on the home will offer the tenant two options:
1. Stay in the home for the remainder of the lease (which they should have the ability to).
2. Receive cash for keys to vacate the property in good condition. Instead of you (the owner) of the property receiving the cash for keys the tenant would for their troubles. This is not the security deposit however it could end up being larger than the security deposit. I typically see them giving out on average 3500.00 to the people living in the property.