Skip to content

[Bug]: Prototype Pollution via Exported G2.renderToMountedElement Options #3163

@Dremig

Description

@Dremig

Describe the bug / 问题描述

@ant-design/plots@2.6.8 exposes @antv/g2 as the G2 namespace from the package root entry. The public G2.renderToMountedElement API can be reached through this root export.

When renderToMountedElement receives an options object, it calls inferKeys(options) before the mounted-element validation fails. inferKeys(options) performs a deep merge through @antv/util.deepMix({}, options). The merge operation does not filter prototype-pollution primitives such as __proto__, allowing attacker-controlled options to write properties onto Object.prototype.

Reproduction link / 复现链接

No response

Steps to Reproduce the Bug or Issue / 重现步骤

Proof of Concept

const { G2 } = require('@ant-design/plots');

delete Object.prototype.polluted;

try {
  G2.renderToMountedElement(
    JSON.parse('{"__proto__":{"polluted":"yes"}}')
  );
} catch (e) {
  // renderToMountedElement may throw later because no valid mounted element is provided.
  // The prototype pollution happens before that validation error.
}

console.log(({}).polluted);

Actual Result

yes

Expected Result

The options-processing path should not modify Object.prototype.

undefined

Version / 版本

Please select / 请选择

OS / 操作系统

  • macOS
  • Windows
  • Linux
  • Others / 其他

Browser / 浏览器

  • Chrome
  • Edge
  • Firefox
  • Safari (Limited support / 有限支持)
  • IE (Nonsupport / 不支持)
  • Others / 其他

Metadata

Metadata

Assignees

No one assigned

    Labels

    waiting for maintainerTriage or intervention needed from a maintainer

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions