Qatadah narrates: I heard Anas bin Malik (may Allah be pleased with him) say that the Messenger of Allah (peace and blessings be upon him) said: "Spitting in the mosque is a sin, and its expiation is to cover it up."
Hadith Referenceالسنن الكبرى للبيهقي / كتاب الصلاة / 3588
It is reported through another chain that Sayyiduna Anas (may Allah be pleased with him) said that the Messenger of Allah (peace and blessings be upon him) said: "Spitting in the mosque is a sin, and its expiation is to bury it."
Hadith Referenceالسنن الكبرى للبيهقي / كتاب الصلاة / 3589
Sayyiduna Abu Dharr (may Allah be pleased with him) narrates that the Messenger of Allah (peace and blessings be upon him) said: "The good and bad deeds of my Ummah were presented to me. Among the good deeds I saw the removal of something harmful from the road, and among the bad deeds I saw phlegm that someone had dropped in the mosque and that was not buried."
Hadith Referenceالسنن الكبرى للبيهقي / كتاب الصلاة / 3590
It is narrated from Sayyiduna Abu Hurayrah (may Allah be pleased with him) that the Messenger of Allah (peace and blessings be upon him) said: "Whoever comes into the mosque and spits or drops phlegm there, let him dig into the soil and bury it. If he cannot do so, then let him spit into his garment and take it with him when he leaves."
Hadith Referenceالسنن الكبرى للبيهقي / كتاب الصلاة / 3591