Here is a link to a useful state pamphlet regarding tenants with landlords going in to foreclosure. http://www.mass.gov/Eoca/docs/foreclosure/tenantpamph.pdf
Also it would not be a bad idea to talk with an attorney if you have concerns.
Once the house is foreclosed upon, to whom do I pay rent?
As a tenant of a foreclosed property, you are required to pay rent to the new owner. If you do not know who the landlord is, such information is available at the Registry of Deeds and the local tax assessorâ€™s office. Send your new landlord a letter offering to pay rent and requesting proper payment information, e.g., name, address, date due. Make sure you have proof of the true landlord before you pay.
Logically, your lease states you'll be paying rent in return for the right to occupy the property- it isn't really your concern how the landlord spends it or what bills he or she chooses to apply it to. As long as you continue to occupy the apartment, you owe rent.
You may also be able to find the answer on the website for the Massachussetts Department of Community Affairs, but the best thing to do is to ask a lawyer.