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

MAX_LIMIT can be bypassed with params.limit = NaN #308

Open
SeanLMcCullough opened this issue Aug 26, 2021 · 0 comments
Open

MAX_LIMIT can be bypassed with params.limit = NaN #308

SeanLMcCullough opened this issue Aug 26, 2021 · 0 comments

Comments

@SeanLMcCullough
Copy link

Tested using the Mongoose Plugin.

The test: if (params.limit > config.MAX_LIMIT) params.limit = config.MAX_LIMIT; can be bypassed if a programming error or edge case exists resulting in params.limit = NaN.

An example is when parsing a query param using params.limit = parseInt(ctx.query.limit, 10).

In this case, params.limit will remain as NaN because NaN > 300 === false.

MongoDB will treat that as an infinite limit and fetch all documents, bypassing the limit value.

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