The Alwars (also spelled Azhwars) are a group of 12 ancient Vaishnava saints who lived in Tamil Nadu and are famous for their poetry in praise of Vishnu. The Alwars are crucially important figures in the development of Vaishnavism; it is the principles and beliefs embodied in the Alwars' poems that ultimately gave rise to the Sri Vaishnava sect (of which I'm a member). Now as I discuss in this question, the course of their poems the Alwars have praised 108 sacred places of Vishnu, known as the Divya Desams. One of the Divya Desams is Thirukkolur, which is the birthplace of Madhurakavi Alwar (whom I discuss here) and the site of the Vaithamanidhi Perumal Vishnu Temple. The story of the temple seems to bear some similarity to the story of Govindaraja, which I discuss here, so I may ask about that in future.
But my question is about Thirukkolur's main claim to fame. The famous Sri Vaishnava Acharya Ramanujacharya was once walking into the town of Thirukkolur, when he saw a little girl walking in the opposite direction. He asked her where she was coming from, and she said Thirukkolur. So he told her everyone goes to Thirukkolur to Sriman Narayana, so what possible reason could she have for leaving. She responded with a set of 81 statements, now known as the Thirukkolur Penpillai Rahasyam or "The secret told by the little girl from Thirukkolur". She listed 81 great devotees of Vishnu, her point being "since I am not like these 81 great devotees, why does it matter if I am in Thirukkolur or not"?
Now the sixth statement the little girl made was "piNa virundhittEnO kaNdAkarNanaip pOlE" meaning "Am I like Kandakarna?" The story as I understand it goes roughly as follows. There was once a cannibalistic demon named Kandakarna who asked Shiva for Moksha for him and his brother. Shiva informed Kandakarna that Shiva once received a boon from Vishnu that Vishnu would come as Krishna to Mount Kailash and pray to Shiva. So Shiva suggested that Kandakarna could use that opportunity to attain Moksha. So when Krishna came to Kailash, Kandakarna killed a sage and offered the sage's dead body to Krishna! Krishna, in his boundless compassion, granted Moksha to Kandakarna, his brother, and the sage he killed. Here's how this web page describes it:
Kandakarnan was a spirit that ate dead bodies. He was an ardent devotee of Shiva and as such hung a bell in his ear to prevent him from hearing Narayana's name being said. Hence he was called kaNdAkarNan. One time he went to Kailasha and prayed to Shiva to help him leave the spirit state and attain moksha. Shiva told him that he could not give him liberation and that only Narayana could do that. However, he gave the spirit a suggestion.
Shiva said "Lord Narayana has appeared on earth as Sri Krishna now. I asked Him one time to give me an opportunity to give Him a boon. He agreed and told me that He would come to Kailasha as Krishna and get a boon from me. When He comes here for that, if you pray to Him, He will give you what you seek". He also gave a description of Krishna's form to Kandakarnan so he would recognize Krishna when he saw Him. Kandakarna then thanked Shiva, removed the bell from his ear and keeping Krishna's image and name in his mind started waiting for His arrival.
One day, he saw Krishna from a distance and recognized Him right away. Immediately he killed a rishi who was nearby with a spear and brought the body to Krishna. Stopping Krishna he said "I have heard from Shiva that You are the one capable of giving moksha. I just now killed this rishi and brought his body just for You. Please accpet my offering" and prayed to Him sincerely. He did that because the shastras say that whatever a person eats according to his state, he should offer that to the divinity that he prays to, before eating it.
Since he had offered something to Krishna and only to Him, with great sincerity, Krishna accepted the offering and granted him moksha. He also granted to moksha to Kandakarna's brother, based on his prayer. It is understood that the rishi who was killed by Kandakarna and offered to Krishna also attained moksha. Thirukkolur Ammal is asking "Am I capable of praying to the Lord as sincerely as Kandakarna did?"
My question is, what scriptures describe the story of Kandakarna? He isn't mentioned during the account of Krishna's visit to Kailash in the Anushasana Parva of the Mahabharata. So is it possible that his story mentioned in the Puranas?
Also, what race did Kandakarna belong to? Was he a Pisacha, or a Bhuta, or what?