-
Notifications
You must be signed in to change notification settings - Fork 346
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
Fix metatable security. #309
base: master
Are you sure you want to change the base?
Conversation
According to LuaBridge documentation the __metatable field is set to false. But apparently this is not the case. Resulting in scripts being able to tamper with them.
It seems that __metatable is not hidden for new namespaces.
if (Security::hideMetatables()) | ||
{ | ||
lua_pushboolean(L, 0); | ||
rawsetfield(L, -2, "__metatable"); | ||
} | ||
|
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.
Spaces should be used instead of tabs.
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.
@Mellnik ?
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.
Is it okay for you when you just push the change under your name?
Can you add a unit test which fails with the original implementation and works with the change? |
The LuaBridge3 repo copied my fix last week + a unit test. Use that? |
From LuaBridge documentation:
According to Lua docuemtation the field must be set to prevent tampering with it.
Setting it to nil as it is currently done, effectively does nothing.
I went back to LuaBridge 1.0.0 where is was still correctly a boolean. Since 1.0.2 it changed to nil.
This makes me wonder if there are more security issues with LuaBridge...
Edit:
I forgot to mention that setting __metatable when constructing Namespace is missing completely. I've also added that to the PR.