Summary
PR #705 adds compiled-size limits to all regex.* builtins via compile_regex_for_builtin(). However, two other code paths accept user-controlled regex patterns without enforcing the same limit:
1. json.match_schema / json.verify_schema
- Path:
src/builtins/objects.rs → compile_json_schema → jsonschema::validator_for
- Issue: JSON Schema
"pattern" keywords contain regex patterns that are compiled by the jsonschema crate internally, bypassing our RegexBuilder::size_limit() enforcement.
- Risk: A policy author can embed an adversarial regex inside a JSON schema pattern to circumvent the size limit.
2. Azure RBAC StringMatches
- Path:
src/languages/azure_rbac/builtins/strings.rs:86
- Issue: Uses
Regex::new() directly without size limit.
- Risk: Feature-gated behind
azure_rbac, but if enabled with untrusted conditions, the same class of adversarial patterns applies.
Suggested Fix
- For
json.match_schema: Configure the jsonschema crate to use a custom regex provider that enforces the same size limit, or pre-validate schema patterns before compilation.
- For Azure RBAC: Route through
compile_regex_for_builtin() or apply RegexBuilder::size_limit() directly.
Context
Found during multi-model review of #705. These are separate code paths from the regex.* builtins and would be best addressed in a follow-up PR.
Summary
PR #705 adds compiled-size limits to all
regex.*builtins viacompile_regex_for_builtin(). However, two other code paths accept user-controlled regex patterns without enforcing the same limit:1.
json.match_schema/json.verify_schemasrc/builtins/objects.rs→compile_json_schema→jsonschema::validator_for"pattern"keywords contain regex patterns that are compiled by thejsonschemacrate internally, bypassing ourRegexBuilder::size_limit()enforcement.2. Azure RBAC
StringMatchessrc/languages/azure_rbac/builtins/strings.rs:86Regex::new()directly without size limit.azure_rbac, but if enabled with untrusted conditions, the same class of adversarial patterns applies.Suggested Fix
json.match_schema: Configure thejsonschemacrate to use a custom regex provider that enforces the same size limit, or pre-validate schema patterns before compilation.compile_regex_for_builtin()or applyRegexBuilder::size_limit()directly.Context
Found during multi-model review of #705. These are separate code paths from the
regex.*builtins and would be best addressed in a follow-up PR.