From 24V to 5V DC voltage regulator

Reading the Uno's regulator datasheet, page 10:

It would seem to me that a 1N4001 diode from 5V to Vin would prevent any damage should Vin be unpowered and 5V driven directly from an external source:

"Protection Diodes
The NCP1117 family has two internal low impedance
diode paths that normally do not require protection when
used in the typical regulator applications. The first path
connects between Vout and Vin, and it can withstand a peak
surge current of about 15 A. Normal cycling of Vin cannot
generate a current surge of this magnitude. Only when Vin
is shorted or crowbarred to ground and Cout is greater than
50 F, it becomes possible for device damage to occur.
Under these conditions, diode D1 is required to protect the
device. The second path connects between Cadj and Vout, and
it can withstand a peak surge current of about 150 mA.
Protection diode D2 is required if the output is shorted or
crowbarred to ground and Cadj is greater than 1.0 F.

A combination of protection diodes D1 and D2 may be
required in the event that Vin is shorted to ground and Cadj
is greater than 50 F. The peak current capability stated for
the internal diodes are for a time of 100 s with a junction
temperature of 25°C. These values may vary and are to be
used as a general guide."