You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Node-RED 5.0.6 : regression in JSONata $moment #5924
JSONata have made a breaking change to address a security issue. The fix for that issue is impacting precisely this use of JSONata in Node-RED.
We are stuck between a rock (continuing shipping an older JSONata with documented Critical CVEs that block adoption) and a hard-place (take the CVE fix that changes behaviour).
The CVE is regarding expressions being able to execute arbitrary code; but nothing that a Node-RED flow couldn't do for itself. I appreciate that's not really a defence, and it's good for JSONata to plug these gaps - its just a gap we relied on and we're currently left without a good solution.
Would this be correct to say that "a few extra niceties" added by Node-RED on top of the JSONata core (for example $moment()) were possible because of the aforementioned "gap"? Or is the blast radius much wider than embedding an extra function/library?
In other words, if Node-RED continued keeping up with JSONata (meaning, also accepting its breaking change as the new standard), how much of a breakage to Node-RED would this be, actually?
I would be missing $moment, of course, but somehow we managed without it before it was injected into JSONata. What else would be gone if Node-RED accepted breaking changes?
The embedding/extended things you link to is exactly how we are able to add the $moment function in the first place.
What has changed is what properties of an Object JSONata will now let you access in an expression. If you're dealing with a pure JSON compatible 'thing', then nothing has changed. But when dealing with richer objects from JavaScript, the change impacts what you can access on those objects.
The expression $moment() still works - it returns an instance of the Moment class. But $moment().hours() does not because JSONata will no longer access properties of that Moment class object. You could pass the result of $moment() to a Function node to call hours() on it - at which point, you may as well just use a Function node to do the whole thing.
The main problem will be the blast radius is going to be unpredictable for end users who don't know about the distinction between pure JSON things, and JavaScript things.
@hardillb that is the most pragmatic solution in my opinion. There is a precedent for having a way to specify custom options to the engine in their 2.2.0 release - jsonata-js/jsonata#795
You could pass the result of $moment() to a Function node to call hours() on it
at which point, you may as well just use a Function node to do the whole thing
That's what I have been doing with more complex logic that would require replacing multiple simple switch/change nodes.
But JSONata has always been that "sweet spot" that would allow staying in the pure "basic nodes" domain.
I'd often even force myself to use JSONata just to avoid putting the entire flow into a single JavaScript function node.
Because what's the point of Node-RED then, right? :)
Obviously, JSONata's true power and purpose lie in its JSON querying / transformation abilities, which JavaScript lacks.
But somehow, we ended up using it for "all other purposes" ("all the wrong purposes"?), because it is embeddable in simple nodes, and adding $moment() is the best proof of that use.
Now we are paying the price for "bending the original language purpose". Fun times.
I've found these discussions, perhaps now seen in a slightly different light...
If a flag is possible then I would short term vote for that, with default new secure behaviour, which though breaking users would force them to accept/acknowledge vulnerability via the flag, but also to announce deprecation and move away from jsonata as per forum discussion re javascript.
Activity
[-]Node-RED 5.0.6[/-][+]Node-RED 5.0.6 : regression in JSONata $moment[/+]knolleary commentedon Sep 4, 2026
JSONata have made a breaking change to address a security issue. The fix for that issue is impacting precisely this use of JSONata in Node-RED.
We are stuck between a rock (continuing shipping an older JSONata with documented Critical CVEs that block adoption) and a hard-place (take the CVE fix that changes behaviour).
The CVE is regarding expressions being able to execute arbitrary code; but nothing that a Node-RED flow couldn't do for itself. I appreciate that's not really a defence, and it's good for JSONata to plug these gaps - its just a gap we relied on and we're currently left without a good solution.
jsonata-js/jsonata#811
uncle-fed commentedon Sep 4, 2026
Would this be correct to say that "a few extra niceties" added by Node-RED on top of the JSONata core (for example
$moment()) were possible because of the aforementioned "gap"? Or is the blast radius much wider than embedding an extra function/library?In other words, if Node-RED continued keeping up with JSONata (meaning, also accepting its breaking change as the new standard), how much of a breakage to Node-RED would this be, actually?
I would be missing $moment, of course, but somehow we managed without it before it was injected into JSONata. What else would be gone if Node-RED accepted breaking changes?
Also, what about this: https://docs.jsonata.org/embedding-extending ?
knolleary commentedon Sep 4, 2026
@uncle-fed it's a little more subtle.
The embedding/extended things you link to is exactly how we are able to add the
$momentfunction in the first place.What has changed is what properties of an Object JSONata will now let you access in an expression. If you're dealing with a pure JSON compatible 'thing', then nothing has changed. But when dealing with richer objects from JavaScript, the change impacts what you can access on those objects.
The expression
$moment()still works - it returns an instance of theMomentclass. But$moment().hours()does not because JSONata will no longer access properties of thatMomentclass object. You could pass the result of$moment()to a Function node to callhours()on it - at which point, you may as well just use a Function node to do the whole thing.The main problem will be the blast radius is going to be unpredictable for end users who don't know about the distinction between pure JSON things, and JavaScript things.
hardillb commentedon Sep 4, 2026
I wonder if we can suggest a flag to re-enable the old behaviour?
knolleary commentedon Sep 4, 2026
@hardillb that is the most pragmatic solution in my opinion. There is a precedent for having a way to specify custom options to the engine in their 2.2.0 release - jsonata-js/jsonata#795
uncle-fed commentedon Sep 4, 2026
@knolleary
That's what I have been doing with more complex logic that would require replacing multiple simple switch/change nodes.
But JSONata has always been that "sweet spot" that would allow staying in the pure "basic nodes" domain.
I'd often even force myself to use JSONata just to avoid putting the entire flow into a single JavaScript function node.
Because what's the point of Node-RED then, right? :)
Obviously, JSONata's true power and purpose lie in its JSON querying / transformation abilities, which JavaScript lacks.
But somehow, we ended up using it for "all other purposes" ("all the wrong purposes"?), because it is embeddable in simple nodes, and adding
$moment()is the best proof of that use.Now we are paying the price for "bending the original language purpose". Fun times.
I've found these discussions, perhaps now seen in a slightly different light...
https://discourse.nodered.org/t/change-node-enhancement-idea-add-javascript-function-as-a-change-option/67796
https://discourse.nodered.org/t/feature-request-allow-one-liner-javascript-as-well-as-jsonata/82825/40
I actually agree with you on all points that question / object the proposals.
But mind wonders... so I guess the ideal solution is yet to come :-)
uncle-fed commentedon Sep 4, 2026
@knolleary
Found these projects, wonder if ...
knolleary commentedon Sep 4, 2026
@uncle-fed thanks for the links. Bonsai look super interesting.
dceejay commentedon Sep 5, 2026
If a flag is possible then I would short term vote for that, with default new secure behaviour, which though breaking users would force them to accept/acknowledge vulnerability via the flag, but also to announce deprecation and move away from jsonata as per forum discussion re javascript.
knolleary commentedon Sep 8, 2026
We're going to patch JSONata in our next release to fix this.
knolleary commentedon Sep 8, 2026
Node-RED 5.0.7 is now available -
$moment().hour()confirmed to be working again.