Skip to content
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

fix: delete validator before clear #2244

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

junwha
Copy link

@junwha junwha commented Dec 25, 2023

Hi, we found an incorrect use of Clear API of the allocator, which leads to Use-After-Free in schematest.

At test/perftest/schematest.cpp:208, the validator is constructed with validatorAllocator, and the chunks allocated during line 210 to line 213 are collected by the Clear API at line 214 as the for statement is ended.
However, the destructor of GeneriSchemaValidator is called at line 215, leading to invalid accesses to the chunks(Stack).

To avoid this issue, I added explicit delete to the validator before the Clear API call.

Thank you very much for taking the time to revise this issue!

@miloyip
Copy link
Collaborator

miloyip commented Dec 26, 2023

I think may just add a block {} to force destructing the validator first.

@junwha
Copy link
Author

junwha commented Dec 26, 2023

Hi @miloyip, Thank you for the feedback! I changed the patch as you commented.

@junwha junwha force-pushed the fix-uaf-schematest branch from 7c4d5f0 to 8a8ac91 Compare January 22, 2024 16:31
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