The Prophet ﷺ said: If anyone sows in other people's land without their permission, he has no right to any of the crop, but he may have what it cost him. (Using translation from Abū Dāʾūd 3403)
قَالَ رَسُولُ اللهِ ﷺ مَنْ زَرَعَ فِي أَرْضِ قَوْمٍ بِغَيْرِ إِذْنِهِمْ فَلَيْسَ لَهُ مِنَ الزَّرْعِ شَيْءٌ وَتُرَدُّ عَلَيْهِ نَفَقَتُهُ قَالَ الْخُزَاعِيُّ مَا أَنْفَقَهُ وَلَيْسَ لَهُ مِنَ الزَّرْعِ شَيْءٌ