Bug that allows you to bypass "attempt to run function in a different lua vm"

You can bypass “attempt to run function in a different lua vm” for parallel and serial by using bindableevents and bindablefunctions by cloning a module and parenting it to an actor and then requiring it

-- Script 
local module = script.Module:Clone()
module.Parent = Instance.new("Actor")

require(module)(function() 
	workspace.DescendantAdded:ConnectParallel(print)
end)
--Module
local BF = Instance.new("BindableFunction")
BF.OnInvoke = function(F,...)
    return F(...)
end
return function(...)
    return BF:Invoke(...)
end

Here’s a video example of this happening:


please patch this soon!

A private message is associated with this bug report

I believe that this error is the same reason that you need to use BindableFunctions for interacting with Core Scripts through StarterGui:SetCore. This isn’t a security vulnerability from my understanding, but rather that Luau VMs cannot call functions defined in other VMs because of technical limitations, and Bindables call the function through the correct VM instead.

The way that I’m doing it shouldn’t be possible normally, you shouldn’t be able to use bindable functions and bindable events to bypass that limitation set, you’re introducing a function from a completely separate Luau VM and running it in another Luau VM.

Like look here for example, when i try to do it this way, it provides me with the Attempt to load a function from a different Lua VM error, while the one I’m reporting does not and runs the function anyway.

After some testing, in the original video you never actually entered a different Luau VM.

Changing the Script to be

_G.Value = 42

local module = script.Module:Clone()
module.Parent = Instance.new("Actor")

require(module)(function()
	workspace:GetPropertyChangedSignal("DistributedGameTime"):ConnectParallel(function()
		print(_G.Value)
	end)
end)

, and the ModuleScript to be

local BF = Instance.new("BindableFunction")
BF.OnInvoke = function(F,...)
	return F(...)
end
return function(...)
	print(_G.Value)
	return BF:Invoke(...)
end

Shows:

image

Whereas,

_G.Value = 42
print(_G.Value)

local actorScript = script.ActorScript:Clone()
local actor = Instance.new("Actor")
actorScript.Parent = actor

actor.Parent = workspace
task.wait()
actor:SendMessage("Run")

and Module (now a Script called ActorScript),

if not script.Parent:IsA("Actor") then
	return
end

script.Parent:BindToMessageParallel("Run", function()
	print(_G.Value)
end)

Gives:

image

, because the original script calling :ConnectParallel did not do so under an Actor, you simply called the function indirectly in the same VM through the Module and BindableFunction. You never entered a new VM or the Parallel Phase, which also does not support calling BindableFunction:Invoke

image

Modules do not run in a different VM from the requiring script, although script:GetActor() returns the actor and task.desynchronize/synchronize appear to work, it doesn’t actually run in a different VM, like @5eri_n states.

I guess you could report the ability to desynchronize as a bug, but it doesn’t appear to be a vulnerability.

As @5eri_n has mentioned, the ModuleScript is actually using the same VM as the function that is being called.

So, as far as I can tell, the behavior being reported is actually as designed. I think this report can be safely closed as “By Design”.

Although if there are any special edge cases (@averlst mentioned “the ability to desynchronize as a bug”) that are still considered suspicious, they may potentially indicate a bug. So please do let me know if there are even more elaborate repro cases that are potentially indicative of a bug.