Honestly why would you even ask this question and honestly I don't like how everyone is trying to become a black hat there are much better things you can do with your free time.
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.
I noticed that no one is actually posting a citation to a law or statute; yes I am suggesting that every answer given so far is based on a personal belief about what is right and wrong.
Really why do answer question that you have no knowledge about?
Hacking is way to vague a word. This question can't be answered.
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?