It's the same situation for motor in front or back, and the answer is water does not get into most hub motors easily. The main entry way is thru the power cable, and most of them are (a) covered with a gasket, and (b) pointed downward. They've found that water can drip down the wire and go inside if the wire loops up instead of down. The cable is highlighted in purple here and see how it goes down,
Now water could get into the handlebar controls (display and throttle) . It could get into the electronics. It could penetrate into harnesses and get inside motors mounted on the frame. All of that has happened to owners, but it will depend on who made your ebike.