-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Make debug.g/setmetatable respect the "__metatable_debug" metatable field
#12118
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
Conversation
0719b5c to
cb1491d
Compare
|
Now they are not overwritten iff mod security is off. In that case, |
|
I find this change highly questionable. Shouldn't we just remove these functions from the sandbox if there's concern over security? |
|
I didn't know how often these functions are used. IIRC there was a discussion in irc about this, where someone (you?) said that they're (almost?) nowhere used. (Ie. mesecons just uses the normal |
|
To properly discuss this it'd be useful if someone (@appgurueu?) could sum up on what types |
Example: > t = setmetatable({}, {__metatable = 42})
> =getmetatable(t)
42
> =debug.getmetatable(t)
table: 0x55d51c5c4060
> setmetatable(t, {})
stdin:1: cannot change a protected metatable
stack traceback:
[C]: in function 'setmetatable'
stdin:1: in main chunk
[C]: ?
> debug.setmetatable(t, {})Further resources: pgimeno's metatable tutorial and the Lua reference manual |
| ]] | ||
|
|
||
| -- Overwrite debug.getmetatable and debug.setmetatable, so that they have the same | ||
| -- semantics with the metatable field "__metatable_debug" as getmetatable and |
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.
Why not respect the __metatable field?
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.
To give more control. And theoretically there could be a mod that does some hacky, but valid, stuff with another mod's object.
If we want to keep debug.setmetatable just for non-table objects and nothing else, using __metatable might be better.
|
Underlying issue (#12216) was fixed, closing. |
debug.getmetatableanddebug.setmetatableare overwritten in builtin to use the"__metatable_debug"field likegetmetatableandsetmetatableuse the"__metatable"field."__metatable_debug"as for"__metatable". This prevents mods from doing nasty stuff like overwriting or replacing"__gc"metatable fields.(The
"__metatable"fields had basically no effect.)debug.g/setmetatablein the sandbox because we want to allow to overwrite the string metatable.)To do
This PR is a Ready for Review.
How to test