Skip to content

Potential fix for code scanning alert no. 3: Prototype-polluting function#23

Open
tonyrobots wants to merge 1 commit intomainfrom
alert-autofix-3
Open

Potential fix for code scanning alert no. 3: Prototype-polluting function#23
tonyrobots wants to merge 1 commit intomainfrom
alert-autofix-3

Conversation

@tonyrobots
Copy link
Copy Markdown
Owner

Potential fix for https://github.com/tonyrobots/dcc-qol/security/code-scanning/3

The safest minimal fix is to block prototype-pollution keys ("__proto__", "constructor", and "prototype") early in the merge loop, before any use of original[k], recursion, deletion, or assignment. This preserves existing behavior for normal keys while preventing writes/traversal into prototype chains.

In scripts/__mocks__/foundry.js, inside global.foundry.utils.mergeObject, update the loop that iterates Object.entries(other):

  • After handling -= prefix normalization, add a guard:
    • if (k === "__proto__" || k === "constructor" || k === "prototype") continue;
      This ensures dangerous keys are ignored in both top-level and recursive merges without changing other merge semantics.

No new imports or dependencies are required.

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

…tion

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@tonyrobots tonyrobots marked this pull request as ready for review April 14, 2026 16:47
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