You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While dealing with OpenFn/language-http#15, we found that VM2's Contextify/Decontextify functions were breaking the object structure of the Agent object.
Internally Node's _http_client.js checks the Agent looks correct by checking for the existance of the addRequest function.
In certain situations this function ceases to exist (or is placed somewhere else in the object) when the check fails.
See: https://github.com/nodejs/node/blob/master/lib/_http_client.js#L149
This issue can be recreated like this:
const{VM}=require('vm2');consthttps=require('https');console.log(typeofnewrequire('https').Agent().addRequest);functionmyFunc(args){return{...args};}newVM({sandbox: { https, myFunc,console }}).run(`try { function threeFunc(args) { debugger; return {...args}; } const three = threeFunc(new https.Agent()); console.log(typeof three.addRequest); console.log(typeof (https.Agent()).addRequest); const one = myFunc(new https.Agent()); console.log(typeof one.addRequest); const two = myFunc.apply(undefined, new https.Agent()); console.log(typeof two.addRequest);} catch (err) { console.error(err)}`);
NOTE this may very well not be solvable, or at least in a way that benefits us - i.e. we need proxied and sandboxed functions in order to protect against malicious code.
Can we somehow work with VM2 in a way that doesn't expose this problem, and if so - what does that look like?
The text was updated successfully, but these errors were encountered:
While dealing with OpenFn/language-http#15, we found that VM2's Contextify/Decontextify functions were breaking the object structure of the
Agent
object.Internally Node's
_http_client.js
checks theAgent
looks correct by checking for the existance of theaddRequest
function.In certain situations this function ceases to exist (or is placed somewhere else in the object) when the check fails.
See: https://github.com/nodejs/node/blob/master/lib/_http_client.js#L149
This issue can be recreated like this:
Can we somehow work with VM2 in a way that doesn't expose this problem, and if so - what does that look like?
The text was updated successfully, but these errors were encountered: