Sahih Muslim , Book 19, Hadith 4427 (USC-MSA)

It has been narrated on the authority of Aswad b. Qais who said: The Messenger of Allah was in a cave (or raid) when his finger was hurt.

وَحَدَّثَنَاهُ أَبُو بَكْرِ بْنُ أَبِي شَيْبَةَ، وَإِسْحَاقُ بْنُ إِبْرَاهِيمَ، جَمِيعًا عَنِ ابْنِ عُيَيْنَةَ، عَنِ الأَسْوَدِ بْنِ قَيْسٍ، بِهَذَا الإِسْنَادِ وَقَالَ كَانَ رَسُولُ اللَّهِ صلى الله عليه وسلم فِي غَارٍ فَنُكِبَتْ إِصْبَعُهُ ‏.‏

sunnah.com