You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This behaviour is incorrect. Requirement for amounts to have at max 7 decimal places comes from the way stellar-core keeps amount values internally (int64 in stroops which is 10-7 XLM). There is no such limitation on string representation of the price.
The regexp check appeared in the code around the time when we received security report about possible DoS vector when parsing amounts using amount.Parse function. The argument value was passed directly to big.Rat.SetString which can start extensive calculations on values like 1E9223372036854775807 (note: E). This behaviour was incorrectly incorporated into price.Parse because it's using big.Rat.SetString internally too.
When fixing this issue we should remember about this DoS vector. Specifically, we should check what's the maximum number of decimal places we can allow to ensure low CPU usage.
The text was updated successfully, but these errors were encountered:
I encounter to different problem related to "price.parse".
I cannot enter more than MAX_INT (2,147,483,647) like 3 trillion as price value in buy/sell offer (it is common on offers between BTC and weak currencies). i believe it may be possible to have the (922337203685.4775807) as the top limit price value.
What version are you using?
master
What did you do?
price.Parse
is usingprice.continuedFraction
internally. It checks if the given price is a valid Stellar amount using regexp:go/price/main.go
Lines 20 to 26 in 04ac85c
go/price/main.go
Lines 41 to 47 in 04ac85c
This behaviour is incorrect. Requirement for amounts to have at max 7 decimal places comes from the way stellar-core keeps amount values internally (
int64
in stroops which is 10-7 XLM). There is no such limitation on string representation of the price.The regexp check appeared in the code around the time when we received security report about possible DoS vector when parsing amounts using
amount.Parse
function. The argument value was passed directly tobig.Rat.SetString
which can start extensive calculations on values like1E9223372036854775807
(note:E
). This behaviour was incorrectly incorporated intoprice.Parse
because it's usingbig.Rat.SetString
internally too.When fixing this issue we should remember about this DoS vector. Specifically, we should check what's the maximum number of decimal places we can allow to ensure low CPU usage.
The text was updated successfully, but these errors were encountered: