mojira.dev
MC-59653

Signs with clickEvents only check permission in spawn-protection

The bug

Signs that contain a clickEvent are only checked for operator permissions if clicked inside of spawn-protection area set by server.properties.

Note: Signs being able to execute commands regardless of executor permissions is likely widely used in adventure maps. It does not directly impose a security vulnerability because placing such signs with clickEvent requires operator permissions. It is similar to placing a command block containing a command: Placing the command block requires operator permissions, but anyone can afterwards place redstone next to it to activate it.

How to reproduce

  1. Start a Minecraft server.

  2. Set the spawn-protection field in the server.properties file to 10.

  3. Run:

    /give @p oak_sign[custom_name='{"text":"MC-59653"}',block_entity_data={id:"minecraft:oak_sign",front_text:{messages:['{"text":"Click me","clickEvent":{"action":"run_command","value":"fill ~ ~1 ~ ~ ~2 ~ redstone_block"}}','{"text":""}','{"text":""}','{"text":""}']}}] 2
  4. Place one sign inside the spawn-protection area and one sign outside the spawn-protection area.

  5. Deop yourself, but make sure theres atleast one other player opped, so spawn protection is active.

  6. Click the sign inside the spawn protection area.
    → ✔ Sign unsuccessfully used, no blocks were placed

  7. Click the sign outside the spawn protection area.
    → ❌ Sign succesfully used, two redstone blocks are placed above the sign

Linked issues

Comments 17

WOW i didn't new this works!

Works as Intended, or Invalid, from what I can tell.

Spawn Protection blocks click events of many kinds. It prevents non-OPs from opening/closing doors, for example. It also prevents players from using commands such as /say and /trigger through spawn-protected signs. There is no command-level permission checking involved; it only checks whether the player has permission to interact with blocks at all in the area.

Outside of spawn-protected zones, sign commands are not restricted. This is because players cannot create signs with commands on them. It is pretty much the same as activating a command block with a button: inside spawn protection, non-OPs can't trigger it at all. Outside spawn protection, non-OPs can freely trigger it, but cannot edit the commands they run.

You should avoid leaving command signs lying around for the same reason you should avoid leaving command blocks lying around.

It's not that this causes issues. In fact, it's preferable. The problem is the inconsistency.

By all means, this is a convenience, but the same logic also applies to tellraw commands, and book commands, etc, none of which have the same effect. Yet, signs work just fine.

Believe me, nobody here thinks this bug is a bad thing. But it is a bug. If it wasn't, it'd be more consistent.

I don't see how it's inconsistent. Spawn protection prevents non-OPs from interacting with blocks, but has no effect on interactions with chat or books. It prevents you from right-clicking a sign for the same reason it prevents you from right-clicking a button attached to a command block.

The reason /tellraw commands and books require OP for executing arbitrary commands is security. A mod can spoof a /tellraw message or book interaction packet with arbitrary commands attached. The server has to validate it, but doesn't actually have access to the chat on a client's screen or the specific pixels of a book the player clicked on. This is simply because of how these two run_command vectors work, and as a result, the server's only option is to require the player to be OP.

The reason signs don't require players to be OP is because the client only sends a clickEvent packet to the server, telling it the coordinates of the block which was right-clicked. The server already validates these packets by making sure the player is within range of the clicked block and (as far as I am aware) has a clear line of sight to it. At this point, the server just has to check what commands are on the sign, and can freely run them whether or not the user is OP. I don't see how it could've been implemented this way on accident.

To sum it up, the reason the OP restriction applies to tellraw and books is because in both cases, the client sends the server a command to be run. The reason it does not apply to signs is because the client only sends the sign's coordinates, and the commands themselves are purely server-side. It's not obvious why it works this way, but it's not a bug, and also has nothing to do with spawn protection.

Tested in 14w29b and is still present.

Like @unknown said, the reason tellraw and books require OP for executing commands is security. Those two examples use the same JSON formatting that signs are capable of using, yet only signs are not checked if the player can issue said command(s).

As far as I know, all events are passed to the server for processing and the server determines if the player can issue said commands(as proven by trying to issue commands via books outside spawn protection). It makes no sense to only check commands that are inside signs when the activating player is also inside spawn protection.

Yes, like @unknown said, it's more of a convenience issue and players creating these signs shouldn't leave them out and about but it happens and, sometimes, it's easier to do just that.

7 more comments

Is this still an issue in the latest snapshot 16w44a? If so please update the affected versions.

This is an automated comment on any open or reopened issue with out-of-date affected versions.

Confirmed for 1.11

Is this still a issue in the latest version of the game(currently 1.13.1)?

If so, please add it to the affected versions, thanks!

Confirmed for 20w51a, I should add that the fact they CAN run commands without permission is used by map makers a lot, and the spawn protection checking should probably be removed instead.

Confirmed for 21w15a
Apologies for posting a duplicate issue, did not see this one despite a searching. Server spawn areas seem like the use case this function was nearly made for, and it's a shame they still do not work as such.

Cody Senmori

[Mod] turbo

(Unassigned)

Confirmed

Platform

Low

Commands, Dedicated Server

clickEvent, server, sign, spawn-protection

Minecraft 14w26c, Minecraft 14w29b, Minecraft 1.8.4, Minecraft 1.9, Minecraft 1.9.4, ..., 23w45a, 23w46a, 1.20.5, 1.20.6, 1.21

Retrieved