Boost _ Firedancer v0.1 34064 - [Blockchain_DLT - Medium] bank tile possible code execution
Submitted on Mon Aug 05 2024 02:31:39 GMT-0400 (Atlantic Standard Time) by @gln for Boost | Firedancer v0.1
Report ID: #34064
Report type: Blockchain/DLT
Report severity: Medium
Target: https://github.com/firedancer-io/firedancer/tree/e60d9a6206efaceac65a5a2c3a9e387a79d1d096
Impacts:
Any sandbox escape
Description
Brief/Intro
Bank and poh tiles do not have checks for minimum fragment size.
Also bank tile trusts the pointer it receives in fragment from pack tile.
Vulnerability Details
Several tiles do not have lower bound checks for size of incoming fragments.
Let's look at the code:
poh tile https://github.com/firedancer-io/firedancer/blob/main/src/app/fdctl/run/tiles/fd_poh.c#L1392
bank tile https://github.com/firedancer-io/firedancer/blob/main/src/app/fdctl/run/tiles/fd_bank.c#L107
there is an upper bound check for 'sz'
in case 'sz' is less than sizeof(fd_microblock_bank_trailer_t) memcpy with very large length will be called on this line
This could possibly lead to code execution in poh/bank tiles and sandbox escape, because both of these tiles run in agave process as threads and basically have no sandbox.
Another interesting issue is that fd_bank tile does not have any checks for 'bank' pointer.
It is being initialized from incoming fragment, see line #3 on the above code snippet.
Later on this pointer is passed to fd_ext__ rust calls:
what happens here is that Arc::increment_strong_count() increments refcount by using our bank pointer.
This issue gives us an ability to increment the value at any address in memory, which is quite powerful primitive.
It could lead to code execution in bank tile/agave process and escape out of sandbox.
Impact Details
Remote code execution in poh/bank tiles. Sandbox escape as these tiles are not sandboxed.
Proof of concept
Proof of Concept
How to reproduce:
get firedancer source code
to simplify the testing I've slightly modified the code
src/app/fdctl/config.c on lines 546, 551, 653: change FD_LOG_ERR macro to FD_LOG_INFO
disco/mux/fd_mux.c - comment out line 166
fd_bank.c - change line 129 to something like " ctx->_bank = trailer->bank;ctx->_bank=(void*)0x4142434451525354;sleep(20);". Make sure to add "#include <unistd.h>" at the beginning as well.
disco/mux/fd_mux.c - comment out line 608 (do not call 'continue')
To test memcpy() issue: disco/mux/fd_mux.c - add code on line 643 "chunk=32841;sz=4;"
build firedancer with asan
run bank tile:
To test 'bank' pointer issue, edit fd_mux.c file on line 643 , change it to "chunk=32841;sz=20;"
run bank tile, it will fork and go to background:
get the pid of 'fdctl' process - "ps aux|grep fdctl" and attach to it by using gdb, enter "c" and press enter
after some time bank tile will crash:
As you can see, basically it is increment-anywhere primitive
Last updated
Was this helpful?