diff --git a/src/lj_load.c b/src/lj_load.c index 0aab488407..13783af4b3 100644 --- a/src/lj_load.c +++ b/src/lj_load.c @@ -34,11 +34,18 @@ static TValue *cpparser(lua_State *L, lua_CFunction dummy, void *ud) UNUSED(dummy); cframe_errfunc(L->cframe) = -1; /* Inherit error function. */ bc = lj_lex_setup(L, ls); - if (ls->mode && !strchr(ls->mode, bc ? 'b' : 't')) { + /* Disable loading of Lua bytecode. Untrusted bytecode is unsafe and can + ** crash the VM or be used for sandbox escapes; see the LuaJIT FAQ. + */ + if (bc) { setstrV(L, L->top++, lj_err_str(L, LJ_ERR_XMODE)); lj_err_throw(L, LUA_ERRSYNTAX); } - pt = bc ? lj_bcread(ls) : lj_parse(ls); + if (ls->mode && !strchr(ls->mode, 't')) { + setstrV(L, L->top++, lj_err_str(L, LJ_ERR_XMODE)); + lj_err_throw(L, LUA_ERRSYNTAX); + } + pt = lj_parse(ls); fn = lj_func_newL_empty(L, pt, tabref(L->env)); /* Don't combine above/below into one statement. */ setfuncV(L, L->top++, fn);