That's a case where they see it as worth it, and the entire purpose of the project was to contribute back. Part of the NSA's mission isn't just to hack everybody else, but to help defend, as well. At least some part of the agency actually does seem a bit dedicated to that task, despite my natural cynicism causing me to be a bit surprised each time I see it.