fablo
fablo copied to clipboard
Config driven shell injection in generated chaincode commands
Raw EJS output (<%- ... %>) is embedded inside quoted shell arguments in chaincode-install-v2.sh and chaincode-install-v2.sh. Values like chaincode.endorsement and chaincodeStartCommand are not escaped before becoming executable shell.
Hey @umegbewe , @dzikowski What Do you think?
I can open a PR for this if helpful.
@rootp1 before opening a PR, do you mind showing code examples in this issue?
<% if (chaincode.lang === "ccaas") { -%>
<% const instance = chaincode.peerChaincodeInstances.find((ci) => ci.peerAddress === peer.address); -%>
startCCaaSContainer <% -%>
"<%= peer.fullAddress %>" <% -%>
"<%= chaincode.name %>" <% -%>
"<%= chaincode.channel.name %>_<%= chaincode.name %>_$version" <% -%>
"<%= chaincode.image %>" <% -%>
"<%= instance.port %>" <% -%>
"<%= org.cli.address %>" <% -%>
"<%= !global.tls ? '' : `crypto-orderer/tlsca.${chaincode.channel.ordererHead.domain}-cert.pem` %>" <% -%>
"<%= instance.containerName %>" <% -%>
"<%= chaincode.chaincodeMountPath ?? "" %>" <% -%>
"<%- chaincode.chaincodeStartCommand ?? "" %>"
<% } -%>
@umegbewe, for example there is the last line, StartCommand is not escaped