The issue of when persons on U.S. territory could be tried by military courts was tested in the Supreme Court in Ex Parte Quirin, 317 U.S. 1 (1942),[10] which upheld military prosecution of seven Germans who had entered U.S. territory covertly, six of whom were executed. At the time there was a congressionally declared state of war with Germany, defining them as "enemies". However, the Supreme Court took the case on a writ of habeas corpus, which established that such persons do at least have that due process right if the offense occurred on U.S. territory. Otherwise there would be no protection against such a military tribunal prosecuting U.S. citizens or "friendly" aliens.
The issue of extended detention of persons of foreign descent was decided in Korematsu v. U.S., 323 U.S. 214 (1944), which affirmed the conviction of a Japanese-American citizen who resisted detention, although he was later found not guilty at the district court level. This case is now generally considered an embarrassment for U.S. case law, although it has not been overturned.Criminal prosecution in civilian courts of persons who committed offenses against the U.S. from outside U.S. territorial limits would be unconstitutional, despite several cases that claim extra-territorial criminal jurisdiction. They would also be extremely difficult to prove.
U.S. v. Burr, 8 U.S. (4 Cranch) 469 (1807)[11] established that the location of a criminal offense is where the offender was at the time of the offense, not where the effects of the offense occur. The Constitution limits criminal jurisdiction to a court in the state and district where the offense was committed.
U.S. v. Hudson, 7 Cranch 32 (1812)[12] established that persons may only be criminally prosecuted under statutes in effect on the territory where the offense was committed, which excludes offenses committed outside U.S. territorial limits.
When the offenders are not acting for a foreign state, a declaration of war is not applicable. That leaves only military action under letters of marque and reprisal as a constitutional remedy.[13]The full constitutional due process protections apply on U.S. territory to citizens and legal residents or visitors, provided they did not gain legal entry by fraud. That does not mean such foreigners don't have full rights of life, liberty, and property, but due process may be truncated, provided authority for doing so is conferred by Congress, by either a declaration of war or letters of marque and reprisal. That authority is needed for such actions as trial of prisoners by a military tribunal, or putting bounties on the heads of suspects. In the absence of such authority, only defensive actions may be taken, without violating the law, represented by 18 USC 2441, which applies to everyone involved, including the president.
http://www.constitution.org/col/foreign_rights.htm