Necessary and sufficient conditions for cubic (quartic) permutation polynomials to be self-invertible over the ring Zpn where p >7 (p >17) is a prime number are given, and completely determined. The characterization of these permutations are given by relations on the coefficients of the polynomial which resulted in a Gröbner basis with respect to some lexicographic order of certain ideals.