Blocking on an API basis

Bug reports and enhancement requests
phyks
Posts: 9
Joined: Fri Mar 27, 2015 8:23 pm

Re: Blocking on an API basis

Post by phyks »

Well, I had a try with Object.defineProperty, but I could not get it to work fine with RTCPeerConnection. On the contrary, my (not so nice) solution to set brutally mozRTCPeerConnection to false seems to be working.

I had a look with a debugger, and trying to access window.mozRTCPeerConnection returns false (in the console), and so does it in the script running (with a breakpoint in the if statement with the iframe trick, I can confirm it enters the iframe due to this script).
Mozilla/5.0 (X11; Linux x86_64; rv:37.0) Gecko/20100101 Firefox/37.0
barbaz
Senior Member
Posts: 11066
Joined: Sat Aug 03, 2013 5:45 pm

Re: Blocking on an API basis

Post by barbaz »

Looks like you need to supply a getter that returns a function.

Code: Select all

Object.defineProperty(window, 'mozRTCPeerConnection', {get:function(){console.log('rtc');return function(){};},set:function(){}});
(Weird, that wasn't needed before...)
*Always* check the changelogs BEFORE updating that important software!
-
phyks
Posts: 9
Joined: Fri Mar 27, 2015 8:23 pm

Re: Blocking on an API basis

Post by phyks »

Indeed, it works. Thanks a lot!

It's really weird that I have to return a function in the getter… Do you have any idea why is this happening? Especially as manually overriding mozRTCPeerConnection, brutally, was working, but only in the main window and not in the iframe.

Thanks
Mozilla/5.0 (X11; Linux x86_64; rv:37.0) Gecko/20100101 Firefox/37.0
barbaz
Senior Member
Posts: 11066
Joined: Sat Aug 03, 2013 5:45 pm

Re: Blocking on an API basis

Post by barbaz »

:D
phyks wrote:It's really weird that I have to return a function in the getter… Do you have any idea why is this happening?
No, it's black magic to me. :roll: I have no idea why I even tried that in the first place.
Also, that trick isn't needed in SeaMonkey.
*Always* check the changelogs BEFORE updating that important software!
-
phyks
Posts: 9
Joined: Fri Mar 27, 2015 8:23 pm

Re: Blocking on an API basis

Post by phyks »

Arf =( I am not a huge fan of black magic,especially when it comes to security concerns… But it works and will do the trick for a PoC :)

I'll try to find more infos about what is happening, and will have a look at plugins API in Firefox, to have something that may be more robust.
Mozilla/5.0 (X11; Linux x86_64; rv:37.0) Gecko/20100101 Firefox/37.0
barbaz
Senior Member
Posts: 11066
Joined: Sat Aug 03, 2013 5:45 pm

Re: Blocking on an API basis

Post by barbaz »

phyks wrote:Arf =( I am not a huge fan of black magic,especially when it comes to security concerns…
+1
phyks wrote:But it works and will do the trick for a PoC :)
Good, especially since that PoC is not designed to work around this trick, it's coincidence that it's being difficult here
phyks wrote:I'll try to find more infos about what is happening, and will have a look at plugins API in Firefox, to have something that may be more robust.
This method is robust for the time being... but please post your findings if you find anything noteworthy or interesting. I too like to block individual JS properties, and if there's a better way I'd like to know. :)
*Always* check the changelogs BEFORE updating that important software!
-
Post Reply