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

[WEB-4211] esbuild/dompurify vuln fixes #656

Merged
merged 4 commits into from
Feb 25, 2025
Merged

Conversation

jamiehenson
Copy link
Member

@jamiehenson jamiehenson commented Feb 21, 2025

Addresses the following vulns:

Summary by CodeRabbit

  • Chores
    • Upgraded several core dependencies—including UI, testing, build, and sanitization tools—for improved performance and stability.
  • Bug Fixes
    • Refined the handling of network request headers within the request simulation service, ensuring more reliable behavior and updated version metadata.

Copy link
Contributor

coderabbitai bot commented Feb 21, 2025

Walkthrough

This pull request updates several dependency versions in the package.json file, including multiple Storybook packages, vite, and dompurify, to their newer releases. Additionally, the public/mockServiceWorker.js file has been modified by updating the version and checksum constants and revising the request headers handling in the getResponse function, particularly the logic that manages the "accept" header.

Changes

File(s) Changes Summary
package.json Upgraded Storybook packages (@storybook/addon-a11y, @storybook/addon-essentials, etc.), storybook, vite, and dompurify to newer versions.
public/mockServiceWorker.js Updated PACKAGE_VERSION and INTEGRITY_CHECKSUM; modified header handling in getResponse by instantiating a new Headers object and refining "accept" header filtering.

Sequence Diagram(s)

sequenceDiagram
    participant C as Client
    participant SW as MockServiceWorker
    participant H as Headers Processor

    C->>SW: Send request
    SW->>SW: Clone the incoming request
    SW->>H: Instantiate new Headers from cloned request
    H-->>SW: Return headers collection
    SW->>SW: Filter "accept" header (remove "msw/passthrough" values)
    SW->>C: Return modified response
Loading

Possibly related PRs

Suggested reviewers

  • aralovelace
  • kennethkalmer

Poem

In a field of code I hop with glee,
Updating versions under a digital tree.
With headers refined and packages anew,
I nibble on bugs and errors too.
Hoppy days ahead for our bundle crew!
🐰✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a401b2b and acecf71.

