This is definitely a question for a tenant's rights attorney (which I am not). Unfortunately, you are caught in the same "Catch 22" as a lot of renters these days. Here are some of the things I know from experience, or have heard of in real estate circles:
1. Your lease is with the current owner of the home. Failure to pay your lease payments gives them the right to evict you.
2. The owner has signed a Deed of Trust as a promise to pay his mortgage to the lender. In many of these documents there is an "assignment of rents" which basically states that if the owner is delinquent on his payments and the property generates rents, the rents are owed to the lender.
So, if you put these two things together, do you pay the rent to the owner or to the lender? Only a tenant's rights attorney will be able to give you clear direction on this.
Regarding your security deposit, unfortunately, if and when the bank forecloses on the property they are not the holders of the security deposit and therefore cannot refund it to you. And, my guess is that the owner does not have the funds to pay you back your security deposit either, so taking them to small claims court may not work either. On the other hand, once the bank takes ownership of the property they will usually offer you "cash for keys" to get you to move out and not damage the property.
Lastly, many home owners are successfully negotiating loan modifications, as the lenders do not want to own any more homes. If your landlord is successful in doing this and they view you as a trouble maker, you might have to move out anyway. And, the owner may have an easier time negotiating a loan modification with a solid, paying tenant in the property. Perhaps you can offer them your cooperation for a reduced rent during this period. Or offer to pay rent until the Notice of Trustee Sale is filed (you will know this has happened because it will get posted on your door) and then be allowed to use your security deposit for this final month's rent. Try to make it a win-win situation and maybe you can smooth things over. Remember, they are not mad at you, they are mad at themselves and the bank. They are just taking it out on you, which is unfortunate.
Wish there were more clarity on this issue, as so many nice people, like you, are getting caught up in a foreclosure mess they did not create. I wish you luck in resolving this with your landlord. Feel free to call me if you want to discuss your options. Dare to Dream.
Real Estate Consultant
RE/MAX Palos Verdes Realty