The Messenger of Allah ﷺ said, "Spitting in the mosque is a sin, and its expiation is to bury it."
أخبرنا قتيبة قال حدثنا أبو عوانة عن قتادة
قال رسول الله ﷺ البصاق في المسجد خطيئة وكفارتها دفنها
Muslim reported it in the chapter on masjids, the chapter on the prohibition of spitting in the masjid, etc., hadith no. 552, from Qutayba. Bukhari reported it in the chapter on prayer, the chapter on the atonement for spitting in the masjid, hadith no. 415, from the hadith of Qatada with the same wording. It is also in Kubra, hadith no. 802.