Skip to content

fix: rx operators better null checks #3426

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 29, 2025

Conversation

wooffie
Copy link
Contributor

@wooffie wooffie commented Jul 29, 2025

what

Add nullptr check in one more place

why

I think it can cause null derefence, because before we check for null:

if (transaction && transaction->m_rules->m_pcreMatchLimit.m_set) {

But after forget about this check and do dereference:

transaction->m_variableMscPcreError.set("1", transaction->m_variableOffset);

I cannot create PoC, maybe I'm wrong and using regex without limit will never cause != Utils::RegexResult::Ok, but looks legit

Copy link

@airween
Copy link
Member

airween commented Jul 29, 2025

Hi @wooffie,

thanks for this PR!

because before we check for null:
...
But after forget about this check and do dereference:

I think the first one is not necessary, because evaluate() is called from a Transaction object originally. But indeed, checking it won't hurt anyone.

maybe I'm wrong and using regex without limit will never cause

yes, you're right - checking nullptr value is always a good step.

Thank you!

@airween airween merged commit f2170d8 into owasp-modsecurity:v3/master Jul 29, 2025
50 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.

2 participants