Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions packages/lib/hooks/useRouterQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ function fromEntriesWithDuplicateKeys(entries: IterableIterator<[string, string]
return result;
}

// Consider setting atleast ES2015 as target
// @ts-expect-error
for (const [key, value] of entries) {
if (result.hasOwnProperty(key)) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

security-high high

Using result.hasOwnProperty(key) directly on an object can lead to runtime errors or unexpected behavior if the query parameters contain keys that match prototype properties (e.g., hasOwnProperty, toString). For example, if a query parameter is hasOwnProperty=123, result.hasOwnProperty will be overwritten, and subsequent calls to result.hasOwnProperty(key) will throw a TypeError: result.hasOwnProperty is not a function, crashing the application.

To prevent this, use Object.hasOwn(result, key) (or Object.prototype.hasOwnProperty.call(result, key)).

Additionally, please note that this function is duplicated in packages/lib/fromEntriesWithDuplicateKeys.ts. You should apply the same fix there, or ideally, refactor the code to import fromEntriesWithDuplicateKeys from a single shared location to avoid duplication.

Suggested change
if (result.hasOwnProperty(key)) {
if (Object.hasOwn(result, key)) {

let currentValue = result[key];
Expand Down
Loading