A 2008 cyber attack launched from an infected flash drive in the Middle East penetrated secret US military computers, a Pentagon official says.
The attack by a foreign spy service was the "most significant breach" ever of US military networks, Deputy Defence Secretary William Lynn said.
Writing in Foreign Affairs magazine, Mr Lynn described it as a "digital beachhead" to steal military secrets.
He urged the US to speed up its cyber defence system procurement procedure.
Mr Lynn, the number two official in the Pentagon, wrote that the previously undisclosed 2008 attack began when an infected flash drive was inserted into a US military laptop at a base.
The computer code then spread stealthily through US military computer networks and readied itself to transfer military data to enemy hands, he wrote.
It is unclear whether the cyber spy effort succeeded in obtaining US secrets, and further details on the attack were unavailable.
In the article, Mr Lynn warned that US military dominance was threatened by the relatively low cost of cyber warfare.
"A dozen determined computer programmers can, if they find a vulnerability to exploit, threaten the United States' global logistics network, steal its operational plans, blind its intelligence capabilities, or hinder its ability to deliver weapons on target," he wrote.
Mr Lynn, a former defence lobbyist and military budget official under former President Bill Clinton, warned the Pentagon had to speed up the process by which it develops and acquires cyber defence kit.
He noted that on average it took the Pentagon 81 months to get a new computer system online after its initial funding, while Apple developed the iPhone in 24 months, "less time than it would take the Pentagon to prepare a budget and receive congressional approval for it".
The US military operates 15,000 networks and seven million computers across the world that are probed by attackers thousands of times a day, Mr Lynn said.
The Pentagon has consolidated its cyber defence operations into a single command structure, which began operations in May.
The Pentagon did not immediately respond to a request for comment.