CVE-2021-33909 - Buffer Copy without Checking Size of Input ('Classic Buffer Overflow')

Severity

78%

Complexity

18%

Confidentiality

98%

fs/seq_file.c in the Linux kernel 3.16 through 5.13.x before 5.13.4 does not properly restrict seq buffer allocations, leading to an integer overflow, an Out-of-bounds Write, and escalation to root by an unprivileged user, aka CID-8cae8cd89f05.

CVSS 3.1 Base Score 7.8. CVSS Attack Vector: local. CVSS Attack Complexity: low. CVSS Vector: (CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H).

CVSS 2.0 Base Score 7.2. CVSS Attack Vector: local. CVSS Attack Complexity: low. CVSS Vector: (AV:L/AC:L/Au:N/C:C/I:C/A:C).

Demo Examples

Buffer Copy without Checking Size of Input ('Classic Buffer Overflow')

CWE-120

The following code asks the user to enter their last name and then attempts to store the value entered in the last_name array.


               
scanf ("%s", last_name);

The problem with the code above is that it does not restrict or limit the size of the name entered by the user. If the user enters "Very_very_long_last_name" which is 24 characters long, then a buffer overflow will occur since the array can only hold 20 characters total.

Buffer Copy without Checking Size of Input ('Classic Buffer Overflow')

CWE-120

The following code attempts to create a local copy of a buffer to perform some manipulations to the data.


               
}
...

However, the programmer does not ensure that the size of the data pointed to by string will fit in the local buffer and blindly copies the data with the potentially dangerous strcpy() function. This may result in a buffer overflow condition if an attacker can influence the contents of the string parameter.

Buffer Copy without Checking Size of Input ('Classic Buffer Overflow')

CWE-120

The excerpt below calls the gets() function in C, which is inherently unsafe.


               
}
...

However, the programmer uses the function gets() which is inherently unsafe because it blindly copies all input from STDIN to the buffer without restricting how much is copied. This allows the user to provide a string that is larger than the buffer size, resulting in an overflow condition.

Buffer Copy without Checking Size of Input ('Classic Buffer Overflow')

CWE-120

In the following example, a server accepts connections from a client and processes the client request. After accepting a client connection, the program will obtain client information using the gethostbyaddr method, copy the hostname of the client that connected to a local variable and output the hostname of the client to a log file.


               
...
close(serversocket);
}
close(clientsocket);

However, the hostname of the client that connected may be longer than the allocated size for the local hostname variable. This will result in a buffer overflow when copying the client hostname to the local variable using the strcpy method.

Overview

Type

Linux

First reported 3 years ago

2021-07-20 19:15:00

Last updated 3 years ago

2021-10-18 12:55:00

Affected Software

Linux Kernel

Debian Linux 9.0

9.0

References

https://cdn.kernel.org/pub/linux/kernel/v5.x/ChangeLog-5.13.4

https://github.com/torvalds/linux/commit/8cae8cd89f05f6de223d63e6d15e31c8ba9cf53b

https://www.openwall.com/lists/oss-security/2021/07/20/1

[debian-lts-announce] 20210720 [SECURITY] [DLA 2713-2] linux security update

[debian-lts-announce] 20210720 [SECURITY] [DLA 2714-1] linux-4.19 security update

[debian-lts-announce] 20210720 [SECURITY] [DLA 2713-1] linux security update

DSA-4941

http://packetstormsecurity.com/files/163621/Sequoia-A-Deep-Root-In-Linuxs-Filesystem-Layer.html

FEDORA-2021-07dc0b3eb1

[oss-security] 20210722 Re: CVE-2021-33909: size_t-to-int vulnerability in Linux's filesystem layer

https://cdn.kernel.org/pub/linux/kernel/v5.x/ChangeLog-5.13.4

Mailing List, Patch, Vendor Advisory

https://github.com/torvalds/linux/commit/8cae8cd89f05f6de223d63e6d15e31c8ba9cf53b

Patch, Third Party Advisory

https://www.openwall.com/lists/oss-security/2021/07/20/1

Exploit, Mailing List, Third Party Advisory

[debian-lts-announce] 20210720 [SECURITY] [DLA 2713-2] linux security update

Mailing List, Third Party Advisory

[debian-lts-announce] 20210720 [SECURITY] [DLA 2714-1] linux-4.19 security update

Mailing List, Third Party Advisory

[debian-lts-announce] 20210720 [SECURITY] [DLA 2713-1] linux security update

Mailing List, Third Party Advisory

DSA-4941

Third Party Advisory

http://packetstormsecurity.com/files/163621/Sequoia-A-Deep-Root-In-Linuxs-Filesystem-Layer.html

Exploit, Third Party Advisory, VDB Entry

FEDORA-2021-07dc0b3eb1

Mailing List, Third Party Advisory

[oss-security] 20210722 Re: CVE-2021-33909: size_t-to-int vulnerability in Linux's filesystem layer

Mailing List, Third Party Advisory

http://packetstormsecurity.com/files/163671/Kernel-Live-Patch-Security-Notice-LSN-0079-1.html

Third Party Advisory

https://security.netapp.com/advisory/ntap-20210819-0004/

[oss-security] 20210825 Re: CVE-2021-33909: size_t-to-int vulnerability in Linux's filesystem layer

http://packetstormsecurity.com/files/164155/Kernel-Live-Patch-Security-Notice-LSN-0081-1.html

[oss-security] 20210916 Containers-optimized OS (COS) membership in the linux-distros list

[oss-security] 20210917 Re: Containers-optimized OS (COS) membership in the linux-distros list

[oss-security] 20210920 Re: Containers-optimized OS (COS) membership in the linux-distros list

http://packetstormsecurity.com/files/163671/Kernel-Live-Patch-Security-Notice-LSN-0079-1.html

Third Party Advisory, VDB Entry

https://security.netapp.com/advisory/ntap-20210819-0004/

Third Party Advisory

[oss-security] 20210825 Re: CVE-2021-33909: size_t-to-int vulnerability in Linux's filesystem layer

Mailing List, Third Party Advisory

http://packetstormsecurity.com/files/164155/Kernel-Live-Patch-Security-Notice-LSN-0081-1.html

Third Party Advisory, VDB Entry

[oss-security] 20210916 Containers-optimized OS (COS) membership in the linux-distros list

Mailing List, Third Party Advisory

[oss-security] 20210917 Re: Containers-optimized OS (COS) membership in the linux-distros list

Mailing List, Third Party Advisory

[oss-security] 20210920 Re: Containers-optimized OS (COS) membership in the linux-distros list

Mailing List, Third Party Advisory

Stay updated

ExploitPedia is constantly evolving. Sign up to receive a notification when we release additional functionality.

Get in touch

If you'd like to report a bug or have any suggestions for improvements then please do get in touch with us using this form. We will get back to you as soon as we can.