That is one of its wordings, and similar versions have been narrated from Abu Hurayrah1, ʿUbadah ibn al-Samit2, and ʿItban ibn Malik3 (may Allah be pleased with them).
Section Four: General texts that are qualified by a condition which leaves no room for abandoning the prayer.
Among them is the Prophet’s ﷺ statement in the narration of ʿItban ibn Malik: “Allah has forbidden the Fire to anyone who says, ‘There is no god but Allah,’ seeking thereby the Face of Allah.” Reported by al-Bukhari4.
Likewise, in the narration of Muʿadh he ﷺ said: “No one bears witness that there is no god but Allah and that Muhammad is the Messenger of Allah—sincerely, from his heart—except that Allah forbids him to the Fire.” Reported by al-Bukhari5.
Accordingly, making the utterance of the two testimonies conditional upon purity of intent and truthfulness of heart