Editor's note: Peter Bergen is CNN's national security analyst, a director at the New America Foundation and the author of "Manhunt: The Ten-Year Search for bin Laden -- From 9/11 to Abbottabad." David Sterman is a research assistant at the New America Foundation.
(CNN) -- On Tuesday, an Afghan soldier killed a U.S. major general and wounded a German brigadier general, as well as up to 15 others, in an attack at the Marshal Fahim National Defense University in the Afghan capital, Kabul.
The attack is an ominous sign regarding the potential risks to American service members as the majority of U.S. forces withdraw from Afghanistan.
If a Bilateral Security Agreement between the United States and Afghanistan is signed in coming months, the United States is likely to keep a residual force of around 9,800 troops in Afghanistan after the withdrawal of all U.S. combat troops at the end of 2014.
This residual force would serve in an advisory role to Afghan troops, which could further expose American forces to insider attacks.
Officials identified the American who was killed as Maj. Gen. Harold Greene. Rear Adm. John Kirby, the Pentagon spokesman, said the Afghan soldier who carried out the attack was shot and killed.
Although directed at high-ranking officers, it was far from the first insider attack on coalition troops in Afghanistan.
According to a count by the New America Foundation, there have been 82 such attacks on coalition personnel over the course of the Afghan War. The numbers refer to Afghan police and army members attacking NATO troops.
During the early years of the war, there were very few insider attacks. But they took off in 2011. That year, the number rose to 14, followed by a peak of 40 in 2012.
At least 145 U.S. and other NATO soldiers have been killed by Afghan soldiers, according to New America's data.
So far, in 2014 there have been only three such attacks, including Tuesday's in Kabul, and an attack on June 23 in Gardez, Paktia, where two American military advisers were injured in a shooting by an Afghan police officer.
Before that, on February 12, two American Special Forces members were killed in Afghanistan's Kapisa province by gunmen wearing Afghan National Security Force uniforms.
In April 2011, in an attack that killed the most coalition personnel, an Afghan military pilot killed eight American soldiers and a military contractor during a meeting in the operations room of the Afghan Air Corps at Kabul Airport.
Insider attacks have taken their largest toll on troops from the United States, which contributes the largest contingent of forces to operations in Afghanistan
Military members from Albania, Australia, France, Germany, Italy, New Zealand, Norway, Slovenia, Spain and the United Kingdom have also been targets.
Still, the number of deaths in insider attacks on foreign forces has been declining -- although they spiked in 2012, when 59 coalition members were killed. In 2011, there were 36; in 2013, there were 18.
The United States took several steps after insider attacks became a large-scale problem, including improving vetting of Afghan security personnel and putting more counterintelligence assets into the field to try to detect threats.
Kirby downplayed the significance of Tuesday's attacks, asserting that he has "seen no indication that there's a degradation of trust between coalition members and their Afghan counterparts."
Maintaining that trust as U.S. combat troops withdraw will be key.