Thread Tools Display Modes
11-24-15, 05:27 PM   #1
MunkDev
A Scalebane Royal Guard
 
MunkDev's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2015
Posts: 431
Bagnon causes restricted environment lock?

I'm currently using some table manipulation inside the secure environment, where I gather unit frames by recursively scanning the UIParent and inserting all protected frames with a unit attribute assigned into a restricted table.

This works flawlessly - until I open interface settings. After that, attempting to run the snippet that gathers nodes results in this error:
Lua Code:
  1. 1x FrameXML\RestrictedExecution.lua:397: Call failed: FrameXML\RestrictedExecution.lua:397: Call failed: FrameXML\RestrictedExecution.lua:397: Call failed: FrameXML\RestrictedInfrastructure.lua:365: Cannot create restricted tables from insecure code
  2. [C]: ?
  3. FrameXML\RestrictedExecution.lua:397: in function <FrameXML\RestrictedExecution.lua:390>
  4. (tail call): ?
  5. (tail call): ?
  6. FrameXML\SecureHandlers.lua:283: in function <FrameXML\SecureHandlers.lua:277>
  7. (tail call): ?
  8.  
  9. Locals:
  10. workingEnv = <userdata>
  11. ctrlHandle = <userdata>
  12. pcallFlag = false
  13. LOCAL_Function_Environment_Manager = <function> defined @FrameXML\RestrictedExecution.lua:209
  14. error = <function> defined =[C]:-1
  15. tostring = <function> defined =[C]:-1

Naturally, I turned to the trustworthy taint log to see what the hell happend. After sifting through all the bloat I found this:
Code:
11/25 00:02:09.812  Execution tainted by Bagnon while reading BagnonFrameinventory - Interface\FrameXML\UIParent.lua:2784
11/25 00:02:09.812      securecall()
11/25 00:02:09.812      Interface\FrameXML\UIParent.lua:2824 CloseWindows()
11/25 00:02:09.812      Interface\FrameXML\UIParent.lua:2852
11/25 00:02:09.812      securecall()
11/25 00:02:09.812      Interface\FrameXML\UIParent.lua:3532 ToggleGameMenu()
11/25 00:02:09.812      TOGGLEGAMEMENU:1
11/25 00:02:09.812  Execution tainted by Bagnon while reading BagnonFrameinventory - Interface\FrameXML\UIParent.lua:2784
11/25 00:02:09.812      securecall()
11/25 00:02:09.812      Interface\FrameXML\UIParent.lua:2824
11/25 00:02:09.812      securecall()
11/25 00:02:09.812      Interface\FrameXML\UIParent.lua:1966 <unnamed>:ShowUIPanel()
11/25 00:02:09.812      Interface\FrameXML\UIParent.lua:1880
11/25 00:02:09.812      <unnamed>:SetAttribute()
11/25 00:02:09.812      Interface\FrameXML\UIParent.lua:2630 ShowUIPanel()
11/25 00:02:09.812      Interface\FrameXML\UIParent.lua:3543 ToggleGameMenu()
11/25 00:02:09.812      TOGGLEGAMEMENU:1
By disabling Bagnon, the errors disappear and I can continue to securely manipulate tables after opening the interface settings. So far, I've had no taint issues with Bagnon, but attempting to manipulate tables after viewing the interface settings seems to cause a complete meltdown.

So what I'm really asking here is:
  1. Can I prevent this from happening or is the problem only related to Bagnon?
  2. Can I determine whether I'm running a tainted execution path and thereby circumvent the lockdown?

Here's the actual code, but it's all executed within a secure enviroment and using secure buttons to trigger changes within.
It works regardless of combat state and hasn't broken down in any other scenario thus far.
__________________

Last edited by MunkDev : 11-24-15 at 06:12 PM.
  Reply With Quote
11-24-15, 06:55 PM   #2
jaliborc
A Chromatic Dragonspawn
 
jaliborc's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2007
Posts: 196
The only thing I can think of is that Bagnon uses the ColorPickerFrame in the configuration panel.
  Reply With Quote
11-24-15, 09:38 PM   #3
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,290
What are you trying to accomplish? Trying to hook the functionalty of every unit frame from the UIParent?
  Reply With Quote
11-24-15, 10:48 PM   #4
MunkDev
A Scalebane Royal Guard
 
MunkDev's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2015
Posts: 431
Originally Posted by Resike View Post
What are you trying to accomplish? Trying to hook the functionalty of every unit frame from the UIParent?

Four secure buttons are each given a direction, which is used to find the most appropriate selection from a table of unit frames. The wrapped pre-body generates a unit attribute, which is then attached to the button and fired immediately afterwards. The result is a one button press to both find the next unit frame and "click" that unit frame. The most appropriate unit frame is determined by looking at where the unit frames are drawn on screen. The cursor you see in that gif is just smoke and mirrors.
I'm not actually hooking anything.
__________________

