Would it be possible to edit the bitcoin-qt code so that when communicating with other peers it also grabs their private keys whilst grabbing their version of the blockchain?
This could be a possible security flaw am I right?
No it's impossible at all because if this critical issue would have been real, the developers would have fixed it in no time.