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

Maximum query string length #64

Open
elpiel opened this issue Jun 21, 2022 · 2 comments
Open

Maximum query string length #64

elpiel opened this issue Jun 21, 2022 · 2 comments

Comments

@elpiel
Copy link

elpiel commented Jun 21, 2022

Working on a web server I've realized that hyper nor serde_qs have an option for a maximum query string length.
It would be nice to add such an additional option to the Config of serde_qs rather than implementing custom validation for each place that uses serde_qs to deserialize query strings.

What is your opinion on this?

@samscott89
Copy link
Owner

Hey @elpiel.

That sounds like a mostly reasonable idea. For example, we already support having a "depth" limit, which controls how deeply we'll attempt to construct maps.

Out of curiosity, what's the use case? I could maybe see that as a simple protection against denial of service attacks (I'm imagining someone submitting q[][][][][][][]....<many many more>[][][][][]=1 for example.

On the other hand, this feels like it would be growing the scope of serde_qs beyond what I'd reasonable want to support. I think it would be easier to write that as a middleware in whatever web framework you are using.

@elpiel
Copy link
Author

elpiel commented Jul 10, 2022

Out of curiosity, what's the use case? I could maybe see that as a simple protection against denial of service attacks...

Yes, that's actually our use case. Since we don't use a framework (just hyper) I don't want to always check the string length before deserializing.

There's already a Config with a few options and I thought it's a good place to add the maximum string length too.

Ps: although there is no limit in the RFC, browsers and servers usually have a set limit according to: https://stackoverflow.com/a/812962/2509411

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

2 participants