Analytical solution has been found for the second-order effective anisotropy of magnetic nanoparticles of a cubic shape due to the surface anisotropy (SA) of the N\'eel type. Similarly to the spherical particles, for the simple cubic lattice the grand-diagonal directions $\left(\pm1,\pm1,\pm1\right)$ are favored by the effective cubic anisotropy but the effect is twice as strong. Uniaxial core anisotropy and applied magnetic field cause screening of perturbations from the surface at the distance of the domain-wall width and reduce the effect of SA near the energy minima. However, screening disappears near the uniaxial energy barrier, and the uniform barrier state of larger particles may become unstable. For these effects the analytical solution is obtained as well, and the limits of the additive formula with the uniaxial and effective cubic anisotropies for the particle are established. Thermally-activated magnetization-switching rates have been computed by the pulse-noise technique for the stochastic Landau-Lifshitz equation for a system of spins.