Skip to content

ext/lists: add max size check to genRange() to prevent OOM#1310

Merged
TristonianJones merged 4 commits into
cel-expr:masterfrom
marwan9696:fix-lists-range-dos
Jun 22, 2026
Merged

ext/lists: add max size check to genRange() to prevent OOM#1310
TristonianJones merged 4 commits into
cel-expr:masterfrom
marwan9696:fix-lists-range-dos

Conversation

@marwan9696

Copy link
Copy Markdown
Contributor

lists.range(N) allocates N elements with no upper bound. A large
value like 2147483647 allocates ~16 GB and crashes the process.

This is dangerous in Kubernetes ValidatingAdmissionPolicy where
user-controlled input feeds into CEL expressions.

Add maxRangeSize (10M) check and reject negative values.

Fixes #1309

lists.range(N) allocates N elements with no upper bound. A large
value like 2147483647 allocates ~16 GB and crashes the process.

This is dangerous in Kubernetes ValidatingAdmissionPolicy where
user-controlled input feeds into CEL expressions.

Add maxRangeSize (10M) check and reject negative values.
@google-cla

google-cla Bot commented Apr 30, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@marwan9696

Copy link
Copy Markdown
Contributor Author

CLA signed. Please re-check.

@TristonianJones

Copy link
Copy Markdown
Collaborator

/gcbrun

Comment thread ext/lists.go Outdated
Move the hardcoded maxRangeSize constant into a ListsMaxRangeSize
functional option on the Lists library, following the same pattern as
ListsVersion. Default remains 10,000,000. Setting to zero disables
the limit.
@marwan9696

Copy link
Copy Markdown
Contributor Author

Done — moved it to a ListsMaxRangeSize(n) functional option. Default is still 10M, setting to zero disables the check. Let me know if you'd like any other changes.

Comment thread ext/lists_test.go
Comment thread ext/lists.go Outdated
@TristonianJones

Copy link
Copy Markdown
Collaborator

/gcbrun

Adjust the default limit for range down to 1M
@TristonianJones

Copy link
Copy Markdown
Collaborator

/gcbrun

@TristonianJones TristonianJones merged commit 13cff33 into cel-expr:master Jun 22, 2026
7 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.

ext/lists: lists.range() unbounded memory allocation allows OOM DoS

2 participants