#874·JsonPath

Regex evaluation can block the current thread indefinitely

Author: ixilerCreated Nov 25, 2022Updated Sep 15, 2026

Hello,

What is the problem:

The current implementation of regex in EvaluatiorFactory.RegexpEvaluator and ValueNodes.PatternNode uses the standard Java implementation that is not interruptible and given a long running regex blocks the thread indefinitely. We do not have control over the input to the library, as it is exposed to customers and there isn't a deterministic way to find out malicious paths passed from users to our application.

What is the desired behaviour:

When executing a JsonPath to be able to pass a timeout after which if the path execution hasn't yielded a result the execution throws an exception.

Minimal required desired behaviour:

Make the pattern implementation interruptible. Or give control over the implementation so the library users can implement the Evaluators as they need.

Possible approach

This issue is described with a possible approach here. The proposed approach there has a performance impact so it can be exposed as a configuration for the user if he wants to use it or not.

What we tried so far

We tried to configure/extend/modify the behaviour of the library so that this becomes interruptible, but all the standard channels to do so seemed blocked by the design.