Skip to content
Business logic Audit finding Beginner

Incorrect Decimals Setting for ckrBTC Token May Lead to User Confusion and Inaccurate Transaction Amounts

The ckrBTC token on Starknet uses 18 decimals instead of the expected 8 for a Bitcoin-pegged asset. This could confuse users about amounts and cause tools relying on 8 decimals to malfunction.

Xor0v0 Follow with AllTooWell and Abdessamed

Originally disclosed on Code4rena

Submitted by Xor0v0, also found by AllTooWell and Abdessamed

Impact

In the OpenZeppelin library, the decimals of the ERC20 component defaults to 18, which is abnormal for BTC. Incorrect decimal settings may result in users entering incorrect amounts or understanding incorrect balances during transactions. This confusion may lead to property damage or transaction failure, especially when the transaction amount is large.

On the other hand, many tools, applications, or smart contracts related to Bitcoin may rely on an accuracy of 8 decimal places. If the accuracy setting is incorrect, these tools or contracts may not work properly, thereby affecting the operation of the entire ecosystem.

Proof of Concept

https://github.com/code-423n4/2024-08-chakra/blob/abef77d95866f2fec93270491fc5abc9ab14f86d/cairo/handler/src/ckr_btc.cairo#L78

Recommended Mitigation Steps

Rewrite the decimals to 8 for the ckrBTC token.

zvlwwj (Chakra) confirmed

0xsomeone (judge) commented:

The Warden has identified that the ckrBTC token on the Starknet network has a different number of decimals than on other networks, causing the ckrBTC variant of the Starknet network to be consistently overvalued.

I do not envision any impact from this discrepancy apart from the value per whole unit of ckrBTC token on the Starknet network being higher than the value per whole unit of ckrBTC token on other networks. As such, I believe a medium-risk rating is acceptable.


The original report as published on Code4rena, by Xor0v0. Images and videos are our own copies; raw HTML is shown as text. View it on Code4rena.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the token contract inherited OpenZeppelin's default of 18 decimals instead of explicitly setting 8 for a Bitcoin-pegged asset.

Impact

The judge noted the Starknet token variant is consistently overvalued per whole unit, but did not see other impact; no exploit or fund loss is demonstrated.

What the attacker needed

None

The fix

The decimals should be set to 8 for the ckrBTC token.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

Tokens have a 'decimals' setting that says how many decimal places the smallest unit represents. Bitcoin normally uses 8, but this token used 18, so the same number of tokens could look very different and confuse people or tools.

What is Business logic?

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.

More from Chakra

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.