A FORMER Russian military intelligence officer once told me this story.

He described how one day in the 1980s – at the height of the Soviet war in Afghanistan – a Russian army patrol entered an Afghan village. Short of rations, one junior officer knocked on the door of a mud hut in search of bread.

An old woman came to the door and, although desperately short of food herself, gave what she could. Touched by the woman's generosity, the officer returned the next day to give her some tea as a thank-you.

Again, the same old woman came to the door but this time, after opening it, she instantly plunged a pitchfork into the officer's stomach.

Later, the soldier she wounded asked her why she had done such a thing. Her answer was simple. As a good Muslim and Pashtun devoted to the tribal code – Pashtunwali – she had been obliged to offer what hospitality she could.

But why had she then tried to kill him, the officer inquired, still puzzled. She explained that having fulfilled her obligation of hospitality, it was then incumbent on her to fulfil that other tenet of Afghan tribal law that required her to confront and combat the infidel.

That story has always struck me as encapsulating the very essence of the problem faced by any foreign army that has ever tried to impose its will on the Afghan people.

It has a particular resonance too in light of the recent sharp rise in so-called green-on-blue killings, where Nato-trained Afghan army soldiers – in their green fatigues, hence the name – turn their rifles on Nato "allies" at close range with fatal results.

On Wednesday three Australian soldiers became the latest victims of a green-on-blue attack after being gunned down by an Afghan soldier in the country's Uruzgan province.

Their deaths mean some 45 coalition troops have died in more than 30 green-on-blue attacks this year alone. Already the count has passed last year's total of 35 dead and reached fully double the figure for the whole of 2010.

Just what then are the underlying reasons for this dramatic rise, and why do an ever increasing number of Afghan soldiers appear prepared to do the Taliban's bidding? Three factors are at play here: disgruntlement, tactics and timing.

Wonderfully hospitable as Afghans are, they have always had an underlying disdain for foreigners who try to tell them what to do. The simple fact is the longer the coalition presence in Afghanistan goes on, the greater the resentment felt towards it.

Visiting the country over the last decade, I've witnessed attitudes change towards Nato's presence and a growing friction born out of cultural differences. Afghans do not easily forgive and forget. The burning of Korans, rampaging massacres against civilians and urinating on dead bodies carried out by – albeit rogue – Nato soldiers have been seared into the minds of many Afghans and irreparably damaged previously good relations.

Where there was once fraternisation and camaraderie among Afghan and coalition soldiers, there is now often suspicion and disgruntlement. Talking to American soldiers during my last visit, many spoke of the need to have constant "eyes on" when it came to their Afghan allies on the frontline. Afghan soldiers in turn said they felt increasingly shunned.

With their undeniably clever sense of timing, the Taliban have been quick to exploit this, shifting their tactics to orchestrate a process of infiltration, enabling them to hit the coalition from within, further eroding trust and co-operation.

"We are working like termites, eating into this already rotten wooden structure," was how one senior Taliban commander aptly described it.

Not surprisingly, some among the Afghan and coalition leadership are keen to play down the problem within their own ranks. Afghan President Hamid Karzai has openly attacked the Pakistani intelligence service, the ISI, for indoctrinating young men in Pakistan before infiltrating them into the Afghan army to attack Nato from within.

While there may well be some substance to this, the most likely causes undoubtedly lie closer to home. That more Afghan soldiers are turning to the Taliban cause might also stem from the fact they see the writing on the wall and sense it might be time to join the Islamist ranks ahead of Nato's troop withdrawal.

All this, of course, is cause for great concern given Nato's departure from Afghanistan in 2014 rests upon having credible Afghan armed forces to take over the relentless job of trying to bring some kind of stability to the country.

"When they stand up, we stand down," the Americans are fond of saying. But given the current levels of mistrust and the corrosive effects of Taliban infiltration, serious questions remain as to how it will be possible to vet the tens of thousands of recruits who are needed if the Afghan military and police are to reach their target strength of 350,000 by next year.

For now, the death toll from green-on-blue attacks keeps rising. Few doubt it's an ominous portent of things to come.