Skip to content

fix: reject deltas with invalid values entries#2460

Open
dirkwa wants to merge 1 commit intoSignalK:masterfrom
dirkwa:fix-null-values-crash
Open

fix: reject deltas with invalid values entries#2460
dirkwa wants to merge 1 commit intoSignalK:masterfrom
dirkwa:fix-null-values-crash

Conversation

@dirkwa
Copy link
Contributor

@dirkwa dirkwa commented Mar 16, 2026

Fixes #1708
Fixes #1473

Summary

Malformed deltas with null entries or pathvalues with missing/null path in the values array crash shouldAllowWrite() with "Cannot read properties of null". The entire delta is rejected as invalid rather than filtering individual bad values, keeping per-delta processing overhead minimal.

Validation covers all entry points:

  • handleMessage in index.ts — rejects before any processing (source assignment, timestamps, delta chain), covers WS, plugins, and providers
  • shouldAllowWrite in tokensecurity.ts — prevents crash in the WS security check that runs before handleMessage

Tested manually against server by sending deltas over WebSocket:

  • null entry in values array → entire delta rejected, warning logged
  • Pathvalue with missing path ({value: 3.14}) → rejected
  • Pathvalue with path: null → rejected
  • Valid delta → processed normally, value stored in data model

Server console output confirmed three rejection warnings followed by successful GET of the valid value.

@dirkwa dirkwa changed the title fix(ws): filter null values from WebSocket deltas fix(ws): filter invalid values from WebSocket deltas Mar 17, 2026
@tkurki
Copy link
Member

tkurki commented Mar 17, 2026

This does not fix #1473 as is ws specific.

Would a better fix be to make security deny malformed deltas?

I am not terribly crazy about adding the filter step to each and every delta. we could just ignore the whole delta as invalid if there is bad data. Processing overhead would be a bit less. It would affect only a very miniscule portion of data, as the vast majority is good.

@dirkwa dirkwa force-pushed the fix-null-values-crash branch from ec0dc94 to 4676c7e Compare March 17, 2026 05:15
@dirkwa dirkwa changed the title fix(ws): filter invalid values from WebSocket deltas fix: reject deltas with invalid values entries Mar 17, 2026
@dirkwa
Copy link
Contributor Author

dirkwa commented Mar 17, 2026

Thanks for the quick feedback. All topics addressed.

Malformed deltas with null entries or missing/null path in the values
array caused shouldAllowWrite() to crash with "Cannot read properties
of null". The entire delta is now rejected as invalid rather than
filtering individual bad values, minimizing per-delta overhead.

Validation is added in two places:
- handleMessage (covers all entry points: WS, plugins, providers)
- shouldAllowWrite (prevents crash before handleMessage in WS path)

Fixes SignalK#1708, closes SignalK#1473
@dirkwa dirkwa force-pushed the fix-null-values-crash branch from 4676c7e to 3eace22 Compare March 17, 2026 20:29
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.

Tokensecurity error on reading properties Block deltas with null or missing path

2 participants