Hacking into the CIA? Legal? Hell no! You being able to hack into them? Unlikely...and the CIA takes all hacks serious as they consider them to be a risk to national security if you do so (last documentary I saw on the CIA).
No, it is completely legal to steal Classified Information right? Of course not what do you think.
Trust me, if you manages to find a RCE or LFI or SQL vulnerability on CIA server you would be some Super-Advanced hacker with sophisticated programming techniques. NO ONE! I REPEAT NO ONE HERE are even 0.01% to that level.
BTW any one see the RCE vulnerability some hacker found on EBay.
Government is no different than anyone else. I would bet breaking into the CIA's stuff would be much easier than breaking into anything Amazon. All it takes is one out dated piece of public facing software. PHPMyAdmin anyone?