I used to think that NASA is exempt by the government from patent royalties when manufacturing equipment for NASA's missions and purposes. But after a little Googling it turns out I am wrong:
http://www.cojk.com/nasa-ordered-to-pay-boeing-28-3m-in-pate...What is more important is that national security can precede legality at times and trying to stop the NSA from using a particular software becomes moot once you consider that an adversary can do the same actions to undermine software. This means the NSA will have justification to ignore any clause of no use an hunt for exploits and may probably comply with a legal clause of no use as a regular user.
On the other hand you shouldn't look at the NSA as the bad guy. Remember that a security/spying agency is controlled by policy. If policies are bad the actor acts badly. Put your energy in fixing policy instead of beating down the NSA. I'm starting to feel sorry for an agency that acts on orders from the government at large.