Skip to content

fix(intl-messageformat): fix value having special key like constructor, fix ##4490#5751

Closed
longlho wants to merge 1 commit intomainfrom
12-31-fix_intl-messageformat_fix_value_having_special_key_like_constructor_fix_4490
Closed

fix(intl-messageformat): fix value having special key like constructor, fix ##4490#5751
longlho wants to merge 1 commit intomainfrom
12-31-fix_intl-messageformat_fix_value_having_special_key_like_constructor_fix_4490

Conversation

@longlho
Copy link
Copy Markdown
Member

@longlho longlho commented Jan 1, 2026

TL;DR

Fixed a security vulnerability where prototype properties like "constructor" in select/plural statements could cause unexpected behavior.

What changed?

Modified the formatToParts function to use Object.prototype.hasOwnProperty.call() when accessing options in select and plural elements. This prevents potential issues when keys like "constructor", "proto", or other JavaScript object prototype properties are used as values in message formats.

How to test?

Added comprehensive test cases that verify:

  • Select statements with "constructor" as a value
  • Select statements with "proto" as a value
  • Select statements with "toString" as a value
  • Select statements with "hasOwnProperty" as a value
  • Plural rules that could potentially match prototype properties
  • Ensuring no crashes when select value is "constructor"

Why make this change?

This fixes GitHub issue #4490 where using certain property names that exist on the JavaScript object prototype (like "constructor") in select/plural statements could lead to unexpected behavior or potential security vulnerabilities. By using hasOwnProperty, we ensure that only the object's own properties are accessed, not those inherited from the prototype chain.

@longlho longlho marked this pull request as ready for review January 1, 2026 03:18
@graphite-app
Copy link
Copy Markdown

graphite-app Bot commented Jan 1, 2026

Merge activity

  • Jan 1, 3:20 AM UTC: longlho added this pull request to the Graphite merge queue.
  • Jan 1, 3:21 AM UTC: CI is running for this pull request on a draft pull request (#5752) due to your merge queue CI optimization settings.
  • Jan 1, 3:23 AM UTC: Merged by the Graphite merge queue via draft PR: #5752.

graphite-app Bot pushed a commit that referenced this pull request Jan 1, 2026
…r, fix ##4490 (#5751)

### TL;DR

Fixed a security vulnerability where prototype properties like "constructor" in select/plural statements could cause unexpected behavior.

### What changed?

Modified the `formatToParts` function to use `Object.prototype.hasOwnProperty.call()` when accessing options in select and plural elements. This prevents potential issues when keys like "constructor", "__proto__", or other JavaScript object prototype properties are used as values in message formats.

### How to test?

Added comprehensive test cases that verify:
- Select statements with "constructor" as a value
- Select statements with "__proto__" as a value
- Select statements with "toString" as a value
- Select statements with "hasOwnProperty" as a value
- Plural rules that could potentially match prototype properties
- Ensuring no crashes when select value is "constructor"

### Why make this change?

This fixes GitHub issue #4490 where using certain property names that exist on the JavaScript object prototype (like "constructor") in select/plural statements could lead to unexpected behavior or potential security vulnerabilities. By using `hasOwnProperty`, we ensure that only the object's own properties are accessed, not those inherited from the prototype chain.
@graphite-app graphite-app Bot closed this Jan 1, 2026
@graphite-app graphite-app Bot deleted the 12-31-fix_intl-messageformat_fix_value_having_special_key_like_constructor_fix_4490 branch January 1, 2026 03:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant