Protecting Afghanistan from Pakistanis and other 'good' neighbors

The only way to protect Afghanistan is to make them stand on their own two feet somehow...
And then, force them to cease all hostility towards Pak, which means keeping Pakistans security needs in mind even in dealings with India.
The Pak Kashmir issue should also be resolved to defuse tension between India an Pak.
The Porous border will always be there, cant do anything about that.