Out of curiosity, can bandits attack you while traveling?
Yes.
At sea?
Not sure. But probably.
Bandit attacks are driven by the amount of gold you are carrying. And possibly the number of soldiers you have. Although if you have enough gold, they will attack you and kill your guards. Or try to.