The National Security Agency is failing to live up to government standards for cybersecurity, leaving the spy agency potentially vulnerable to digital attacks, according to an internal watchdog.

The NSA Inspector General on Monday revealed the organization, which collects and analyzes some of the government’s of the most sensitive intelligence, doesn’t always follow its own rules for keeping that information secure. Auditors also found the agency held onto some of that data for longer than the law permits and failed to implement protections against insider threats.

The report, which summarizes dozens of IG audits and investigations conducted between October 2018 and March 2019, offers a rare glimpse inside an agency whose inner workings are usually sealed off from the public.

Under the Federal Information Security Management Act, agency inspectors general annually grade organizations on how closely they follow best practices for eight categories of IT security. Scores can range from Level 1 to Level 5, with higher marks indicating better security.

Last year, auditors found the NSA had “room for improvement in all eight IT security areas.” Though auditors didn’t outline any specific security gaps, the report showed many of the agency’s cybersecurity procedures are inconsistent at best.

Auditors gave the NSA a Level 2 rating in five categories—risk management, configuration management, data protection and privacy, continuous monitoring and incident response—meaning officials had clearly defined policies but failed to consistently implement them. The agency received a Level 3 rating in two categories—identity and access management, and security training—which means policies are consistently implemented but officials aren’t measuring how effective they are.

The IG gave the agency’s contingency management practices a Level 1 rating, meaning there’s no official plan for the NSA to follow if it falls victim to a cyberattack.

The audit revealed that despite its data-driven mission, NSA struggles with many of the same cybersecurity challenges that plague less clandestine federal agencies.

In a separate study summarized in the report, the IG found NSA “retained a small percentage” of the signals intelligence it collected from around the globe for longer than the law and its own policies permit. The violation resulted from the agency not implementing a technical system for calculating when certain data must be deleted, the IG said.

NSA also has yet to implement multiple IG recommendations to defend against insider threats, such as putting in place two-person access controls for agency data centers and scanning removable devices for viruses, auditors said. In recent years, the agency has suffered major security breaches at the hands of contractors Edward Snowden, Harold Martin and Reality Winner, as well as a yet-unidentified group dubbed the Shadow Brokers that have tried to sell off some of the agency’s cyber tools.

During the six-month period covered in the report, investigators uncovered three instances in which NSA officials illegally retaliated against internal whistleblowers. The report included no information on the results of those cases.

The report also highlighted a number of IG audits and investigations that are currently underway, including an assessment of the NSA chief information officer’s authorities and a study of the agency’s process for certifying its signals intelligence systems. The report included little information on any of the ongoing inquiries.