Skip to content

fix(store): harden lookup maps against prototype pollution#2447

Draft
arturovt wants to merge 1 commit into
masterfrom
fix/store_object.hasOwn
Draft

fix(store): harden lookup maps against prototype pollution#2447
arturovt wants to merge 1 commit into
masterfrom
fix/store_object.hasOwn

Conversation

@arturovt
Copy link
Copy Markdown
Member

@arturovt arturovt commented Jun 2, 2026

Objects used as string-keyed dictionaries were initialized with {}, inheriting Object.prototype. A key matching an inherited property (e.g. constructor, hasOwnProperty) would return a truthy prototype value instead of undefined, causing silent mismatches in lookups.

  • Replace {} with Object.create(null) in all plain map initializations: state name/path maps in StateFactory, buildGraph, nameToState, findFullParentPath, topologicalSort, the actions metadata map, and the FilterMap seeds in ofAction operators
  • Replace ɵhasOwnProperty helper with Object.hasOwn(), which is safe on null-prototype objects and removes the indirection

Objects used as string-keyed dictionaries were initialized with `{}`,
inheriting Object.prototype. A key matching an inherited property
(e.g. `constructor`, `hasOwnProperty`) would return a truthy prototype
value instead of undefined, causing silent mismatches in lookups.

- Replace `{}` with Object.create(null) in all plain map initializations:
  state name/path maps in StateFactory, buildGraph, nameToState,
  findFullParentPath, topologicalSort, the actions metadata map,
  and the FilterMap seeds in ofAction operators
- Replace ɵhasOwnProperty helper with Object.hasOwn(), which is safe
  on null-prototype objects and removes the indirection
@nx-cloud
Copy link
Copy Markdown

nx-cloud Bot commented Jun 2, 2026

🤖 Nx Cloud AI Fix Eligible

An automatically generated fix could have helped fix failing tasks for this run, but Self-healing CI is disabled for this workspace. Visit workspace settings to enable it and get automatic fixes in future runs.

To disable these notifications, a workspace admin can disable them in workspace settings.


View your CI Pipeline Execution ↗ for commit e618379

Command Status Duration Result
nx run-many --target=test --all --configuration... ❌ Failed 2m 29s View ↗
nx run-many --target=lint --all --exclude=creat... ✅ Succeeded 9s View ↗
nx lint-types store ✅ Succeeded <1s View ↗
nx run-many --target=build --all ✅ Succeeded 1m 48s View ↗

☁️ Nx Cloud last updated this comment at 2026-06-02 19:50:38 UTC

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Jun 2, 2026

Open in StackBlitz

@ngxs/devtools-plugin

npm i https://pkg.pr.new/@ngxs/devtools-plugin@2447

@ngxs/form-plugin

npm i https://pkg.pr.new/@ngxs/form-plugin@2447

@ngxs/hmr-plugin

npm i https://pkg.pr.new/@ngxs/hmr-plugin@2447

@ngxs/router-plugin

npm i https://pkg.pr.new/@ngxs/router-plugin@2447

@ngxs/storage-plugin

npm i https://pkg.pr.new/@ngxs/storage-plugin@2447

@ngxs/store

npm i https://pkg.pr.new/@ngxs/store@2447

@ngxs/websocket-plugin

npm i https://pkg.pr.new/@ngxs/websocket-plugin@2447

commit: e618379

@bundlemon
Copy link
Copy Markdown

bundlemon Bot commented Jun 2, 2026

BundleMon

Files updated (2)
Status Path Size Limits
fesm2022/ngxs-store.mjs
116.42KB (-43B -0.04%) 114KB / +0.5%
fesm2022/ngxs-store-internals.mjs
12.56KB (-158B -1.21%) 15KB / +0.5%
Unchanged files (4)
Status Path Size Limits
fesm2022/ngxs-store-operators.mjs
15.7KB 16KB / +0.5%
fesm2022/ngxs-store-internals-testing.mjs
10.32KB 13KB / +0.5%
fesm2022/ngxs-store-plugins.mjs
2.37KB 3KB / +0.5%
fesm2022/ngxs-store-experimental.mjs
574B 2KB / +0.5%

Total files change -201B -0.12%

Groups updated (1)
Status Path Size Limits
@ngxs/store(fesm2022)[gzip]
./fesm2022/*.mjs
39.47KB (-43B -0.11%) +1%

Final result: ❌

View report in BundleMon website ➡️


Current branch size history | Target branch size history

@bundlemon
Copy link
Copy Markdown

bundlemon Bot commented Jun 2, 2026

BundleMon (NGXS Plugins)

Files updated (1)
Status Path Size Limits
Plugins(fesm2022)[gzip]
storage-plugin/fesm2022/ngxs-storage-plugin.m
js
4.16KB (-11B -0.26%) +0.5%
Unchanged files (8)
Status Path Size Limits
Plugins(fesm2022)[gzip]
router-plugin/fesm2022/ngxs-router-plugin.mjs
3.43KB +0.5%
Plugins(fesm2022)[gzip]
hmr-plugin/fesm2022/ngxs-hmr-plugin.mjs
2.78KB +0.5%
Plugins(fesm2022)[gzip]
websocket-plugin/fesm2022/ngxs-websocket-plug
in.mjs
2.61KB +0.5%
Plugins(fesm2022)[gzip]
form-plugin/fesm2022/ngxs-form-plugin.mjs
2.51KB +0.5%
Plugins(fesm2022)[gzip]
devtools-plugin/fesm2022/ngxs-devtools-plugin
.mjs
2.26KB +0.5%
Plugins(fesm2022)[gzip]
logger-plugin/fesm2022/ngxs-logger-plugin.mjs
2.07KB +0.5%
Plugins(fesm2022)[gzip]
storage-plugin/fesm2022/ngxs-storage-plugin-i
nternals.mjs
1007B +0.5%
Plugins(fesm2022)[gzip]
router-plugin/fesm2022/ngxs-router-plugin-int
ernals.mjs
453B +0.5%

Total files change -8B -0.04%

Unchanged groups (1)
Status Path Size Limits
All Plugins(fesm2022)[gzip]
./-plugin/fesm2022/.mjs
21.24KB +0.5%

Final result: ✅

View report in BundleMon website ➡️


Current branch size history | Target branch size history

@bundlemon
Copy link
Copy Markdown

bundlemon Bot commented Jun 2, 2026

BundleMon (Integration Projects)

Files updated (1)
Status Path Size Limits
Main bundles(Gzip)
hello-world-ng21/dist-integration/browser/mai
n-(hash).js
67.97KB (-20B -0.03%) +1%

Total files change -20B -0.03%

Final result: ✅

View report in BundleMon website ➡️


Current branch size history | Target branch size history

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