Closed c4-bot-10 closed 8 months ago
141345 marked the issue as insufficient quality report
Out of scope
Was OOS for this audit, tagging @kvinwang in case you want to take a look anyways
OpenCoreCH marked the issue as unsatisfactory: Out of scope
The macro does not only generate the fn dispatch
but also generate the caller side implementation which would ensure the panic never happen.
As for the depth_limit, the input data structure is defined in pink runtime itself. There isn't such data structure that would be too deep.
Lines of code
https://github.com/code-423n4/2024-03-phala-network/blob/a01ffbe992560d8d0f17deadfb9b9a2bed38377e/phala-blockchain/crates/pink/macro/src/macro_xcall.rs#L190
Vulnerability details
Impact
pink_runtime::capi::ecall()
serves as the central hub for all ecall functions. Upon invocation, it forwards function calls by invoking theecall::dispatch
.ecall::dispatch
function is generated by macro_xcallmacro_xcall.rs#L199
Here is where the execution methods are generated
macro_xcall.rs#L190
As you can see, the args are decoded before passing it to the executor. There are two problems here:
parity_scale_codec
crate decode feature. Because of this,decode_with_depth_limit
function was introduced. Check: https://docs.rs/parity-scale-codec/latest/parity_scale_codec/trait.DecodeLimit.htmlexpect
, if an error occured, it will panic with the message "Failed to decode args". So, even ifdecode_with_depth_limit
was used, panic will occur, just caused by a different reason.The following code won't panic. Instead, it will return an error.
Proof of Concept
Included above within the impact for simplicity.
Tools Used
Manual analysis
Recommended Mitigation Steps
Assessed type
Other