You can cheat to get cheats on after creating a world with cheats off. If you start a LAN and enable cheats, you can do all commands. This is like: "Oh no I fell in lava! But, that's not a problem, I just need to start a LAN and enable cheats, then I can fly out from the lava and everything is as normal.". And that's not supposed to happen, I think.
The cheats can be disabled if you rejoin the world.
You could do this since LAN was added.
Related issues
duplicates
Comments


Working as intended, you shouldn't use that option then.

If cheats is disabled when creating a world, you shouldn't be able to change gamemode or enable cheats in LAN settings.

Maybe the option "Allow cheats for other players" was meant to be enabled when the world before opening to LAN already has cheats enabled ?
Confirmed, but possibly intended, as you also have an option to change the gamemode to creative. If 'Open to LAN' has that option, it is very likely that enabling cheats is intended behavior.