AntFleet

Disagreement · d121d4bf-anthropic-0

to_smallest_units mishandles empty integer part and signs, producing wrong on-chain amounts

mismatch
repo a16d2030·PR #4·reviewed 1 week ago

Primary finding

to_smallest_units mishandles empty integer part and signs, producing wrong on-chain amounts

highbughigh
  • symbiosis/scripts/symbiosis-quote.py:18-23
  • symbiosis/scripts/symbiosis-swap.py:22-27
If a user passes `.1` (no leading 0) the integer part is the empty string, then `int(integer + frac)` becomes `int("100000000000000000")` which works, but if integer is empty and frac is also empty (e.g. amount=".") this raises ValueError with a non-user-friendly traceback. More importantly, the function silently truncates the fractional component past `decimals` digits without any warning (e.g., 0.1234567 USDC with 6 decimals becomes 0.123456, dropping value), and it silently accepts arbitrary garbage like '1e3', '1,5', '-1', etc. A negative amount '-1' would be coerced to int('-1...') and sent to the API as a negative smallest-units string, which is then signed by the user; while the API will likely reject it, there is no input validation in the script. Combined with no docs warning, this is a real correctness/data-loss risk because the swap amount the user typed is not what gets sent.

Recommendation

Validate `amount` matches a positive decimal regex; reject negatives and non-numeric values; raise a clear error if the user provides more fractional digits than `decimals` (or at least warn). Also handle the empty-integer case explicitly.

Counterpart finding

Unlimited token allowance (MAX_UINT256) to third-party router is a security risk

mediumsecurityhigh
  • symbiosis/scripts/symbiosis-swap.py:18-19
  • symbiosis/scripts/symbiosis-swap.py:147-149
Granting unlimited allowance to a router/contract exposes the user to potential loss if that contract is compromised or its permissions change. Best practice is to approve only the exact needed amount and re-approve when necessary.

Recommendation

Approve only the exact amount required for the swap (amount_wei). Optionally revoke or reset the allowance to 0 after swap completion. Consider warning the user before granting unlimited approvals.

Why this didn't post

This finding didn't meet AntFleet's unanimous agreement threshold. Both frontier models review every PR independently; only findings they both flag with the same severity and category are posted to the PR. This one fell through.

read the methodology →

From the same review

These findings passed the unanimous gate on the same PR review. The disagreement above was filtered out; the findings below were posted.