Fix query parameter truncation with configurable limit (fixes #5878)#7117
Open
nmurrell07 wants to merge 1 commit intoexpressjs:masterfrom
Open
Fix query parameter truncation with configurable limit (fixes #5878)#7117nmurrell07 wants to merge 1 commit intoexpressjs:masterfrom
nmurrell07 wants to merge 1 commit intoexpressjs:masterfrom
Conversation
- Change default query parser from 'simple' to 'extended' - Add 'query parser limit' setting with default of 10000 - Pass limit to query parser at parse time (not compile time) - Fixes issue expressjs#5878 - query params truncated at 1000+ params - Supersedes PR expressjs#7116 which used Infinity (security concern)
krzysdz
suggested changes
Mar 21, 2026
Contributor
krzysdz
left a comment
There was a problem hiding this comment.
Some other notes:
- My understanding of #5878 is that quietly dropping params is unexpected, not necessarily a specific limit value.
- In my opinion an Express-level query parsing configuration limit should apply to all non-custom (that is
'simple'and'extended') parsers.
| this.set('etag', 'weak'); | ||
| this.set('env', env); | ||
| this.set('query parser', 'simple') | ||
| this.set('query parser', 'extended') |
Contributor
There was a problem hiding this comment.
'query parser' changed to 'simple' in Express 5 (#3621) and I don't think reverting to 'extended' is planned.
| this.set('env', env); | ||
| this.set('query parser', 'simple') | ||
| this.set('query parser', 'extended') | ||
| this.set('query parser limit', 10000) |
Contributor
There was a problem hiding this comment.
In my opinion any new limit setting should be the same as current one (1000 in this case).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR fixes issue #5878 where query parameters are silently truncated at 1000+ params due to the
qslibrary's defaultparameterLimitof 1000.Instead of setting
parameterLimit: Infinity(which was the approach in PR #7116 and could enable DoS via massive query strings), this PR:query parser limitsetting (default: 10000)app.set('query parser limit', N)qs.parse()at parse timeChanges
lib/utils.js—parseExtendedQueryStringaccepts a limit parameterlib/request.js— readsquery parser limitfrom app settingslib/application.js— sets defaultquery parser limitto 10000Supersedes
parameterLimit: Infinity)I'm fairly new to contributing to express — would appreciate any feedback on the approach! Happy to iterate.
Fixes #5878