Skip to content

fix: potential prototype-polluting assignment#40

Open
ddevsr wants to merge 1 commit into
developfrom
fix-prototype-polluting-assignment
Open

fix: potential prototype-polluting assignment#40
ddevsr wants to merge 1 commit into
developfrom
fix-prototype-polluting-assignment

Conversation

@ddevsr

@ddevsr ddevsr commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Potential fix for https://github.com/PHPDevsr/js-validation/security/code-scanning/1

The safest minimal fix (without changing external functionality) is to harden the dictionary-like containers and reject dangerous keys:

  1. Store methods, locales, and per-language locale maps as prototype-less objects using Object.create(null), so special keys do not resolve through Object.prototype.
  2. Validate incoming keys (lang and method name) and reject __proto__, constructor, and prototype.
  3. When merging locale messages, iterate keys and copy only safe own properties (also rejecting dangerous message keys) instead of blindly Object.assign into a potentially sensitive object.

In src/core.js, update:

  • static field initializers for methods and locales
  • addLocaleMessages(...) to validate lang, initialize safe map, and copy safe keys
  • addMethod(...) to validate name before assignment

No new imports or dependencies are needed.

Suggested fixes powered by Copilot Autofix. Review carefully before merging.

…gnment

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@ddevsr ddevsr changed the title Potential fix for code scanning alert no. 1: Prototype-polluting assignment fix: potential prototype-polluting assignment Jun 18, 2026
@ddevsr ddevsr marked this pull request as ready for review June 18, 2026 03:54
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