⛔ Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (2)
  • package.json (3 hunks)
  • public/mockServiceWorker.js (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Run linters and tests
🔇 Additional comments (6)
public/mockServiceWorker.js (2)

11-12: Version and checksum updated to match dependency update.

The service worker version has been updated from 2.6.1 to 2.7.1, along with its integrity checksum. This matches the MSW dependency version specified in package.json (line 50).


195-214: Improved header handling for better request passthrough functionality.

The implementation has been enhanced to:

  1. Create a new Headers object instead of using Object.fromEntries
  2. Properly handle the 'accept' header by filtering out 'msw/passthrough' values
  3. Only delete the header if no values remain after filtering

This approach is more robust and provides better compatibility with CORS policies.

package.json (4)

22-29: Security update: Storybook packages upgraded to latest versions.

All Storybook-related packages have been updated from 8.5.6 to 8.6.0, with test-runner updated from 0.21.1 to 0.21.3. These updates align with the PR objectives to address security vulnerabilities.


56-56: Storybook core package updated to match addon versions.

The main storybook package has been updated to 8.6.0 to maintain version consistency with the Storybook addons.


62-62:

✅ Verification successful

Vite updated to address potential security vulnerabilities.

Vite has been updated from 6.0.0 to 6.2.0, which likely includes security patches. This aligns with the PR objectives to address the esbuild vulnerability, as esbuild is a dependency of Vite.


🌐 Web query:

What security fixes are included in Vite 6.2.0 compared to 6.0.0?

💡 Result:

Vite 6.2.0 introduces critical security enhancements compared to 6.0.0, primarily through dependency updates and vulnerability resolutions:

1. Esbuild Security Fix
The most significant security improvement is the upgrade to esbuild 0.25 (included in v6.2.0-beta) which resolves GHSA-67mh-4wv8-2f99, a vulnerability allowing code execution through malicious peer dependency installations[7][1]. This was backported from later beta releases into the stable channel.

Key Security Fixes Since 6.0.x
While not exclusive to 6.2.x, these vulnerabilities were addressed in versions between 6.0.x and latest:

  • CORS Origin Validation: Fixed improper origin validation in default CORS settings (affects <6.0.x)[4][9]
  • Information Exposure: Resolved through configuration hardening for dev server headers[4][9]
  • Access Control Bypass: Patched improper request handling in server middleware[4][9]

Other Security-Relevant Fixes
Version 6.x series introduced:

| Version | Security Enhancement |
|---------|-----------------------|
| 6.1.x   | Improved certificate validation (IPV4 address handling)[1] |
| 6.x     | Manifest file validation improvements[1] |
| All     | Regular dependency audits via automated updates[5][9] |

For projects using Vite <6.x, Snyk recommends upgrading immediately due to multiple resolved vulnerabilities including XSS risks and access control bypasses[4][9]. The current release strategy maintains security patches for:

  • Current minor (v6.x)
  • Previous major (v5.x latest minor)
  • Second-to-last major (v4.x latest minor)[8]

Citations:


Enhanced Vite Update Confirms Critical Security Fixes

The upgrade from Vite 6.0.0 to 6.2.0 now clearly includes a necessary fix for the esbuild vulnerability by updating to esbuild 0.25 (resolving GHSA-67mh-4wv8-2f99). In addition, this release benefits from additional security improvements in areas such as CORS origin validation, header hardening, and access control in server middleware—all of which help mitigate risks from older versions. This update effectively addresses the PR’s objective regarding the esbuild vulnerability.

  • File: package.json (line 62)
  • Change: "vite": "^6.2.0"
  • Impact: Confirms esbuild security fixes and additional enhancements are in place.

92-92:

✅ Verification successful

Critical security update: DOMPurify upgraded to fix vulnerabilities.

DOMPurify has been updated from 3.1.4 to 3.2.4, directly addressing one of the security vulnerabilities mentioned in the PR objectives.


🌐 Web query:

What security vulnerabilities were fixed in DOMPurify between versions 3.1.4 and 3.2.4?

💡 Result:

DOMPurify versions between 3.1.4 and 3.2.4 addressed multiple security vulnerabilities, primarily focused on preventing mutation cross-site scripting (mXSS) bypasses and improving sanitization logic:

Critical Vulnerabilities Fixed

  1. CVE-2025-26791

    • Issue: Incorrect regular expression handling for template literals allowed mXSS attacks via malicious scripts in sanitized output[1][10].
    • Fixed in: v3.2.4 with improved regex patterns[6].
  2. Conditional Sanitizer Bypasses

    • Issue: Specific configurations could allow attackers to bypass sanitization through nested HTML elements or DOM clobbering[5][6].
    • Fixed in: v3.2.3 (patches for bypasses reported by @parrot409 and @Slonser)[6].

Key Security Enhancements

  • Attribute Clobbering Protections
    Strengthened checks against DOM clobbering attacks where attributes could override sanitization logic[6].

  • Hook Handling Improvements

    • Fixed timing issues with uponSanitizeAttribute hooks that allowed unsafe attribute injection via currentNode.setAttribute[3].
    • Added type declarations (v3.2.0) to prevent misuse of hooks[6].
  • Server-Side Rendering Risks
    Mitigated bypasses when using DOMPurify with vulnerable libraries like happy-dom (CVE-2024-51757)[3].


Recommendations

  • Upgrade to v3.2.4 or later for comprehensive fixes.
  • Avoid unsafe configurations like ALLOW_UNKNOWN_PROTOCOLS: true unless strictly necessary[7].
  • Use input validation alongside DOMPurify as an additional layer[1][5].

Citations:


Action Required: Confirmed Security Fixes in DOMPurify Upgrade

  • The upgrade to DOMPurify v3.2.4 from v3.1.4 in package.json (line 92) is correctly applied.
  • This update addresses multiple critical vulnerabilities:
    • CVE-2025-26791: Fixed by improving regex patterns to prevent mXSS attacks.
    • Conditional Sanitizer Bypasses: Resolved issues related to nested HTML elements and DOM clobbering.
  • Additional enhancements include strengthened attribute clobbering protections and improved hook handling.

Given the verified security improvements, no further changes are required.

✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@jamiehenson jamiehenson marked this pull request as ready for review February 25, 2025 14:23
@jamiehenson jamiehenson added the review Deploy Storybook to ably.github.io/ably-ui label Feb 25, 2025
@jamiehenson jamiehenson requested review from aralovelace and a team February 25, 2025 14:26
@jamiehenson jamiehenson merged commit 39118b1 into main Feb 25, 2025
5 checks passed
@jamiehenson jamiehenson deleted the web-4211-vuln-fix branch February 25, 2025 17:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
review Deploy Storybook to ably.github.io/ably-ui
Development

Successfully merging this pull request may close these issues.

3 participants