Your landlord owns the property until title transfers to a new owner. This means that you still need to pay rent to your landlord. Many tenants in your situation stop paying rent but they have no legal grounds to do so.
Even if your landlord is in foreclosure, they still have the right to evict you for nonpayment. Your landlord might depend on the rental income to work out a solution with the lender.
You should begin by asking your landlord what to expect. The landlord may be able to save the home from foreclosure.
Try to discuss the possibility of getting your security deposit back early. You can try to negotiate an early move out or reduced rent. If your landlord wants to sell the property to avoid foreclosure, they may be willing to pay you to move out. Discuss moving costs with your landlord.
It may be in your best interest to remain on the property and pay rent. The Protecting Tenants at Foreclosure Act (PTFA) may offer you protection after the sale and transfer of the property.