If you need a ID........better photo would help as well as type of bark it was found on and location? Are you in the USA or in Asia or another part of the world. There are a million kinds of larvae/worms/caterpillars.
It might be a red palm weevil (Rhynchophorus ferrugineus). Looks like there can be there different kinds of moth larvae that live in palms or on the leaf of palm trees. But the one I mention has a brown radish color so might be the one you found.