Having a wank by yourself is about as risk free as sex can get. Wanking with someone else isn't much riskier. There are no records of anyone catching HIV from wanking so you can tug away without fear.

STIs can be transmitted if you rub someone else's cum on the head of your cock, although wanking is still one of the least risky things you can do. The main risk from wanking is if you or your partner gets a little over-eager and pulls too hard (or too often), which can damage your urethra and lead to NSU.