You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
case'O': { /* output format */charoutformat[50];
char*of=opj_optarg;
sprintf(outformat, ".%s", of);
The vulnerable code in opj_decompress.c is identical.
Reason:opj_optarg comes straight from argv, so no length checking is done to see if it fits in outformat. A malicious user can supply an output format whose length is greater than 50 characters, which results in a buffer overflow after the sprintf call.
"Images" can be any folder name, and here the OutForargument is 50 a's to overflow the buffer.
On my machine (ec2 t2-micro), using 1200 a's results in a segmentation fault.
Proposed mitigation:
Multiple ways to do this, for example you can allocate outformat using strlen(opj_optarg). Also there are no formats greater than 4 characters, so you can also verify the argument passed in is only 4 characters.
The text was updated successfully, but these errors were encountered:
robbiejones96
changed the title
sprintf buffer overflow in opj_compress.c (parse_cmdline_encoder)
sprintf buffer overflow in opj_compress/opj_decompress.c (parse_cmdline_encoder)
Jul 31, 2018
A buffer overflow is possible in
opj_compress
andopj_decompress
when using the-ImgDir -OutFor
options.Vulnerable Code:
opj_compress.c:parse_cmdline_encoder
The vulnerable code in
opj_decompress.c
is identical.Reason:
opj_optarg
comes straight fromargv
, so no length checking is done to see if it fits inoutformat
. A malicious user can supply an output format whose length is greater than 50 characters, which results in a buffer overflow after thesprintf
call.Reproducing the attack:
"Images"
can be any folder name, and here theOutFor
argument is 50a's
to overflow the buffer.On my machine (ec2 t2-micro), using 1200 a's results in a segmentation fault.
Proposed mitigation:
Multiple ways to do this, for example you can allocate
outformat
usingstrlen(opj_optarg)
. Also there are no formats greater than 4 characters, so you can also verify the argument passed in is only 4 characters.The text was updated successfully, but these errors were encountered: