Details
curl -i 'https://target.example/en/profile?role=toString'
HTTP/1.1 500 Internal Server Error
Impact
- Availability: An unauthenticated attacker can force a 500 response on any page or API route that formats a
selectICU message using user-controllable input. Each request fails independently; there is no persistent state corruption or amplification beyond the malicious request. - Confidentiality / Integrity: None. No data is leaked and no prototype write occurs — this is a prototype-chain *read* confusion, not a prototype pollution write.
- Scope: Any consumer of
icu-minifythat passes user input into aselectbranch is vulnerable.next-intlusers are only exposed if they have opted into the experimentalexperimental.messages.precompileflag. - Preconditions: Developer must forward untrusted input to a
{arg, select, …}placeholder. This is a routine pattern (role,status,gender,type) and the library offers no documentation warning thatselectkeys must be validated against prototype members.
Recommended Fix
Either of the following (defense-in-depth suggests both). Both are one-line, minimal-churn fixes.
- Use a null-prototype map in
compileSelect(and symmetrically incompilePlural) so that noObject.prototypekeys can ever be resolved:
// packages/icu-minify/src/compile.tsx
function compileSelect(node: SelectElement): CompiledNode {
- const options: SelectOptions = {};
+ const options: SelectOptions = Object.create(null);
for (const [key, option] of Object.entries(node.options)) {
options[key] = compileNodesToNode(option.value);
}
return [node.value, TYPE_SELECT, options];
}
- Gate the runtime lookup with
Object.prototype.hasOwnProperty.callso theotherfallback is reached for any non-own key:
// packages/icu-minify/src/format.tsx
function formatSelect<RichTextElement>(/* … */) {
const value = String(getValue(values, name));
- const branch: CompiledNode | undefined = options[value] ?? options.other;
+ const branch: CompiledNode | undefined =
+ Object.prototype.hasOwnProperty.call(options, value) ? options[value] : options.other;
/* … */
}
Option 1 is preferable because it also survives future serialization round-trips (e.g. JSON-hydrated compiled messages) and removes the hazard at the source. Option 2 is a defensive backstop for any code path that constructs SelectOptions from arbitrary JSON at runtime.
No regression is expected in tests — compileSelect never reads back through the prototype chain, and all existing lookups use own properties.