Possibly relevant excerpts:
The 1878 Posse Comitatus Act expressly forbids the use of military forces to “execute the laws,” except when expressly authorized by the Constitution or a statute. It has long been thought to limit most military involvement in civilian law enforcement. The Church Committee concluded in 1976 that the Act “would probably prevent the military from conducting criminal investigations of civilians, but... would not bear upon other types of investigations. ‘ Since that time, however, Congress has enacted an exception to the Act that allows the Secretary of Defense to provide law enforcement officials with “any information collected during the normal course of military training or operations that may be relevant to a violation of any Federal or State law,” and to take the needs of such officials into account “to the maximum extent practicable” in the planning and execution of military training or operations. The secretary may also furnish equipment to law enforcement agencies along with personnel to operate it for cases involving foreign or domestic counterterrorism or violation of any law, foreign or domestic, prohibiting terrorist activities.
“Other statutory exceptions to the [Posse Comitatus] Act are potentially much broader. The Stafford Act, for example, gives the President authority to use the armed services in an emergency to perform work “essential for the preservation of life and property.” The Insurrection statutes at 10 U.S.C. §§ 331-335 give the President wide latitude to use troops for almost any purpose, including law enforcement, in responding to an actual or threatened terrorist attack. Another statute allows military forces to assist the Justice Department in collecting intelligence or in searches and seizures when it is “necessary for the immediate protection of human life. These statutory exceptions, designed to furnish maximum flexibility to the executive branch in an emergency, are most striking for their failure to include any meaningful limits-temporal, geographical, or situational-or any means for challenging their invocation. Taken together, they appear to remove any significant Posse Comitatus Act constraints on domestic military intelligence activities.
key there: “ to operate it for cases involving foreign or domestic counterterrorism or violation of any law, foreign or domestic, prohibiting terrorist activities.”