Skip to content

fix: potential prototype-polluting assignment#40

Merged
ddevsr merged 1 commit into
developfrom
fix-prototype-polluting-assignment
Jun 24, 2026
Merged

fix: potential prototype-polluting assignment#40
ddevsr merged 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.

@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
…gnment

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@ddevsr ddevsr force-pushed the fix-prototype-polluting-assignment branch from 23955e9 to 0aa41f5 Compare June 24, 2026 02:37
@ddevsr ddevsr merged commit b7c22bb into develop Jun 24, 2026
8 checks passed
@ddevsr ddevsr deleted the fix-prototype-polluting-assignment branch June 24, 2026 02:49
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