Resource exhaustion threats require explicit bounded budgets. Three attack vectors need defense: arbitrarily deep nesting exhausts parser stack or memory, extremely large payloads exhaust available memory, and adversarial input triggers pathological regular expression backtracking that consumes unbounded CPU time. Each requires a hard limit that causes the filter to reject sharing the payload while allowing the primary task to continue with local processing.
Depth budget: enforce maximum nesting level during parse. Reject payloads exceeding the limit before building the full tree. The bound must account for legitimate nested structures while preventing stack exhaustion.
Byte budget: enforce maximum total size before parsing begins. Check the serialized input size and reject oversized payloads immediately. This prevents memory exhaustion from allocation before any validation occurs.
Work budget: enforce maximum validation cost using a shared counter decremented during tree traversal and pattern matching. Each node visit, each string examined, and each regex engine step consumes from one fuel tank. When the budget exhausts mid-validation, the decision must fail closed by rejecting the entire payload for sharing, never passing a partially validated prefix.
Regex backtracking defense requires either a timeout mechanism or conversion to a deterministic automaton that guarantees linear time complexity. The timeout approach needs careful coordination with the work budget to ensure consistent fail-closed behavior.
Category warnings on rejection stay bounded by reporting only which limit was exceeded, never the depth reached, byte count, or content shape. The diagnostic identifies the budget type without measurements that leak payload characteristics.