Hadithcore
Sahih Muslim, 12 b
sahih

It is narrated on the authority of Thabit that Anas said:

We were forbidden in the Holy Qur'an that we should ask about anything from the Messenger of Allah (ﷺ) and then Anas reported the hadith in similar words.

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

References2 variants
In-Book Reference
Book 1, Hadith 11
USC-MSA web (English) reference
Book 1, Hadith 10 (deprecated numbering scheme)