[9.0] Fix lua-enable-insecure-api default value cannot be changed to yes (#3548) - #4182
Merged
sarthakaggarwal97 merged 1 commit intoJul 17, 2026
Merged
Conversation
…alkey-io#3548) The default value of lua-enable-insecure-api cannot be safely changed from no to yes due to two issues: 1. In createEngineContext(), lua_enable_insecure_api was hardcoded to 0 before initializing Lua states, so deprecated APIs (newproxy, setfenv, getfenv) were never registered in the global table regardless of the actual config value. Once the global table is locked, the config change has no effect. 2. lua_insecure_api_current was initialized to 0 (struct zero-init) and never synced with the final config value. If the default was changed to yes(1), a subsequent CONFIG SET no would see both values as 0 and skip the evalReset() call in updateLuaEnableInsecureApi(). Fix by reading the real config via isLuaInsecureAPIEnabled() in createEngineContext() before Lua state initialization, and syncing lua_insecure_api_current after all config sources (default, config file, command-line args) are applied. 9.0 backport note: only fix valkey-io#2 (the lua_insecure_api_current sync in server.c) applies to this branch. Bug valkey-io#1 does not exist on 9.0: there is no per-engine-context lua_enable_insecure_api field hardcoded to 0 -- the Lua engine has not been modularized here (src/lua/, not src/modules/lua/). The deprecated-API allowlist gate reads server.lua_enable_insecure_api directly (script_lua.c luaNewIndexAllowList), and evalInit() runs in initServer() after loadServerConfig(), so the config-file value is already honored at Lua state initialization. The engine_lua.c hunk is therefore dropped. Validated: the two new tests fail on 9.0 without the server.c sync and pass with it. Signed-off-by: Binbin <binloveplay1314@qq.com>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
sarthakaggarwal97
approved these changes
Jul 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Backport of #3548 to 9.0. Picked up from the "Needs attention" list in sweep #4167,
which skipped it because the target branch lacks src/modules/lua/engine_lua.c.
Adaptation for 9.0: only fix #2 from the original PR (the
lua_insecure_api_currentsync in server.c) applies here. Fix #1 does notexist on 9.0: the Lua engine is not modularized on this branch (src/lua/, not
src/modules/lua/), there is no per-engine-context
lua_enable_insecure_apifield hardcoded to 0, and the deprecated-API allowlist gate reads
server.lua_enable_insecure_apidirectly inluaNewIndexAllowList(script_lua.c). Since
evalInit()runs ininitServer()afterloadServerConfig(), the config-file value is already honored at Lua stateinitialization. The engine_lua.c hunk is therefore dropped.
Validation on 9.0:
unit/scriptingsuite passes with the fixgetfenv()remains accessible after
CONFIG SET lua-enable-insecure-api nobecauseupdateLuaEnableInsecureApi()sees0 != 0as false and skipsevalReset()