fix: prevent silent truncation of query parameters#7009
fix: prevent silent truncation of query parameters#7009jonathan-fulton wants to merge 1 commit intoexpressjs:masterfrom
Conversation
Set parameterLimit to Infinity in the extended query parser to prevent silent truncation of query parameters when exceeding the qs library's default limit of 1000. Previously, query strings with more than 1000 parameters would be silently truncated, potentially causing data loss and hard-to-debug issues. Now all parameters are parsed by default. Users who need a limit for security can provide a custom query parser function. Fixes expressjs#5878
|
this is a documented behavior. Is it a good idea? Suppose a malicious actor can send big body trying to DoS your application. |
|
@danizavtz Thanks for raising this concern - it's an important consideration! To clarify the intent of this PR: What this PR does:
What this PR does NOT do:
Regarding DoS concerns: If there's a preference for making the behavior configurable (e.g.,
Would that address your concern? Happy to iterate on the approach! |
Summary
The
qslibrary used by Express has a defaultparameterLimitof 1000, which silently truncates query parameters beyond this limit. This can lead to subtle data loss bugs that are extremely difficult to diagnose, as there's no warning when parameters are dropped.Solution
Set
parameterLimit: Infinityin the extended query string parser. Users who need a limit for security reasons can provide a custom query parser.This aligns with the principle of least surprise - it's better to process all parameters by default and let users explicitly opt into limits, rather than silently dropping data.
Before:
Query string with 1500 parameters silently returns only 1000.
After:
All 1500 parameters are parsed correctly.
Changes
lib/utils.jsto setparameterLimit: InfinityFixes #5878