Skip to content

fix(extraction): refuse non-int RegexExtractionStrategy pattern from untrusted requests - #2654

Merged
ntohidi merged 1 commit into
developfrom
fix/regex-strategy-pattern-check
Nov 30, 2026
Merged

ntohidi merged 1 commit into
developfrom
fix/regex-strategy-pattern-check

Conversation

@ntohidi

@ntohidi ntohidi commented Nov 30, 2026

Copy link
Copy Markdown
Collaborator

Follow-up to #2588.

  • A request from outside with a non-int pattern (string, list, dict, bool) crashed RegexExtractionStrategy.__init__ with a TypeError and returned a 500. _clamp_untrusted now rejects it with UntrustedConfigError, so the server returns a 400. This was already broken before fix(extraction): keep RegexExtractionStrategy patterns through dump()/load() #2588.
  • self.pattern is stored as a plain int, so dump() holds a normal number, not the _B enum object.
  • The constructor docstring named a patterns argument that does not exist. It now documents pattern and custom.

Tests: 5 new cases in tests/unit/test_regex_strategy_serialization.py. They fail without the fix and pass with it. Unit + security suites: 552 passed. The 2 failures (test_getattr_removed_from_source, test_asyncio_subprocess_rce_attempt) also fail on develop.

…untrusted requests

An untrusted body with a non-int pattern (string, list, dict) crashed
__init__ with a TypeError, which the server returned as a 500. Reject it
with UntrustedConfigError (400) instead.

Also store pattern as a plain int so dump() holds no enum object, and fix
the constructor docstring, which named a non-existent 'patterns' argument.

Follow-up to #2588.
@ntohidi
ntohidi merged commit 4271a7b into develop Nov 30, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant