Speaking at a private dinner for tech security executives at the St. Regis Hotel in San Francisco in late February, America's cyberdefense chief boasted how well his organizations protect the country from spies.

U.S. teams were "understanding the adversary better than the adversary understands themselves,” said Gen. Paul Nakasone, boss of the National Security Agency and U.S. Cyber Command, according to a Reuters reporter present at the Feb. 26 dinner. His speech has not been previously reported.

Yet even as he spoke, hackers were embedding malicious code into the network of a Texas software company called SolarWinds Corp., according to a timeline published by Microsoft and more than a dozen government and corporate cybersecurity researchers.