A cloaked ship could fly into the sector and launch mines there. Or, a minelayer could attack your undefended planet, but not fire because it has no weapons, and launch mines. This is more of an issue with multiplayer games, as the AI is not as clever as human opponents.
