fablo icon indicating copy to clipboard operation
fablo copied to clipboard

Config driven shell injection in generated chaincode commands

Open rootp1 opened this issue 6 months ago • 4 comments

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.

rootp1 avatar May 05 '26 20:05 rootp1

Hey @umegbewe , @dzikowski What Do you think?

rootp1 avatar May 05 '26 20:05 rootp1

I can open a PR for this if helpful.

rootp1 avatar May 05 '26 20:05 rootp1

@rootp1 before opening a PR, do you mind showing code examples in this issue?

umegbewe avatar May 05 '26 20:05 umegbewe

    <% 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

rootp1 avatar May 05 '26 20:05 rootp1