CVE-2022-0685 (published 2022-02-20T11:15Z)

Use of Out-of-range Pointer Offset in GitHub repository vim/vim prior to 8.2.4418.

Severity: MEDIUM
CVSS v2 base score: 6.8 (AV:N/AC:M/Au:N/C:P/I:P/A:P)
CVSS v3 base score: 7.8, HIGH (CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H)

Weakness information:
cwe_id: CWE-823
cwe_name: Use of Out-of-range Pointer Offset
description: The product performs pointer arithmetic on a valid pointer, but it uses an offset that can point outside of the intended range of valid memory locations for the resulting pointer.
extended_description: 
            While a pointer can contain a reference to any arbitrary memory location, a program typically only intends to use the pointer to access limited portions of memory, such as contiguous memory used to access an individual array.
            Programs may use offsets in order to access fields or sub-elements stored within structured data. The offset might be out-of-range if it comes from an untrusted source, is the result of an incorrect calculation, or occurs because of another error.
            If an attacker can control or influence the offset so that it points outside of the intended boundaries of the structure, then the attacker may be able to read or write to memory locations that are used elsewhere in the product. As a result, the attack might change the state of the product as accessed through program variables, cause a crash or instable behavior, and possibly lead to code execution.
         
         

Fix information:
repo_url: https://github.com/vim/vim
commit_details: repo_url: https://github.com/vim/vim
author: Bram Moolenaar
author_date: 2022-02-19 11:20:12+00:00
msg: patch 8.2.4418: crash when using special multi-byte character

Problem:    Crash when using special multi-byte character.
Solution:   Don't use isalpha() for an arbitrary character.
repository: repo_url: https://github.com/vim/vim
repo_name: vim/vim
description: The official Vim repository
repo_language: Vim Script
owner: vim
file_changes: filename: charset.c
change_type: ModificationType.MODIFY
diff: @@ -1644,6 +1644,12 @@ vim_isupper(int c)
     return isupper(c);
 }
 
+    int
+vim_isalpha(int c)
+{
+    return vim_islower(c) || vim_isupper(c);
+}
+
     int
 vim_toupper(int c)
 {

programming_language: C
filename: filepath.c
change_type: ModificationType.MODIFY
diff: @@ -3626,7 +3626,7 @@ unix_expandpath(
 	else if (path_end >= path + wildoff
 			 && (vim_strchr((char_u *)"*?[{~$", *path_end) != NULL
 			     || (!p_fic && (flags & EW_ICASE)
-					     && isalpha(PTR2CHAR(path_end)))))
+					  && vim_isalpha(PTR2CHAR(path_end)))))
 	    e = p;
 	if (has_mbyte)
 	{

programming_language: C++
filename: charset.pro
change_type: ModificationType.MODIFY
diff: @@ -50,6 +50,7 @@ int vim_isxdigit(int c);
 int vim_isbdigit(int c);
 int vim_islower(int c);
 int vim_isupper(int c);
+int vim_isalpha(int c);
 int vim_toupper(int c);
 int vim_tolower(int c);
 char_u *skiptowhite(char_u *p);
@@ -63,5 +64,4 @@ int hexhex2nr(char_u *p);
 int rem_backslash(char_u *str);
 void backslash_halve(char_u *p);
 char_u *backslash_halve_save(char_u *p);
-void ebcdic2ascii(char_u *buffer, int len);
 /* vim: set ft=c : */

programming_language: C
filename: test_autochdir.vim
change_type: ModificationType.MODIFY
diff: @@ -110,4 +110,12 @@ func Test_verbose_pwd()
   call delete('Xautodir', 'rf')
 endfunc
 
+func Test_multibyte()
+  " using an invalid character should not cause a crash
+  set wic
+  call assert_fails('tc *', 'E344:')
+  set nowic
+endfunc
+
+
 " vim: shiftwidth=2 sts=2 expandtab

programming_language: Lua
filename: version.c
change_type: ModificationType.MODIFY
diff: @@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    4418,
 /**/
     4417,
 /**/

programming_language: Ruby