Valve · Report #463286
Specially Crafted Closed Captions File can lead to Remote Code Execution in CS:GO and other Source Games
Validstatus
criticalseverity
$7,500bounty
109upvotes
5 May 2021disclosed
Summary
With a specially crafted closed captions file, the parser calls CHudCloseCaption::GetNoRepeatValue which in turn calls CHudCloseCaption::SplitCommand which has no boundary checks allowing the on stack variables cmd and args to be overflowed which in turn allows Remote Code Execution.
Buffer overflow via the closed captioning system in the function CHudCloseCaption::SplitCommand which can be reached via the function CHudCloseCaption::GetNoRepeatValue
bool CHudCloseCaption::GetNoRepeatValue( const wchar_t *caption, float &retval )
{
retval = 0.0f;
const wchar_t *curpos = caption;
for ( ; curpos && *curpos != L'\0'; ++curpos )
{
wchar_t cmd[ 256 ];
wchar_t args[ 256 ];
if ( SplitCommand( &curpos, cmd, args ) )//Vulnerable call
{
if ( !wcscmp( cmd, L"norepeat" ) )
{
retval = (float)wcstod( args, NULL );
return true;
}
continue;
}
}
return false;
}
bool CHudCloseCaption::SplitCommand( wchar_t const **ppIn, wchar_t *cmd, wchar_t *args ) const
{
const wchar_t *in = *ppIn;
const wchar_t *oldin = in;
if ( in[0] != L'<' )
{
*ppIn += ( oldin - in );
return false;
}
args[ 0 ] = 0;
cmd[ 0 ]= 0;
wchar_t *out = cmd;
in++;
while ( *in != L'\0' && *in != L':' && *in != L'>' && !V_isspace( *in ) )
{
*out++ = *in++;//Vulnerable overflow
}
*out = L'\0';
if ( *in != L':' )
{
*ppIn += ( in - oldin );
return true;
}
in++;
out = args;
while ( *in != L'\0' && *in != L'>' )
{
*out++ = *in++;//Vulnerable overflow
}
*out = L'\0';
//if ( *in == L'>' )
// in++;
*ppIn += ( in - oldin );
return true;
}
How it was found
The write-up for this report has not been downloaded yet, or the program disclosed it without one. Read it on HackerOne.