Skip to content

Conversation

@NanoBob
Copy link
Contributor

@NanoBob NanoBob commented Mar 11, 2021

This PR changes permission checks to be done on the global client variable instead of on the event source. Since the event source is not guaranteed to be the player that triggered the event. (Think modified clients / injected Lua code)

Some detections are already in place to verify the client and source are equal, but with default configuration these are not enabled.
Furthermore there really is no reason to use source over client in this case since client is always the correct client.

@Dutchman101
Copy link
Member

This causes a change in behavior with some commands (popular across gamemodes, including the default freeroam) that are listed in ACL

Example from chatbox: Access denied for 'repair'

@NanoBob
Copy link
Contributor Author

NanoBob commented Mar 12, 2021

There's no reason that should be the case, all this change does is check if the actual client that triggered an event has permission todo so. This would only have an impact in case the event is triggered from a client with a source other than that client's local player.

Furthermore freeroam has its own repair command which is completely unrelated to the admin resource:

function repairVehicle()

So unless any other gamemode were to trigger admin events, supplying a different element than the localplayer (one which does have the required admin access) as source, this change will not impact any such gamemode.

What I do see happening is that the admin panel itself triggers this event through commands (which arguably should not be done in this way, but legacy code..)
I'll add an additional update to fall back onto the event source, only if client is nil (or otherwise falsey).

@Dezash
Copy link
Contributor

Dezash commented Mar 12, 2021

I think it would be better to separate the functions that are called by these event handlers so that the permission check wouldn't be needed at all if the function is called directly.
You could then replace serverside triggerEvent with function calls.

@NanoBob
Copy link
Contributor Author

NanoBob commented Mar 12, 2021

I do agree that it would indeed make far more sense for commands and events to be two separate ways to trigger the same function. (Instead of commands using the same events clients use).
However I do believe that is out of scope of this PR, since you're talking about a refactor (albeit a good one), while this is PR is about a pretty big security issue.

@jlillis jlillis mentioned this pull request Mar 19, 2021
5 tasks
@jlillis jlillis merged commit ef59929 into multitheftauto:master Mar 19, 2021
@patrikjuvonen
Copy link
Contributor

So, did this change break other default resources or no? I expect fixes to them where needed.

@xLive
Copy link
Member

xLive commented Mar 20, 2021

So, did this change break other default resources or no? I expect fixes to them where needed.

No, it shouldn't affect other default resources.

@NanoBob NanoBob deleted the fix/client-permission-checks branch March 22, 2021 16:02
@patrikjuvonen patrikjuvonen added this to the 1.5.9 milestone Apr 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants