refactor(deps): migrate @types/express from 4.17.13 to 5.0.6#5882
refactor(deps): migrate @types/express from 4.17.13 to 5.0.6#5882digital-wizard48 wants to merge 1 commit intoFlowiseAI:mainfrom
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request primarily focuses on upgrading the Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request upgrades @types/express to version 5 and adapts the code to the new, stricter type definitions for req.query. However, a critical security regression was introduced in the sanitizeMiddleware. The updated logic does not correctly sanitize nested query parameters (ParsedQs), leaving the application vulnerable to Cross-Site Scripting (XSS) attacks. Specifically, nested objects are no longer sanitized, which could lead to XSS if these parameters are rendered in the UI. A suggested fix has been provided to implement proper deep sanitization of the req.query object.
| } else if (typeof val === 'string') { | ||
| req.query[p] = sanitizeHtml(val) | ||
| } |
There was a problem hiding this comment.
The sanitizeMiddleware fails to sanitize nested objects in req.query, which can lead to Cross-Site Scripting (XSS) vulnerabilities. Express supports nested query parameters (e.g., ?filter[name]=<script>alert(1)</script>), but the current implementation only sanitizes strings, skipping objects due to the typeof val === 'string' check. This allows XSS payloads in nested query parameters to bypass the filter. The suggested change ensures that all non-undefined values are coerced to strings before sanitization, addressing this regression.
| } else if (typeof val === 'string') { | |
| req.query[p] = sanitizeHtml(val) | |
| } | |
| } else if (val !== undefined) { | |
| req.query[p] = sanitizeHtml(String(val)) | |
| } |
Changes
Dependency Update
@types/expressfrom^4.17.13to^5.0.6in rootpackage.jsonBreaking Changes Addressed
@types/expressv5 query type changes (XSS.ts)@types/expressv5,Request.queryvalues are typed asstring | ParsedQs | string[] | ParsedQs[] | undefined, which is stricter than v4sanitizeMiddlewareinpackages/server/src/utils/XSS.tsto:const val = req.query[p]to capture the value with proper typing before branchingtypeof val === 'string'guard instead of a bare castas stringto satisfy the narrowed typeString(q)for array elements to safely coerceParsedQsentries to string before sanitizingfor (let p in ...)tofor (const p in ...)as the loop variable is never reassignedCompatibility Notes
Request,Response,NextFunctionsignatures remain structurally compatible between v4 and v5 types for the patterns used in this codebasedeclare global namespace Expressaugmentation inpackages/server/src/index.tscontinues to work without changes(req, res, next) => voidare compatible with v5's updatedRequestHandlertypeThis PR was auto-generated by Gittensor upgrade bot using Claude AI