(173) باب الْحَرْبِيِّ إِذَا دَخَلَ دَارَ الإِسْلاَمِ بِغَيْرِ أَمَانٍ
Narrated Salama bin Al-Akwa`:
"An infidel spy came to the Prophet (ﷺ) while he was on a journey. The spy sat with the companions of the Prophet (ﷺ) and started talking and then went away. The Prophet (ﷺ) said (to his companions), 'Chase and kill him.' So, I killed him." The Prophet (ﷺ) then gave him the belongings of the killed spy (in addition to his share of the war booty).
Reference: Sahih al-Bukhari 3051
In-book reference: Book 56, Hadith 257
USC-MSA web (English) reference(deprecated numbering scheme): Vol. 4, Book 52, Hadith 286