Abdullah bin Abbas reported,

The Prophet ﷺ said, "Some people from my nation will gain deep understanding of the religion and recite the Quran, and they will say, 'We will go to the rulers and gain something of their worldly wealth, while keeping our religion separate from them.' But that cannot be, just as nothing can be picked from the thorn-tree except thorns, likewise nothing can be picked from being close to them except..."Muhammad bin al-Sabbah said, "It is as though he meant sins."

Ibn Majah 255

Daif

حدثنا محمد بن الصباح أنبأنا الوليد بن مسلم عن يحيى بن عبد الرحمن الكندي عن عبيد الله بن أبي بردة

عن ابن عباس

عن النبي ﷺ قال إن أناسا من أمتي سيتفقهون في الدين ويقرءون القرآن ويقولون نأتي الأمراء فنصيب من دنياهم ونعتزلهم بديننا ولا يكون ذلك كما لا يجتنى من القتاد إلا الشوك كذلك لا يجتنى من قربهم إلا قال محمد بن الصباح كأنه يعني الخطايا

ابن ماجه 255ضعيف
Contents
Reference
Commentary
Ayat
Collection
Sunan Ibn Majah
Book
Sunnah
Chapter
Benefiting from knowledge and acting upon it
Numbering
Darussalam 255
Ibn Majah 255