Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Potential attack via asymmetric encoding. #10

Open
simon-greatrix opened this issue Sep 29, 2020 · 0 comments
Open

Potential attack via asymmetric encoding. #10

simon-greatrix opened this issue Sep 29, 2020 · 0 comments

Comments

@simon-greatrix
Copy link

A server using canonical JSON could be attacked by submitting a JSON object such as:

{
   "int" : 1e1000000000
}

This would be expanded to occupy a gigabyte of memory as the integer is rendered into canonical form. The ability to place a very high load on the server's memory for very small messages can easily be used to cause a denial of service attack.

To rectify this, I suggest that the canonical form for integers be changed to specify a maximum number of trailing zeros. I suggest two possible rules:

  1. Put all integers into their most compact representation. If an integer has 3 or more trailing zeros, it should have an exponential component, so "1000" becomes "1e3". This provides a consistent representation for all integers and completely blocks the attack.

or

  1. Put all integers with 20 or more trailing zeros into exponential form. A number with 21 or more total digits cannot be expressed in 64 bits so exceeds the precision of common integer representations. This still permits the expansion of "1e19" but that is only a five fold increase in size. I think this provides a reasonable limit on the use of trailing zeros which would affect a very small number of existing documents.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant