I heard the Messenger of Allah ﷺ say, "The lawful is clear and the unlawful is clear, and between the two are doubtful matters that many people do not know. Whoever avoids the doubtful matters protects his religion and his honor, and whoever falls into the doubtful matters falls into the unlawful, like a shepherd grazing his flock around a private pasture, on the verge of letting them graze in it. Indeed, every king has a private pasture, and indeed the private pasture of Allah is what He has forbidden. Indeed, in the body there is a morsel of flesh which, if it is sound, the whole body is sound, and if it is corrupt, the whole body is corrupt. Indeed, it is the heart."
سمعت رسول الله ﷺ يقول: إن الحلال بين، وإن الحرام بين، وبينهما مشتبهات لا يعلمهن كثير من الناس، فمن اتقى الشبهات استبرأ لدينه وعرضه، ومن وقع في الشبهات وقع في الحرام، كالراعي يرعى حول الحمى، يوشك أن يرتع فيه، ألا وإن لكل ملك حمى، ألا وإن حمى الله محارمه، ألا وإن في الجسد مضغة، إذا صلحت صلح الجسد كله، وإذا فسدت فسد الجسد كله، ألا وهي القلب.
Bukhari narrated it in the Book of Faith (52), and Muslim in the Book of Sales (1599), both through Zakariya, from Amir Shaybi, who said, "I heard Numan bin Bashir say," and then he mentioned it. The wording given is that of Muslim, and Bukhari's wording is similar.