Well, the derivation of the virial theorem is perfectly right if you ask me. $r$ in this context is the distance from the origin and $\vec{r}$ the displacement vector. Since the particles can change their distance towards the origin, there is no problem in differentiating them in time and thus also the moment of inertia. (Rememeber, this is not a rigid body, but an ensemble of particles with a possible but not necessary set of constraints.)
It is quite customary not to talk in length about the convention in physics, and sometimes mathematical presuppositions are not stated or even properly explored, but I would not call this cheating really.