Open SuyueGuo opened 3 months ago
Yes, maybe I should open this issue in MediaArea/MediaInfoLib?
@JeromeMartinez
Visual Studio's Analysis also found some potential memory-related issues and other issues with MediaInfoLib. I'm not sure if there are any false positives and whether they can actually be encountered in normal use or be exploited. Therefore I didn't open a new issues about this but thought I should let you know in case you haven't known. Below are some examples. More can be seen by executing Analyze > Run Code Analysis > Run Code Analysis on MediaInfoLib
in Visual Studio.
Memory-related:
Severity Code Description Project File Line Suppression State Details
Warning C6001 Using uninitialized memory 'Buffer_Offset_Current'. MediaInfoLib \MediaInfoLib\Source\MediaInfo\Audio\File_Ac4.cpp 1847
Warning C6001 Using uninitialized memory 'nonstd_bed_channel_assignment_mask'. MediaInfoLib \MediaInfoLib\Source\MediaInfo\Audio\File_DolbyE.cpp 2403
Warning C6001 Using uninitialized memory 'Bitw_Stream_Metadata'. MediaInfoLib \MediaInfoLib\Source\MediaInfo\Audio\File_Dts.cpp 1073
Warning C6001 Using uninitialized memory 'RefClockCode'. MediaInfoLib \MediaInfoLib\Source\MediaInfo\Audio\File_Dts.cpp 1074
Warning C6001 Using uninitialized memory 'TimeStamp'. MediaInfoLib \MediaInfoLib\Source\MediaInfo\Audio\File_Dts.cpp 1077
Warning C6001 Using uninitialized memory 'Num_Frames_Total'. MediaInfoLib \MediaInfoLib\Source\MediaInfo\Audio\File_Dts.cpp 1081
Warning C6001 Using uninitialized memory 'tnsDataPresent'. MediaInfoLib \MediaInfoLib\Source\MediaInfo\Audio\File_Usac.cpp 4515
Warning C6001 Using uninitialized memory 'tnsDataPresent[BYTE:0]'. MediaInfoLib \MediaInfoLib\Source\MediaInfo\Audio\File_Usac.cpp 4515
Warning C6001 Using uninitialized memory 'num_grid_info'. MediaInfoLib \MediaInfoLib\Source\MediaInfo\Audio\File_Usac.cpp 4772
Warning C6001 Using uninitialized memory 'numQuantSteps'. MediaInfoLib \MediaInfoLib\Source\MediaInfo\Audio\File_Usac.cpp 5626
Warning C6001 Using uninitialized memory 'Compression'. MediaInfoLib \MediaInfoLib\Source\MediaInfo\Image\File_Png.cpp 582
Warning C6001 Using uninitialized memory 'maxscl'. MediaInfoLib \MediaInfoLib\Source\MediaInfo\Multiple\File_Mk.cpp 5452
Warning C6001 Using uninitialized memory 'ProfileLevel'. MediaInfoLib \MediaInfoLib\Source\MediaInfo\Multiple\File_Mpeg4_Descriptors.cpp 580
Warning C6001 Using uninitialized memory 'default_length'. MediaInfoLib \MediaInfoLib\Source\MediaInfo\Multiple\File_Mpeg4_Elements.cpp 5142
Warning C6001 Using uninitialized memory 'SDTI_TimeCode_StartTimecode_StreamPos_Last'. MediaInfoLib \MediaInfoLib\Source\MediaInfo\Multiple\File_Mxf.cpp 3579
Warning C6001 Using uninitialized memory 'SystemScheme1_TimeCodeArray_StartTimecode_StreamPos_Last'. MediaInfoLib \MediaInfoLib\Source\MediaInfo\Multiple\File_Mxf.cpp 3587
Warning C6001 Using uninitialized memory 'End'. MediaInfoLib \MediaInfoLib\Source\MediaInfo\Multiple\File_Nsv.cpp 1420
Warning C6001 Using uninitialized memory 'seq_level_idx'. MediaInfoLib \MediaInfoLib\Source\MediaInfo\Video\File_Av1.cpp 435
Warning C6001 Using uninitialized memory 'maxscl'. MediaInfoLib \MediaInfoLib\Source\MediaInfo\Video\File_Hevc.cpp 3271
Warning C6001 Using uninitialized memory 'chrominance_factor'. MediaInfoLib \MediaInfoLib\Source\MediaInfo\Video\File_ProRes.cpp 332
Warning C6001 Using uninitialized memory 'frame_type'. MediaInfoLib \MediaInfoLib\Source\MediaInfo\Video\File_ProRes.cpp 333
Warning C6001 Using uninitialized memory 'primaries'. MediaInfoLib \MediaInfoLib\Source\MediaInfo\Video\File_ProRes.cpp 336
Warning C6001 Using uninitialized memory 'transf_func'. MediaInfoLib \MediaInfoLib\Source\MediaInfo\Video\File_ProRes.cpp 336
Warning C6001 Using uninitialized memory 'colorMatrix'. MediaInfoLib \MediaInfoLib\Source\MediaInfo\Video\File_ProRes.cpp 336
Warning C6001 Using uninitialized memory 'alpha_info'. MediaInfoLib \MediaInfoLib\Source\MediaInfo\Video\File_ProRes.cpp 345
Warning C6001 Using uninitialized memory 'bit_depth'. MediaInfoLib \MediaInfoLib\Source\MediaInfo\Video\File_Vp9.cpp 306
Warning C6001 Using uninitialized memory 'colorspace'. MediaInfoLib \MediaInfoLib\Source\MediaInfo\Video\File_Vp9.cpp 307
Warning C6001 Using uninitialized memory 'subsampling'. MediaInfoLib \MediaInfoLib\Source\MediaInfo\Video\File_Vp9.cpp 311
Warning C6001 Using uninitialized memory 'yuv_range_flag'. MediaInfoLib \MediaInfoLib\Source\MediaInfo\Video\File_Vp9.cpp 312
Warning C6001 Using uninitialized memory 'width_minus_one'. MediaInfoLib \MediaInfoLib\Source\MediaInfo\Video\File_Vp9.cpp 316
Warning C6001 Using uninitialized memory 'height_minus_one'. MediaInfoLib \MediaInfoLib\Source\MediaInfo\Video\File_Vp9.cpp 317
Severity Code Description Project File Line Suppression State Details
Warning C6385 Reading invalid data from 's->bl_count'. zlibstat \zlib\trees.c 534
Warning C6385 Reading invalid data from 's->bl_count'. zlibstat \zlib\trees.c 550
Warning C6385 Reading invalid data from 'MI_Offsets'. MediaInfoLib \MediaInfoLib\Source\MediaInfo\Archive\File_Iso9660.cpp 100
Warning C6385 Reading invalid data from 'vDk0'. MediaInfoLib \MediaInfoLib\Source\MediaInfo\Audio\File_Aac_GeneralAudio_Sbr.cpp 947
Warning C6385 Reading invalid data from 'Aac_ChannelMode'. MediaInfoLib \MediaInfoLib\Source\MediaInfo\Audio\File_Aac_Main.cpp 501
Warning C6385 Reading invalid data from 'uniDrcConfigExtType_ConfNames'. MediaInfoLib \MediaInfoLib\Source\MediaInfo\Audio\File_Usac.cpp 2905
Warning C6385 Reading invalid data from 'usacConfigExtType_ConfNames'. MediaInfoLib \MediaInfoLib\Source\MediaInfo\Audio\File_Usac.cpp 3380
Warning C6385 Reading invalid data from 'C.sbrHandler.bs_df_noise[ch]'. MediaInfoLib \MediaInfoLib\Source\MediaInfo\Audio\File_Usac.cpp 4700
Warning C6385 Reading invalid data from 'usacExtElementType_Names'. MediaInfoLib \MediaInfoLib\Source\MediaInfo\Audio\File_Usac.cpp 5947
Warning C6385 Reading invalid data from 'PowersOf10'. MediaInfoLib \MediaInfoLib\Source\MediaInfo\TimeCode.cpp 511
Severity Code Description Project File Line Suppression State Details
Warning C33010 Unchecked lower bound for enum (this->MediaInfoLib::File__Base::StreamKind_Last) used as index.. MediaInfoLib \MediaInfoLib\Source\MediaInfo\File__Analyze_Streams.cpp 773
Warning C33010 Unchecked lower bound for enum (this->MediaInfoLib::File__Analyze::StreamSource) used as index.. MediaInfoLib \MediaInfoLib\Source\MediaInfo\File__Analyze_Streams.cpp 1005
Warning C33010 Unchecked lower bound for enum StreamKind used as index.. MediaInfoLib \MediaInfoLib\Source\MediaInfo\File__Analyze_Streams.cpp 1061
Warning C33010 Unchecked lower bound for enum StreamKind used as index.. MediaInfoLib \MediaInfoLib\Source\MediaInfo\File__Analyze_Streams.cpp 1744
Warning C33010 Unchecked lower bound for enum StreamKind used as index.. MediaInfoLib \MediaInfoLib\Source\MediaInfo\File__Analyze_Streams.cpp 1893
Warning C33010 Unchecked lower bound for enum Format used as index.. MediaInfoLib \MediaInfoLib\Source\MediaInfo\MediaInfo_Config.cpp 2903
Warning C33010 Unchecked lower bound for enum KindOfStream used as index.. MediaInfoLib \MediaInfoLib\Source\MediaInfo\MediaInfo_Config.cpp 2903
Warning C33010 Unchecked lower bound for enum Format used as index.. MediaInfoLib \MediaInfoLib\Source\MediaInfo\MediaInfo_Config.cpp 2964
Warning C33010 Unchecked lower bound for enum KindOfStream used as index.. MediaInfoLib \MediaInfoLib\Source\MediaInfo\MediaInfo_Config.cpp 3042
Warning C33010 Unchecked lower bound for enum KindOfStream used as index.. MediaInfoLib \MediaInfoLib\Source\MediaInfo\MediaInfo_Config.cpp 3062
Warning C33010 Unchecked lower bound for enum KindOfStream used as index.. MediaInfoLib \MediaInfoLib\Source\MediaInfo\MediaInfo_Config.cpp 3074
Warning C33010 Unchecked lower bound for enum KindOfStream used as index.. MediaInfoLib \MediaInfoLib\Source\MediaInfo\MediaInfo_Config.cpp 3086
Redundant/repeated checks in if
statements which I don't know is intentional or mistake/bug:
Warning C6287 Redundant code. MediaInfoLib \MediaInfoLib\Source\MediaInfo\Audio\File_Adm.cpp 5468
Warning C6287 Redundant code. MediaInfoLib \MediaInfoLib\Source\MediaInfo\File__Analyze_Streams_Finish.cpp 934
Warning C6287 Redundant code. MediaInfoLib \MediaInfoLib\Source\MediaInfo\Multiple\File_DvDif_Analysis.cpp 787
Cppcheck also found:
Id: arrayIndexOutOfBoundsCond
CWE: 788
Either the condition 'Code>=0x80' is redundant or the array 'Iab_Channel_Values[34]' is accessed at index 104, which is out of bounds.
If I understand the intention correctly, I think this should be:
if (Code>=0x80 && Code-0x68<sizeof(Iab_Channel_Values)/sizeof(const char*))
return Iab_Channel_Values[Code-0x68];
Warning C6385 Reading invalid data from 'vDk0'. MediaInfoLib >\MediaInfoLib\Source\MediaInfo\Audio\File_Aac_GeneralAudio_Sbr.cpp 947
This one likely a false positive since there is already a check: https://github.com/MediaArea/MediaInfoLib/blob/abdbb218b07f6cc0d4504c863ac5b42ecfab6fc6/Source/MediaInfo/Audio/File_Aac_GeneralAudio_Sbr.cpp#L896-L897 So this should not be possible to be out-of-bounds: https://github.com/MediaArea/MediaInfoLib/blob/abdbb218b07f6cc0d4504c863ac5b42ecfab6fc6/Source/MediaInfo/Audio/File_Aac_GeneralAudio_Sbr.cpp#L947
Summary
A heap-buffer-overflow vulnerability was found in MediaInfo, it may cause arbitrary code execution.
Version
Details
ASAN output:
Poc
heap_overflow_mediainfo.tar.gz
reproduce: