Most suttas in the canon are given by the Buddha, but many are given by his disciples, including this one, given by Sariputta. In the Mahayana tradition, Sariputta was re-imagined as a dunderhead who could never get it right. This is probably because he was the Buddha’s chief disciple. Criticizing Sariputta was code for criticizing the Theravada. But the Buddha declared he was fully enlightened and that he was “foremost in wisdom” of all his disciples.
Once Sariputta was living near Nālakagāma in Magadha. Jambukhādaka the homeless spiritual wanderer came for a chat. After a friendly greeting, he asked Sariputta, “Who would you say is teaching Dhamma, practicing in the right way, and doing well in the world?”
Sariputta replied, “If someone is teaching the way to end desire, they are teaching Dhamma. If they teach the way to end aversion or confusion, they are teaching Dhamma. Likewise, if someone is practicing to end desire, aversion, and confusion, they are practicing well. And anyone who has completely abandoned desire, aversion, and delusion — destroyed the foundation, uprooted them like a palm stump — they are practicing well.”
Jambukhādaka asked, “Then what is the path to end desire, aversion, and confusion?”
“The Eightfold Path is the way: right understanding, right motivation, right speech, right behavior, right profession, right mindset, right mindfulness, and right concentration.”
Jambukhādaka said, “Sounds great!”
-Dhammavādīpañhā Sutta SN 38.3 (S iv 252)