Closed c4-bot-5 closed 3 months ago
141345 marked the issue as primary issue
141345 marked the issue as sufficient quality report
block number and event hash do not correspond to each other
The implementation matches the documentation. Chain extension is the low-level API, and more convenient functions can be implemented in a higher-level SDK.
kvinwang (sponsor) disputed
OpenCoreCH changed the severity to QA (Quality Assurance)
QA at most, the implementation is according to the docs, so if applications use these values differently, that's on them
OpenCoreCH marked the issue as grade-b
Lines of code
https://github.com/code-423n4/2024-03-phala-network/blob/a01ffbe992560d8d0f17deadfb9b9a2bed38377e/phala-blockchain/crates/pink/runtime/src/runtime/extension.rs#L321-L326
Vulnerability details
Proof of Concept
Take a look at https://github.com/code-423n4/2024-03-phala-network/blob/a01ffbe992560d8d0f17deadfb9b9a2bed38377e/phala-blockchain/crates/pink/runtime/src/runtime/extension.rs#L321-L326
This method is used to retrieve the information for the current event chain
Now consider the following snippets from from
pallet_pink.rs
that are being queried to demonstrate the storage items involved:Impact
The current implementation of
current_event_chain_head
inextension.rs
might return inaccurate information about the event chain head. Here's how it impacts the system:PalletPink::next_event_block_number()
. This function returns the number for the next event block, not the current one. This creates a discrepancy between the reported head and the actual state of the chain.PalletPink::last_event_block_hash()
. This value might not reflect the most recently committed event block's hash if not updated promptly.This inconsistency leads to issues for applications or functionalities that rely on accurate event chain head information. For example:
Recommended Mitigation Steps
Refactor the functions not to return any stale or futuristic data for the current event chain head, this should be easily achieved by modifying the
current_event_chain_head
method.Assessed type
Context