It sounds like there are a lot of potential issues you are dealing with and that it makes sense for you to contact an attorney as soon as possible so as to limit any potential liability you might be facing. Generally speaking, it is a good idea to return an illegal security deposit as soon as a tenant makes such a demand since the case law suggests that a landlord's doing so can cut off treble damages and attorney's fees to which the tenant would otherwise be entitled. While it sounds like the pet deposit is very likely illegal, it is impossible to say for sure without reviewing the relevant documents.
The withholding of rent is a separate issue. G.L. c. 239 s. 8A lays out some specific requirements for rent withholding and if a tenant does not meet them, then they might not have the protection of that statute in a summary process case for non-payment of rent. If the rent withholding is due to potential code violations in the unit that you know about, you may want to consider acting quickly to fix them as additional liability can result from unreasonable delays in making required repairs.
Because of the many issues you are potentially facing, I suggest that you contact a landlord-tenant attorney as soon as possible to advise you as to how best to deal with everything and to limit your liability in the fact of what sounds like a difficult tenant.
The response given is not intended to create, nor does it create an ongoing duty to respond to questions. The response does not form an attorney-client relationship, nor is it intended to be anything other than the educated opinion of the author. It should not be relied upon as legal advice. The response given is based upon the limited facts provided by the person asking the question. To the extent additional or different facts exist, the response might possibly change.
I did not see a question in your posting. If you are inquiring as to whether pet deposits are illegal in MA the answer is yes. Hire an experienced attorney to counsel you as to the proper procedures necessary in the business of being a landlord. My clients pay me a few hundred dollars to save thousands later. It really is worth it and is tax-deductable.
No attorney-client relationship is created in responding to this question, and advice provided is based solely on very limited facts presented, and therefore may not be correct. You are advised that it is always best to contact a competent and experienced with the practice of law in the county in which you reside.
The law regarding the rental of residential property in Massachusetts IS NOT friendly to landlords and if you do something wrong you could end up paying triple damages and the tenant's attorney's fees. Pet deposits are not permitted. The maximum amount that you can collect up-front is first, last and security plus a small key deposit. If you were my client, I would advise you to return the pet deposit immediately.