Proposal - Linear Time Ruling #24
Replies: 3 comments 9 replies
-
Even if not enabled by default, it should still be safe to use input from users in json logic when using e.g. sort or regex operators. Perhaps a global/per operator timeout is a better catch all approach to achieve this? Additionally, should any space limits be enforced? |
Beta Was this translation helpful? Give feedback.
-
This really feels like an implementation detail to me and shouldn't be part of the spec. What happens when an implementation can't meet this requirement due to some language/framework limitation? Do we say that that language simply cannot support JSON Logic, even though the processing works, just more slowly? |
Beta Was this translation helpful? Give feedback.
-
Current Votes
|
Beta Was this translation helpful? Give feedback.
-
Background
While we work to identify our error-handling strategy (which affects several proposals), I’d like to propose a restriction on recognized/default JSON Logic operators to strengthen the computational guarantees of the standard.
JSON Logic advertises the following:
This is a solid guarantee, but I believe we can provide a stronger one: "Linear Computation Time."
Fortunately, the operators defined by JSON Logic already appear to adhere to this guarantee.
I truly do not expect this to significantly change our course on anything we plan to do for Core, but might help explain JSON Logic's out of the box goals.
Proposal
I propose the following:
Additionally:
This is not an implementation mandate, as it would be fairly difficult to ensure that with tests alone. This is a guideline for TC and Community members to help with default operator selection.
Assumptions
Motivation
JSON Logic advertises itself as a safe way to serialize and execute "logic" or "rules," even when the rules come from an untrusted source.
By imposing a restriction on default operators, we mitigate potential denial-of-service attacks and ensure consistent, predictable performance.
While developers are free to extend JSON Logic for their specific use cases (e.g., making JSON Logic Turing complete by adding
while
), I believe any default operators should adhere to the stronger guarantee of linear computation time.Beta Was this translation helpful? Give feedback.
All reactions