Joining the armed forces voluntarily means you voluntarily entered UCMJ jursidiction. Espionage is illegal under UCMJ. That's the actual, formal law. It's not a failure of due process.
In his defense of Snowden's decision to flee the country, Daniel Ellsberg elaborates more on what's different between now and when he made the decision not to flee in 1971.