hardhat icon indicating copy to clipboard operation
hardhat copied to clipboard

Infinite Loop in Source Map Parsing

Open tynes opened this issue 3 years ago • 3 comments

It is possible to cause an infinite loop in the source map parsing if an empty buffer ends up being passed through to this function. It will just loop forever.

https://github.com/NomicFoundation/hardhat/blob/98b7548525080c91a45cc3d3971f2d0248f62695/packages/hardhat-core/src/internal/hardhat-network/stack-traces/source-maps.ts#L76-L84

I think that there should be a check added to ensure that this doesn't loop forever to prevent hardhat from crashing on bad input.

It is possible to create an empty buffer if the string passed to this function has a 0x prefix. https://github.com/NomicFoundation/hardhat/blob/98b7548525080c91a45cc3d3971f2d0248f62695/packages/hardhat-core/src/internal/hardhat-network/stack-traces/library-utils.ts#L20-L33

This is only possible if there is a bug in the creation of the compiler output JSON file which incorrectly serializes the object bytecode with a 0x prefix.

tynes avatar Jun 28 '22 18:06 tynes

This issue is also being tracked on Linear.

We use Linear to manage our development process, but we keep the conversations on Github.

LINEAR-ID: 390b3faa-6306-4f67-bb1a-2308b4489fc6

github-actions[bot] avatar Jun 28 '22 18:06 github-actions[bot]

One option would be to pass compilerOutputBytecodeObject through remove0x or similar

smartcontracts avatar Jun 28 '22 20:06 smartcontracts

This issue was marked as stale because it didn't have any activity in the last 30 days. If you think it's still relevant, please leave a comment indicating so. Otherwise, it will be closed in 7 days.

github-actions[bot] avatar Aug 04 '22 19:08 github-actions[bot]