0

I need to modify the embedded V8 engine in electronjs/nodejs in order to intercept/block any network access request, whether it be through request, http module or even src tag in a html or ajax request, i need to pull this off at the core of V8 so that no one could tamper it using any js code. ( Maybe possibly through C++ addons. )

C++ is not my best thing so if anyone could help me with the solution and implementation I'll appreciate it.

Timberland
  • 40
  • 8

1 Answers1

0

V8 does not do any networking requests and has no networking code, so there is nothing to intercept there. You'll have to look at the respective embedder (i.e. Electron/Node).

jmrk
  • 34,271
  • 7
  • 59
  • 74
  • So there's literally no point in V8 to cross and build the wall? what about this webrequest feature which is in Chrome : https://developer.chrome.com/extensions/webRequest, is it possible to implement it somehow into V8? any clear constructive idea how to achieve it would be much appreciated. – Timberland Dec 10 '18 at 19:21
  • 1
    Correct, there is no point in V8 where you could intercept all network requests. V8 does not know what a "web request" or the `chrome.webRequest` API is. This and other APIs exposed to JavaScript are created by the respective embedder via V8's C++ API. – jmrk Dec 10 '18 at 19:25
  • Then going after respective embedder i guess it would mean to go after each individual API while I'm looking for a once-for-all solution. I still cant get my head around that, if there's no networking part/capability in V8 itself then that means if i embed it into a program it shouldn't be able to load a url or make any request, There gotta be something ! perhaps by blocking port access like 80 in V8 etc – Timberland Dec 10 '18 at 19:40
  • 1
    Correct, if you embed V8 in a program then V8 will be unable to load any URLs (it doesn't even know what a URL is) or make any requests (it doesn't even know what a request is). Embedders provide networking functionality, but to V8 that's just an external function call, it doesn't know or care whether the embedder's code is going to the network or to disk or to whatever. There may well be a central bottleneck for your purposes, but it's not in V8. I guess Node has some central networking component that all requests go through. – jmrk Dec 10 '18 at 20:06
  • Thank you for the clarifications, i wanted to update the question from V8 to Nodejs but let's leave it be for if somebody else's went through the same wrong assumption about V8. – Timberland Dec 10 '18 at 21:01
  • Similar confusion, in Chromium, network request seems in webRequest API, so it mean 3rd network module such as axios in nodejs, will send the request to webRequest? if it does, what if the env in nodejs without chromium? – Kylin.Zhang Jun 08 '22 at 11:26