microsoft / microsoft/regorus

Regex size limit bypass via json.match_schema and Azure RBAC StringMatches

Open
#706 0 comments 0 reactions 0 assignees View on GitHub

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.rscompile_json_schemajsonschema::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.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.