Skip to content

Tighten deserialization allowlist regex to require full-string match#66499

Open
potiuk wants to merge 2 commits intoapache:mainfrom
potiuk:serde-fullmatch-allowlist
Open

Tighten deserialization allowlist regex to require full-string match#66499
potiuk wants to merge 2 commits intoapache:mainfrom
potiuk:serde-fullmatch-allowlist

Conversation

@potiuk
Copy link
Copy Markdown
Member

@potiuk potiuk commented May 7, 2026

Tighten the deserialization allowlist ([core] allowed_deserialization_classes_regexp)
to use re.fullmatch() instead of re.match(). Previously a pattern such as
airflow\.models\.Variable admitted not only the intended class but also
airflow.models.Variable_Maliciousre.match only anchors at the start
of the string. Using fullmatch requires the pattern to match the entire
classname, eliminating the prefix-bypass footgun.

Updated the config description so admins know patterns are full-match and
that .* is needed for prefix-style allowances. Updated the existing test
that relied on prefix-match semantics, and added a dedicated test for the
bypass scenario.

Compatibility note for reviewers

This is a behaviour change for any deployment that configured
allowed_deserialization_classes_regexp with patterns relying on
prefix-match semantics (e.g. airflow\.models\. to mean "any class under
airflow.models"). Such deployments need to add .* to the pattern.
The default value is empty, so out-of-the-box deployments are unaffected.
Default off, admin-only config — leaving the newsfragment decision to the
reviewer.


Was generative AI tooling used to co-author this PR?
  • Yes — Claude Opus 4.7 (1M context)

Generated-by: Claude Opus 4.7 (1M context) following the guidelines

The ``allowed_deserialization_classes_regexp`` allowlist used ``re.match()``,
which only anchors at the start of the string. A pattern like
``airflow\.models\.Variable`` therefore also admitted classnames such as
``airflow.models.Variable_Malicious``. Switch to ``re.fullmatch()`` so the
admin's pattern matches the entire classname; document the semantics in
the config description so operators know to use ``.*`` for prefix-style
allowances.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant