UCMJ, Section 16c(1)(c):
Lawfulness. A general order or regulation is lawful unless it is contrary to the Constitution, the laws of the United States, or lawful superior orders or for some other reason is beyond the authority of the official issuing it.
UCMJ, Section 14c(2)(a)(i):
Inference of lawfulness. A order requiring the performance of a military duty or act may be inferred to be lawful and it is disobeyed at the peril of the subordinate. This inference does not apply to a patently illegal order, such as one that directs the commission of a crime.