The Messenger of Allah ﷺ said, "The blood of a Muslim who testifies that there is no god but Allah and that I am the Messenger of Allah is not lawful to shed except in three cases, the married person who commits adultery, a life for a life, and the one who abandons his religion and separates from the community."
قال رسول الله ﷺ: لا يحل دم امرئ مسلم يشهد أن لا إله إلا الله وأنى رسول الله إلا بإحدى ثلاث: الثيب الزاني، والنفس بالنفس، والتارك لدينه المفارق للجماعة.
Bukhari reported it in the Book of Blood Money (6878), and Muslim in the Book of Qasama (1676), both through Amash, from Abdullah bin Mura, from Masruq, from Abdullah, who said, then he mentioned it. The wording is Muslim's, and Bukhari's wording is similar.