You can stay 90 days after foreclosure or to the end of your lease per the link below. Its says...
"These rules changed dramatically on May 20, 2009, when President Obama signed the "Protecting Tenants at Foreclosure Act of 2009." This legislation provided that leases would survive a foreclosure -- meaning the tenant could stay at least until the end of the lease, and that month-to-month tenants would be entitled to 90 days' notice before having to move out (this notice period is longer than any state's non-foreclosure notice period, a real boon to tenants)."
"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."