Sand erosion as an internal boundary value problem