Skip to content

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

@anakrish

Description

@anakrish

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions