You can stay until the house is actually forclosed and sold in which case you will receive notice that you can stay by permission of the new owner or you must leave. Legally you must continue to pay rent even when the house is in forclosure or the owner can evict you.
I doubt the bank will allow you to assume the mortgage with bad credit as you normally would need to qualify for a mortgage and with bad credit that can be very hard. If the bank allows you to continue to live in the property which is completely up to the bank then you would continue to be a tenant.
An exception was carved out for the buyer who intends to live on the property -- this buyer may terminate a lease with 90 days' notice. Importantly, the law provides that any state legislation that is more generous to tenants will not be preempted by the federal law. These protections apply to Section 8 tenants, too.
DISCLAIMER: Answers from Experts on JustAnswer are not substitutes for the advice of an attorney. JustAnswer is a public forum and questions and responses are not private or confidential or protected by the attorney-client privilege. The Expert above is not your attorney, and the response above is not legal advice. You should not read this response to propose specific action or address specific circumstances, but only to give you a sense of general principles of law that might affect the situation you describe. Application of these general principles to particular circumstances must be done by a lawyer who has spoken with you in confidence, learned all relevant information, and explored various options. Before acting on these general principles, you should hire a lawyer licensed to practice law in the jurisdiction to which your question pertains.
The responses above are from individual Experts, not JustAnswer. The site and services are provided “as is”. To view the verified credential of an Expert, click on the “Verified” symbol in the Expert’s profile. This site is not for emergency questions which should be directed immediately by telephone or in-person to qualified professionals. Please carefully read the Terms of Service (last updated February 8, 2012).