The U.S. made a formal declaration (the 2001 AUMF).
But I don't even have qualms comparing international waters to Afghanistan, because you have to consider that if a given piece of land is completely ungoverned, does it belong to a specific nation at all?
If you say that the lands in Afghanistan from which AQ organized their terrorism was effectively governed by the Taliban and not a failed state, then it's even easier legally, as you have an actual causus belli for military action in response.
I'm just trying to make a point about warlike actions without formal declarations, in any case.