The Messenger of Allah ﷺ said, "The two parties to a sale each have the option to back out as long as they have not parted, except in a sale where the option has been stipulated."
حدثنا عبد الله بن مسلمة عن مالك عن نافع
أن رسول الله ﷺ قال المتبايعان كل واحد منهما بالخيار على صاحبه ما لم يفترقا إلا بيع الخيار
Bukhari narrated it in the Book of Trade, in the chapter "The two parties to a sale have the option [to cancel] as long as they have not separated," Hadith: 2111, and Muslim narrated it in the Book of Trade, in the chapter "The confirmation of the option of the session for the two parties to a sale," Hadith: 1531, from the hadith of Malik through this same chain, and it is found in Muwatta (Yahya): 2/671.