-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CSM restrictions: Make 'LOAD_CLIENT_MODS' disable loading of 'builtin' #8000
Conversation
Why a separate restriction instead of disabling |
Good question and is something that has confused many times. The 'LOAD_CLIENT_MODS' CSM restriction is for when a server sends CSMods to run on the client, but does not want the client to load it's own CSMods. In this situation 'builtin' needs loading because the server-sent mods require it. This is why the verification of 'builtin' is necessary once we have SSCSM, because it needs to be loaded. |
Restrictions probably should not apply to server-sent code. This (and the issue you mentioned in #7995 (comment)) would be solved by having separate Lua states for CSM and CPCSM as @nerzhul suggested in #5393 (comment). I think that would make a lot of sense since the APIs would probably differ. |
@pauloue i think SSCSM should have restrictions from client side too. If a client doesn't want server to use some API it should have the freedom to do it. And yeah server owners will not like this suggestion, but users should have the permission to block it, and being warned about gameplay issues. |
Since the builtin bypass is supposed to be eventually fixed, why not make |
I agree with @sfan5. I think mod loading & lua stack disable must be the same flag, there is no reason (currently) to have builtin alone. |
sfan5 good idea, i was concerned about adding a new restriction that may later be unnecessary. About the default: Because restrictions can be bypassed by placing code in builtin, and because builtin won't be checked in 5.0.0, the default for 5.0.0 will now have to be restriction enabled, disabled is not safe. |
load mods is already off by default but extendid load_mods restriction to builtin too (which is a good idea) permit to ensure it's nice. I suggest you to do that, and we can close all the issues related to CSM not restricteable |
How? I tested by using |
I mean things not covered by the 4 feature restrictions, but that should be restricted by 'LOAD_CLIENT_MODS'. |
Updated as requested (mostly). The default for CSM restrictions has been changed to disable the client scripting environment. Considering CSM is unfinished and considering the requests of server owners this seems essential. The default should be the safest option. I haven't tested this thoroughly yet. |
I think this doesn't work because scripts are inited in the client constructor, then the server doesn't have sent the CSM restriction it wanted. |
I'm fine with this actually, it's not any different than disabling Javascript (either completely or selectively) from running in a browser, and there are plenty of legit reasons to do that. |
Yes please. I have tried suggesting this as a compromise / discussion point a few times. (The thing about clients being able to decide what to accept from a server is common sense, and it shouldn't be assumed server owners will disagree with it.) |
One point we need to care, the default on remote server, but it should be enabled for singleplayer as it's the local player server :) @paramat let me code this this weekend, it's more tricky than just changing the condition because you are not in the correct workflow step |
No issues with singleplayer default being to allow. It should just be disabled by default for multiplayer servers. |
Do you mean CSM restrictions have not yet been sent from the server when the client constructor is run? I did wonder about that. I'll test this, i may have to move the restriction action back into 'loadMods'. And yes, CSM should be enabled by the singleplayer server, i forgot this. |
Tested and they are not. @nerzhul i don't mind you adding to this work but i would like to merge this as i've put a lot of work into it. As it is now this PR seems fine, it just doesn't load builtin. The only thing needed now is to enable CSM in singleplayer. If i can work out how i'll add this to the PR. |
builtin/settingtypes.txt
Outdated
@@ -1192,13 +1192,13 @@ server_side_occlusion_culling (Server side occlusion culling) bool true | |||
|
|||
# Restricts the access of certain client-side functions on servers | |||
# Combine these byteflags below to restrict client-side features: | |||
# LOAD_CLIENT_MODS: 1 (disable client mods loading) | |||
# LOAD_CLIENT_MODS: 1 (disable loading client-provided mods or 'builtin') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or 'builtin')
This is an implementation detail, and not really needed
your pr has been changed and doesn't disable builtin loading. As i said yes restriction are created when the client connect, then it's after cllient object creation, logical :) |
nerzhul, it does:
Found a bug so WIP. |
Fixed. Fix is:
To avoid running code that relies on builtin being loaded. Still need to apply according to singleplayer mode. |
It's not a fix, it's a hack. You will hack the cut for the callbacks but builtin has already be loaded in the constructor. I think i will take the ownership of this PR to rework the CSM loading workflow |
Where in the client constructor is builtin loaded? I can't see anything in The loading of builtin is done in I'm happy to let you do this if it's complex to the point of being beyond my ability, but please clearly explain so i understand. |
However there are 2 things that my PR doesn't do which it probably should:
|
@paramat for the singleplayer let it outside of your pr we will handle that in another PR. |
Ok. I'm happy for you to code that, i may not be able to do it well. To clarify: What this PR does is temporary while we work on SSCSM. It just moves the 'LOAD_CLIENT_MODS' restriction to before the loading of builtin. This PR is no longer WIP. |
Previously, when the CSM restriction 'LOAD_CLIENT_MODS' was used a client was still able to add CSM code to 'builtin' to bypass that restriction, because 'builtin' is not yet verified. Until server-sent CSM and verifying of 'builtin' are complete, make 'LOAD_CLIENT_MODS' disable the loading of builtin. Clarify code comments and messages to distinguish between client-side modding and client-side scripting. 'Scripting' includes 'builtin', 'modding' does not.
Rebased and updated.
|
luanti-org#8000) Previously, when the CSM restriction 'LOAD_CLIENT_MODS' was used a client was still able to add CSM code to 'builtin' to bypass that restriction, because 'builtin' is not yet verified. Until server-sent CSM and verifying of 'builtin' are complete, make 'LOAD_CLIENT_MODS' disable the loading of builtin. Clarify code comments and messages to distinguish between client-side modding and client-side scripting. 'Scripting' includes 'builtin', 'modding' does not.
Previously, when the CSM restriction 'LOAD_CLIENT_MODS' was used a
client was still able to add CSM code to 'builtin' to bypass that
restriction, because 'builtin' is not yet verified.
Until server-sent CSM and verifying of 'builtin' are complete, make
'LOAD_CLIENT_MODS' disable the loading of builtin.
Clarify code comments and messages to distinguish between client-side
modding and client-side scripting. 'Scripting' includes 'builtin',
'modding' does not.
///////////////////////////////
A CSM restriction exists ('LOAD_CLIENT_MODS' ) that stops a client loading CSMods, this is for servers that want to stop a client using any CSM code, whether it is generally considered harmful or not.
However this restriction does not stop the client loading the 'builtin' CSM code, and it's easy to add CSM code to builtin, and builtin is not yet checked for such added code.