The Messenger of Allah ﷺ said, "Spitting in the mosque is a sin, and its expiation is to bury it."
حدثنا مسدد حدثنا أبو عوانة عن قتادة
قال رسول الله ﷺ البزاق في المسجد خطيئة وكفارتها دفنها
Recorded by Muslim, in the Book of Masjids, Chapter on the Prohibition of Spitting in the Masjid, from the hadith of Abu Awana, through this same chain.