Sablier

Sablier
DeFiFoundry
53,440 USDC
View results
Submission Details
Severity: low
Invalid

Calculation of X-axis for SVG will make NFTs to not be centered correctly

Vulnerability Details

The NFTSVG library has a visual assymetry issue.

If the total width of the cards combined is not an even number, dividing by two and truncating the result could lead to one side of the SVG having slightly more whitespace than the other. While often minor, in detailed graphical representations, especially those intended for high-resolution displays or where precise symmetry is aesthetically important, this could be noticeable.

unchecked {
// Calculate the width of the row containing the cards and the margins between them.
vars.cardsWidth =
vars.amountWidth + vars.durationWidth + vars.progressWidth + vars.statusWidth + CARD_MARGIN * 3;
// Calculate the positions on the X axis based on the following layout:
//
// ___________________________ SVG Width (1000px) ___________________________
// | | | | | | | | | |
// | <-> | Progress | 16px | Status | 16px | Amount | 16px | Duration | <-> |
@> vars.progressXPosition = (1000 - vars.cardsWidth) / 2; // @audit - truncated value.
vars.statusXPosition = vars.progressXPosition + vars.progressWidth + CARD_MARGIN;
vars.amountXPosition = vars.statusXPosition + vars.statusWidth + CARD_MARGIN;
vars.durationXPosition = vars.amountXPosition + vars.amountWidth + CARD_MARGIN;
}
  1. The calculation (1000 - vars.cardsWidth) / 2 sets the starting position for the progress card based on the total width of all cards plus margins. This assumes an even distribution of remaining space on either side of the combined cards.

  2. However, this approach can lead to a situation where the cardsWidth calculation results in an odd number, causing the / 2 division to round down.

  3. The subsequent positioning of the status, amount, and duration cards builds off the initial progress card's position, propagating any initial misalignment throughout the layout.

Impact

  • Visual Misalignment: The cards may not be centered correctly within the SVG canvas, potentially resulting in an unbalanced visual appearance.

Tools Used

Manual Review

Recommendations

  • Check whether will truncate: ((1000 - vars.cardsWidth) / 2) % 2 == 1, in case this condition is true add +1 before the division.

Updates

Lead Judging Commences

inallhonesty Lead Judge over 1 year ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity
Assigned finding tags:

Info/Gas/Invalid as per Docs

https://docs.codehawks.com/hawks-auditors/how-to-determine-a-finding-validity

0xnevi Judge
over 1 year ago
holydevoti0n Submitter
over 1 year ago
inallhonesty Lead Judge
over 1 year ago
inallhonesty Lead Judge about 1 year ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity
Assigned finding tags:

Info/Gas/Invalid as per Docs

https://docs.codehawks.com/hawks-auditors/how-to-determine-a-finding-validity

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.