Regex size limit bypass via json.match_schema and Azure RBAC StringMatches
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 346
- Forks
- 75
- Avg merge
- 1d 3h
- Merged PRs (30d)
- 15
Description
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 thejsonschemacrate internally, bypassing ourRegexBuilder::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 thejsonschemacrate 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 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.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Read src/builtins/objects.rs around compile_json_schema and src/languages/azure_rbac/builtins/strings.rs:86, then inspect compile_regex_for_builtin() and the jsonschema validator configuration. Confirm both json.match_schema/json.verify_schema and Azure RBAC StringMatches enforce the same regex size limit, including patterns supplied through JSON Schema.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- security
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100