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

serde_json::error:: RecursionLimitExceeded exists #507

Open
ShadowJonathan opened this issue Apr 14, 2021 · 5 comments
Open

serde_json::error:: RecursionLimitExceeded exists #507

ShadowJonathan opened this issue Apr 14, 2021 · 5 comments
Labels
area/serde blocked not currently actionable effort/hard

Comments

@ShadowJonathan
Copy link
Member

At https://github.com/serde-rs/json/blob/7ca63e7d5acac348db55c4345cb199f9d658669f/src/error.rs#L240-L241;

    /// Encountered nesting of JSON maps and arrays more than 128 layers deep.
    RecursionLimitExceeded,

I feel this is possible to encounter in the wild in matrix, unintentional or not, so ruma should be able to handle this sorta thing, i'd guess.

@jplatte
Copy link
Member

jplatte commented Apr 14, 2021

I don't really know what we could do about this 😕

@jplatte
Copy link
Member

jplatte commented May 8, 2021

I wonder whether Synapse / the Python lib it uses has similar limitations. One could try creating a test room and posting a custom event with a content like { "foo": [[[[[[[[[[[[<500 more pairs of brackets>]]]]]]]]]]]] }.

@jplatte
Copy link
Member

jplatte commented May 27, 2021

serde_json has a feature flag called unbounded_depth that can be used to disable this limitation, but at least for homeservers that would open a super simple DOS attack vector.

@ShadowJonathan
Copy link
Member Author

Maybe we can provide the same feature flag as well? And then add it to any crate that uses serde, it'll be off by default, though for any homeserver or application that needs to enable it, it's there.

@lieuwex
Copy link
Contributor

lieuwex commented Jun 4, 2021

ref: serde-rs/json#613

Noteworthy is the reference to https://source.chromium.org/gn/gn/+/master:src/base/json/json_reader.cc;l=18?q=kStackMaxDepth, which would at least be applicable for the CS API.

@jplatte jplatte added area/serde blocked not currently actionable labels Apr 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/serde blocked not currently actionable effort/hard
Development

No branches or pull requests

3 participants