What do the rules say?
From the BBC:
The rules
A number of F1 regulations apply to this sort of incident. One says: “Should a car leave the track the driver may re-join, this may only be done when it is safe to do so and without gaining any lasting advantage.”
The question here being, did Vettel gain a lasting advantage by doing what he did?
Another says: “Manoeuvres liable to hinder other drivers, such as deliberate crowding of a car beyond the edge of the track or any other abnormal change of direction, are strictly prohibited.”
And another: “It is not permitted to drive any car unnecessarily slowly, erratically or in a manner deemed potentially dangerous to other drivers at any time.”
Response from Hamilton too. Says it was a penalty but he would’ve probably done the same thing: “What I can say is, if I was in the lead and made a mistake and went wide, I would probably have done the same thing, because it happened so quick and you are just trying to hold your position.”
https://www.bbc.co.uk/sport/formula1/48577539