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

Bypass validation by specifing same parameter multiple times #1065

Closed
ghost opened this issue Jul 15, 2021 · 1 comment
Closed

Bypass validation by specifing same parameter multiple times #1065

ghost opened this issue Jul 15, 2021 · 1 comment

Comments

@ghost
Copy link

ghost commented Jul 15, 2021

Describe the bug

If you specify a query-parameter multiple times, you can bypass the validation. Not tested for other locations

To Reproduce

  1. Use simple validation as shown below
    app.get('/',[query("test").isAlphanumeric()], (req,res,next) => { validationResult(req).throw() //something })

  2. http://localhost:8000/?test=A&test=!! --> passes

Expected behavior

Validation should fail, since express handles stuff like this as array.
Should check every value of given array.
--> { test: [ 'A', '!!' ] }

Current behavior

Validation passes

Express-validator version:

  • Version: 6.12.0
@fedeci
Copy link
Member

fedeci commented Jul 18, 2021

It is a known issue, it will be fixed in v7 (#1002).
For the moment if you expect test to be an array you should use wildcards like

query('test.*').isAlphanumeric()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant