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

incomplete creation for RegExp object #91

Open
sunlili opened this issue Aug 13, 2022 · 0 comments
Open

incomplete creation for RegExp object #91

sunlili opened this issue Aug 13, 2022 · 0 comments

Comments

@sunlili
Copy link

sunlili commented Aug 13, 2022

version: jsish 3.5.0
os: ubuntu 20.04
crash: segment fault caused by a null-ptr dereference

poc1:

var V0 = (new RegExp ( /test/ ));

poc2:

try {
    const V1 = ([] . forEach);
    new RegExp ( "[d-G\\B]" ) . exec ( V1 ) ;
 } catch (V1) {
 }

My fuzzer finds those crashes, and I notice the latest fix. But, the fix seems to be incorrect. In poc1, when the RegExp is created:

jsish/src/jsiRegexp.c

Lines 150 to 154 in 4e5066c

else {
Jsi_Obj *o = Jsi_ObjNewType(interp, JSI_OT_REGEXP);
Jsi_ValueMakeObject(interp, ret, o);
target = *ret;
}

only JSI_OT_REGEXP field is set. The re expr /test/ is not assigned to the RegExp object in here or later. So, the RegExp object is incomplete. However, in following operations, the code assumes the RegExp object is complete, which causes the null-ptr dereference.

ISec Lab.

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

No branches or pull requests

1 participant