Last edited by MunkDev : 11-25-15 at 12:17 AM.
  Reply With Quote
11-25-15, 12:16 AM   #5
MunkDev
A Scalebane Royal Guard
 
MunkDev's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2015
Posts: 431
Originally Posted by jaliborc View Post
The only thing I can think of is that Bagnon uses the ColorPickerFrame in the configuration panel.
Is that normally a culprit in issues like these?
I can't say for sure that Bagnon is causing the issue, but disabling it solves the problem.

This is the part where shit hits the fan:
Lua Code:
  1. local children = newtable(self:GetFrameRef("UIParent"):GetChildren())
__________________

Last edited by MunkDev : 11-25-15 at 12:39 AM.
  Reply With Quote
11-25-15, 01:40 AM   #6
MunkDev
A Scalebane Royal Guard
 
MunkDev's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2015
Posts: 431
I figured out a workaround, which involves scanning the children of UIParent outside the secure environment and then pushing the frames onto a stack one by one if they are protected.

Attempting to insert something tainted into a table created in the secure environment is most likely what caused the problem. Since InterfaceOptionsFrame is a child of UIParent, it would be included in the table if the scan is done outside of combat. Why specifically Bagnon seemed to be the culprit, I'm not sure. But this solution works:

Lua Code:
  1. function ConsolePort:UpdateSecureFrameStack()
  2.     if not InCombatLockdown() then
  3.         for i, child in pairs({UIParent:GetChildren()}) do
  4.             if not child:IsForbidden() and child:IsProtected() then
  5.                 UIHandle:SetFrameRef("NewChild", child)
  6.                 UIHandle:Execute([[
  7.                     FrameStack[self:GetFrameRef("NewChild")] = true
  8.                 ]])
  9.             end
  10.         end
  11.     end
  12. end

Lua Code:
  1. -- Changed this to only scan a predefined table instead of creating a new one
  2. UIHandle:Execute([[
  3.     UpdateFrameStack = [=[
  4.         Nodes = wipe(Nodes)
  5.         for Frame in pairs(FrameStack) do
  6.             CurrentNode = Frame
  7.             self:Run(GetNodes)
  8.         end
  9.     ]=]
  10. ]])
__________________

Last edited by MunkDev : 11-25-15 at 01:46 AM.
  Reply With Quote
11-25-15, 01:50 AM   #7
semlar
A Pyroguard Emberseer
 
semlar's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2007
Posts: 1,060
The taint log is pointing to bagnon inserting its frame into the UISpecialFrames table which is read by the CloseSpecialWindows function in UIParent.lua.

Your error itself is being caused by "newtable" being called from a tainted execution path, and frankly I don't know how that's even possible.

Last edited by semlar : 11-25-15 at 02:15 AM.
  Reply With Quote
11-25-15, 02:21 AM   #8
MunkDev
A Scalebane Royal Guard
 
MunkDev's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2015
Posts: 431
Originally Posted by semlar View Post
Your error itself is being caused by "newtable" being called from a tainted execution path, and frankly I don't know how that's even possible.
It's possible because handle:GetChildren() will still return unprotected frames in the secure environment when you're not in combat. Since they are unprotected, they can very well be tainted. It's kind of a trojan horse in the secure environment.
__________________
  Reply With Quote
11-25-15, 02:48 AM   #9
semlar
A Pyroguard Emberseer
 
semlar's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2007
Posts: 1,060
Originally Posted by MunkDev View Post
It's possible because handle:GetChildren() will still return unprotected frames in the secure environment when you're not in combat. Since they are unprotected, they can very well be tainted. It's kind of a trojan horse in the secure environment.
Any frame created by an addon that isn't secure is, by definition, tainted, so unless bagnon is the only thing you're running with a child of UIParent something else would also trigger it.

Here's an example that outputs all unprotected children of UIParent when you mouse over a unit. If you're in combat, GetChildren() will simply not include those frames, it doesn't freak out about a tainted execution path.
Lua Code:
  1. local f = CreateFrame('frame', nil, UIParent, 'SecureHandlerStateTemplate')
  2. f:SetAttribute('_onstate-mousestate', [[
  3.     if newstate == 'on' then
  4.         for i, f in pairs(newtable(self:GetParent():GetChildren())) do
  5.             if not f:IsProtected() and f:GetName() then
  6.                 print(f:GetName())
  7.             end
  8.         end
  9.     end
  10. ]])
  11. RegisterStateDriver(f, 'mousestate', '[@mouseover,exists] on; off')
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Bagnon causes restricted enviroment lock?


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off