I've been fired on by friendly AI surface forces before, in a MP dive no less.
I fired an ADCAP at a certain person on this forum about 14nm away (which killed him after I died...

) when I was about 500 yards away from a Spruance and it immediately put a MK50 in the water and I died before i could figure out exactly what had happened.
If friendly surface ships are in a hostile posture and are prosecuting submarines and you happen to be near them and fire torpedoes, about 50% of the time they will snapshot torpedoes down the bearing of your TIW.
So you have to be very careful about firing torpedoes around friendly surface forces when they have detected hostile submerged contacts in their vicinity.