"It's difficult to know an attacker from a non-attacker when everybody is wearing a uniform, Hayar said.
The attacker was one of seven people rounded up earlier this month from various units within the Afghan National Army Corps 203, Hayar said. The corps covers the eastern Afghan provinces of Paktia, Paktika, Ghazni, Wardak, Logar and Khost.
"He was together with me in my room with some of my other colleagues. He had a long beard. We didn't know anything about him. We were living together, sleeping together," said Hayar, who has been in the Afghan army for 2 1/2 years.
He said the suspected infiltrator was identified after a Taliban militant arrested in Logar told his Afghan interrogators that members of the fundamentalist Islamic movement had infiltrated the corps and were planning imminent attacks. That prompted Hayar's superiors to start questioning soldiers in various units.
Hayar said his roommate's uneasy reaction raised suspicion, and investigators found Taliban songs saved to the memory card of his cell phone. He was then detained by Afghan intelligence officials and confessed he was a member of the Taliban and planned to stage attacks.
Hayar says he assumes his former bunkmate was probably going after foreign forces, but it makes him uncomfortable nevertheless.
"It's very hard to trust anybody — even a roommate," he said. "Whenever I'm not on duty, I lock my weapon and keep the key myself. I don't put my weapon under my pillow to sleep because maybe someone will grab it and shoot me with my own weapon."
To counter such attacks, the U.S. military earlier this year stopped training about 1,000 members of the Afghan Local Police, a controversial network of village-defense units. U.S. commanders have assigned some troops to be "guardian angels" who watch over their comrades even as they sleep. U.S. officials also recently ordered American troops to carry loaded weapons at all time, even when they are on their bases.
Then, after a string of insider attacks, Allen this month restricted operations carried out alongside with small-sized Afghan units. Coalition troops have routinely conducted patrols or manned outposts with small groups of Afghan counterparts, but Allen's directive said such operations would no longer be considered routine and required the approval of the regional commander.
For their part, Afghan authorities have detained or removed hundreds of soldiers as part of its effort to re-screen its security forces. The Ministry of Defense also released a 28-page training booklet this month that advises soldiers not to be personally offended when foreign troops do things Afghans view as deeply insulting.
The booklet urges them not to take revenge for foreign troops' social blunders, such as blowing their noses in public, stepping into a mosque with their shoes on, walking in front of a soldier who is praying or asking about their wives.
"Most of the coalition members are interested to share pictures of their families. It is not a big deal for them. If someone asks you about your family, especially the females in your family, don't think they are disrespecting you or trying to insult you," the booklet says.
"That is not the case. By asking such questions, they are trying to show that they want to learn more about you. You can very easily explain to them that nobody in Afghanistan would ask, especially about wives or females in the family."
Associated Press writers Amir Shah and Rahim Faiez in Kabul contributed to this report.