If the foreclosure goes through - that the bank/lender takes back the property due to the foreclosure - they have the ability to evict you regardless if you have a lease that has not expired or not.
What I would do is find another residence immediately or as soon possible to move to and make no more payments to the landlord. (Unless you are certain that there is someway they are going to be able to stop the foreclosure somehow and can give you guarantees thereof - documented proof that it's stopped.)
Albeit that you technically owe the rent for the period of time or pursuant to the lease agreement - you may get really screwed here - you continue to pay but they don't pay the mortgage nor give you back your security deposit. They have obviously used the rental monies for something else and aren't paying the mortgage for whatever reason.
I would save my monies and find another place to live immediately. Basically, if they would file suit against you - you can claim "constructive evicition" that you were noticed of the foreclosure and didn't want to be out on the street.
Attorney
19 years legal practitioner: real estate, collections, estate, civil, business, and criminal law