Skip to content
Business logic Audit finding Intermediate

Wrong calcAsymmetricShare calculation

The code that calculates asymmetric shares does not match the formula given in the inline comment, and the order of multiplication is wrong. This could let an attacker borrow more than their collateral because the share value used for collateral is incorrect.

Vader Protocol contest

Originally disclosed on Code4rena

The inline-comment defines the number of asymmetric shares as (u * U * (2 * A^2 - 2 * U * u + U^2))/U^3 but the Utils.calcAsymmetricShare function computes (uA * 2U^2 - 2uU + u^2) / U^3 which is not equivalent as can be seen from the A^2 term in the first term which does not occur in the second one.

The associativity on P * part1 is wrong, and part2 is not multiplied by P.

The math from the spec is not correctly implemented and could lead to the protocol being economically exploited, as the asymmetric share (which is used to determine the collateral value in base tokens) could be wrong. For example, it might be possible to borrow more than the collateral put up.

Recommend clarifying if the comment or the code is correct and fix them if not.

strictly-scarce (vader) confirmed:

Valid

strictly-scarce (vader) commented:

Whilst the math is incorrect, in the current implementation it is not yet implemented, so disagree with Severity (funds not lost), recommend: 2

The original report as published on Code4rena. 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 developer implemented the formula incorrectly, using a different expression from the one in the comment and misplacing a multiplication.

Impact

The incorrect share calculation could allow an attacker to borrow more than their collateral, but the vulnerable function is not yet used in the current implementation, so no funds are lost at present.

What the attacker needed

None

The fix

The code or the comment should be corrected so they match, but the text does not state that a fix was applied.

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.

A comment in the code describes a mathematical formula for calculating a value called an asymmetric share. The actual code that computes this value uses a different formula and also multiplies things in the wrong order. Because this share is used to work out how much collateral someone has, a mistake could let someone borrow more money than they should.

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 Vader Protocol contest

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.