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

Failure to check file size leads to out-of-bounds memory access #33

Open
kittener opened this issue Jul 6, 2024 · 3 comments
Open

Failure to check file size leads to out-of-bounds memory access #33

kittener opened this issue Jul 6, 2024 · 3 comments
Assignees

Comments

@kittener
Copy link

kittener commented Jul 6, 2024

Hello,
I am testing my new fuzz tester recently. I found a crash when testing the gif2tga program. After analysis, the vulnerability appears in the following code snippet

	if(v!=i->gce.transparent_color || !i->gce.transparent_flag) {
#ifndef NGIFLIB_INDEXED_ONLY
		if(p->mode & NGIFLIB_MODE_INDEXED) {
#endif /* NGIFLIB_INDEXED_ONLY */
			*context->frbuff_p.p8 = v;
#ifndef NGIFLIB_INDEXED_ONLY
		} else
			*context->frbuff_p.p32 = v < i->ncolors ?
			   GifIndexToTrueColor(i->palette, v) : 0;
#endif /* NGIFLIB_INDEXED_ONLY */
	}

I think it should be caused by not checking the file structure in the LoadGIF function, resulting in too many memory addresses being allocated.

The condition for the vulnerability to be triggered is

gif2tga poc.gif

The poc file is

poc

by Kaiyu Xie

@kittener
Copy link
Author

kittener commented Jul 6, 2024

poc

@miniupnp miniupnp self-assigned this Jul 7, 2024
@miniupnp
Copy link
Owner

miniupnp commented Jul 7, 2024

The GIF looks 65535 x 65535

@miniupnp
Copy link
Owner

miniupnp commented Jul 7, 2024

So it is trying to write 16GB tga file :(

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