German example: The BND has been caught spying on all Germans' communication (most probably still does so), as well as connections to foreign countries. They are only supposed to watch foreign countries. So they came up with a legal theory, called "Weltraumtheorie", where satellites are in space, so outside the jurisdiction of any state. https://de.wikipedia.org/wiki/Weltraumtheorie Later on, when this got out, it was just legalized and extended to fibre connections, because, well, that just replaces space, doesn't it?...
Also, later on, the government just legalized what the BND was doing, thereby invalidating any future attempt at prosecution for that past crime against the BND. Yet still maintaining the illegality for everyone else.
>"I think we've started to fill a void, a niche for the Americans to get around a few legal hurdles domestically"
https://www.abc.net.au/news/2021-06-10/nsw-operation-ironsid...