People, you recite this verse, "You who believe, take care of your own souls. Those who go astray cannot harm you if you are rightly guided" [Maidah 5:105]. But I heard the Messenger of Allah ﷺ say, "When people see a wrongdoer and do not restrain his hand, Allah is about to engulf them all in a punishment from Himself."Muhammad bin Bashshar narrated to us, Yazid bin Harun narrated to us from Ismail bin Abu Khalid something similar.
حدثنا أحمد بن منيع حدثنا يزيد بن هارون أخبرنا إسمعيل بن أبي خالد عن قيس بن أبي حازم
أيها الناس إنكم تقرءون هذه الآية {يا أيها الذين آمنوا عليكم أنفسكم لا يضركم من ضل إذا اهتديتم} وإني سمعت رسول الله ﷺ يقول إن الناس إذا رأوا الظالم فلم يأخذوا على يديه أوشك أن يعمهم الله بعقاب منه حدثنا محمد بن بشار حدثنا يزيد بن هارون عن إسمعيل بن أبي خالد نحوه
[Its chain of transmission is sahih]. Abu Dawud narrated it in the Book of Wars, chapter on commanding and forbidding, no. 4338, and Ibn Majah, no. 4005, from the hadith of Ismail bin Abu Khalid with this wording, and he stated explicitly that he heard it directly, as recorded by Ahmad, 5/1, and Ibn Hibban graded it sahih (al-Ihsan), 304.There is also a narration on this subject from Ayesha [Ibn Majah, no. 4004, and Ibn Hibban, no. 1841], Umm Salama [Ahmad, 294/6, 418], Numan bin Bashir [to come, 2173], Abdullah bin Umar [Tabarani in al-Awsat, 1/217, no. 1389], and Huzaifa [to come, 2169, 2170].