Linux kernel vulnerability allows remote code execution

Summary

At the end of 2022 the Zero Day Initiative reported a vulnerability in the Linux kernel that allowed authenticated users to read data remotely and execute code in the kernel. The bug was in ksmbd, the SMB file server that has run directly in the kernel since Linux 5.15, in the processing of SMB2_TREE_DISCONNECT. ZDI initially gave it the maximum rating of 10 and later corrected it to 9.6.

What is ksmbd?

SMB is the protocol Windows computers use to share files on the network. On Linux, this has traditionally been handled by Samba, a program that runs as a normal process. ksmbd is an alternative developed by Samsung that works directly in the kernel and is meant to be faster as a result. It entered the official kernel in 2021 with Linux 5.15.

The price for the speed: a bug in ksmbd does not run in an isolated process but with the highest privileges of the system. That is exactly what made this vulnerability so dangerous.

How dangerous was it really?

The vulnerability arose because the code did not check whether an object still existed before an operation. However, an attacker needed credentials for the server. In addition, ksmbd is a module that has to be set up and started specifically; anyone using Samba or no SMB server at all was not affected. Potentially at risk were distributions with kernel 5.15 or newer, such as Ubuntu 22.04, Deepin Linux 20.3 and Slackware 15.

What you can learn from it

New features in the kernel bring new attack surface. The more network services run directly in the kernel, the greater the possible damage from a single bug. Further security reports for ksmbd followed in the years after, which is not unusual for young kernel components.

Ideas

  • A file server in the kernel saves context switches and can be faster.
  • Failing to check whether an object exists leads to memory bugs with code execution.
  • Modules that are not loaded present no attack surface.

Insights

  • Speed in the kernel is paid for with higher risk when bugs occur.
  • Whether a vulnerability is relevant depends on whether the affected component runs at all.
  • Young components need time and scrutiny before they are as robust as proven solutions.

Facts

  • ksmbd was developed by Samsung and entered the kernel with Linux 5.15.
  • The vulnerability was in the processing of SMB2_TREE_DISCONNECT.
  • The rating was corrected from CVSS 10 to 9.6.

References

Remarks

  • For most systems running Samba there was no danger, since ksmbd is not active there.

Recommendations

  • Check with lsmod whether ksmbd is loaded and unload the module if you do not need it.
  • Never expose SMB shares directly to the internet and keep the kernel up to date.

Read the original article

Search the Web Archive

Found a mistake or have something to add? Get in touch.