Admittedly there are edge cases and military planners like nothing more than dreaming these up and devising countermeasures. The Suez and Panama Canals are not small, so it's not as if all the ships have to crowd together and be trapped in a small area. But yes, there are threats and their probability of success is never 100%.
Here's an interesting lesson from WW2 which shows the danger of previously unknown coastal torpedo batteries: https://en.wikipedia.org/wiki/Battle_of_Drøbak_Sound