Table of Contents
If you installed Samba from the distribution's repository
If you installed Samba from source
Home System Tutorial LINUX Application of methods to repair SambaCry vulnerabilities in Linux systems

Application of methods to repair SambaCry vulnerabilities in Linux systems

Jan 02, 2024 pm 09:12 PM
linux linux tutorial Red Hat linux system linux command linux certification red hat linux linux video

Introduction Samba has long been the standard for providing shared file and print services to Windows clients on Linux systems. Used by home users, mid-sized businesses and large companies, it stands out as the best solution in environments where multiple operating systems coexist, something that most Samba installations face due to the widespread use of tools. The risk of an attack that exploits a known vulnerability that was considered unimportant until news of the WannaCry ransomware attack came out.

Linux 系统中这样修复 SambaCry 漏洞

Vulnerability

Outdated and unpatched systems are vulnerable to remote code execution vulnerabilities. In simple terms, this means that someone with access to a writable share can upload an arbitrary piece of code and have it executed using root privileges in the server.

This issue is described as CVE-2017-7494 on the Samba website and is known to affect Samba v3.5 (released in early March 2010) and later. It was unofficially named SambaCry due to similarities to WannaCry: they both target the SMB protocol and are likely worms - which could cause it to spread from one system to another.

Debian, Ubuntu, CentOS and Red Hat have taken quick action to protect their users and released patches for their supported versions. Additionally, unsupported security workarounds are provided.

Update Samba

As mentioned previously, there are two ways to update depending on how you installed it previously:

If you installed Samba from the distribution's repository

Let’s look at what you need to do in this situation:

Fixing SambaCry under Debian

Add the following line to your sources list (/etc/apt/sources.list) to ensure that apt gets the latest security updates:

deb http://security.debian.org stable/updates main
deb-src http://security.debian.org/ stable/updates main
Copy after login

Next, update the available packages:

# aptitude update
Copy after login

Finally, make sure that the version of the samba package matches the bug-fixed version (see CVE-2017-7494):

# aptitude show samba
Copy after login

Linux 系统中这样修复 SambaCry 漏洞

Fixing SambaCry in Debian

Fixing SambaCry in Ubuntu

To start the repair, check for new available packages and update the Samba package as follows:

$ sudo apt-get update
$ sudo apt-get install samba
Copy after login

The Samba versions that have fixed CVE-2017-7494 are as follows:

  • 17.04: samba 2:4.5.8 dfsg-0ubuntu0.17.04.2
  • 16.10: samba 2:4.4.5 dfsg-2ubuntu5.6
  • 16.04 LTS: samba 2:4.3.11 dfsg-0ubuntu0.16.04.7
  • 14.04 LTS: samba 2:4.3.11 dfsg-0ubuntu0.14.04.8

Finally, run the following command to verify that your Ubuntu has the correct version installed.

$ sudo apt-cache show samba
Copy after login

Fixing SambaCry in CentOS/RHEL 7

The patched Samba version in EL 7 is samba-4.4.4-14.el7_3. To install it, do these:

# yum makecache fast
# yum update samba
Copy after login

As before, make sure you have the patched version of Samba installed:

# yum info samba
Copy after login

Linux 系统中这样修复 SambaCry 漏洞

Fixing SambaCry in CentOS

Old supported CentOS and older versions of RHEL are also fixed. See RHSA-2017-1270 for more.

If you installed Samba from source

Note: The following procedure assumes you have previously built Samba from source. It is strongly recommended that you try it in a test environment before deploying to a production server.

Also, make sure you back up the smb.conf file before starting.

In this case, we will also compile and update Samba from source. However, before we begin, we must first ensure that all dependencies are installed. Note that this may take several minutes.

In Debian and Ubuntu:

# aptitude install acl attr autoconf bison build-essential /
debhelper dnsutils docbook-xml docbook-xsl flex gdb krb5-user /
libacl1-dev libaio-dev libattr1-dev libblkid-dev libbsd-dev /
libcap-dev libcups2-dev libgnutls28-dev libjson-perl /
libldap2-dev libncurses5-dev libpam0g-dev libparse-yapp-perl /
libpopt-dev libreadline-dev perl perl-modules pkg-config /
python-all-dev python-dev python-dnspython python-crypto xsltproc /
zlib1g-dev libsystemd-dev libgpgme11-dev python-gpgme python-m2crypto
Copy after login

In CentOS 7 or similar:

# yum install attr bind-utils docbook-style-xsl gcc gdb krb5-workstation /
libsemanage-python libxslt perl perl-ExtUtils-MakeMaker /
perl-Parse-Yapp perl-Test-Base pkgconfig policycoreutils-python /
python-crypto gnutls-devel libattr-devel keyutils-libs-devel /
libacl-devel libaio-devel libblkid-devel libxml2-devel openldap-devel /
pam-devel popt-devel python-devel readline-devel zlib-devel
Copy after login

Stop the service (LCTT translation: not necessary here):

# systemctl stop smbd
Copy after login

Download and unzip the source code (4.6.4 is the latest version at the time of writing):

# wget https://www.samba.org/samba/ftp/samba-latest.tar.gz 
# tar xzf samba-latest.tar.gz
# cd samba-4.6.4
Copy after login

For informational purposes, check the available configuration options with the following command.

# ./configure --help
Copy after login

If you have used some options in the previous version of the build, you may be able to include some options in the return of the above command, or you may choose to use the default value:

# ./configure
# make
# make install
Copy after login

Finally restart the service.

# systemctl restart smbd
Copy after login

And verify you are using the updated version:

# smbstatus --version
Copy after login

The returned value here should be 4.6.4.

Other situations

If you are using an unsupported distribution and for some reason cannot upgrade to the latest version, you may want to consider these suggestions:

  • If SELinux is enabled, you are protected!
  • Make sure the Samba share is mounted with the noexec option. This prevents binaries from being executed from the mounted file system.

There are also generals:

nt pipe support = no
Copy after login

Add to the [global] field of smb.conf. You might want to keep in mind that this "may disable certain features of the Windows client" according to the Samba Project.

Important: Note that the nt pipe support = no option disables the share list for Windows clients. For example: when you enter //10.100.10.2/ in Windows Explorer on a Samba server, you will see "permission denied". Windows clients have to manually execute the share, such as //10.100.10.2/share_name to access the share.

Summarize

In this post, we have described the SambaCry vulnerability and how to mitigate the impact. We hope you can use this information to protect the systems you are responsible for.

If you have any questions or comments about this article, please use the comment box below to let us know.


About the Author:

Gabriel Cánepa is a GNU/Linux system administrator and web developer at Villa Mercedes in San Luis, Argentina. He works for a large international consumer products company and has great fun using FOSS tools in his daily work to increase productivity.


The above is the detailed content of Application of methods to repair SambaCry vulnerabilities in Linux systems. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Linux Architecture: Unveiling the 5 Basic Components Linux Architecture: Unveiling the 5 Basic Components Apr 20, 2025 am 12:04 AM

The five basic components of the Linux system are: 1. Kernel, 2. System library, 3. System utilities, 4. Graphical user interface, 5. Applications. The kernel manages hardware resources, the system library provides precompiled functions, system utilities are used for system management, the GUI provides visual interaction, and applications use these components to implement functions.

What computer configuration is required for vscode What computer configuration is required for vscode Apr 15, 2025 pm 09:48 PM

VS Code system requirements: Operating system: Windows 10 and above, macOS 10.12 and above, Linux distribution processor: minimum 1.6 GHz, recommended 2.0 GHz and above memory: minimum 512 MB, recommended 4 GB and above storage space: minimum 250 MB, recommended 1 GB and above other requirements: stable network connection, Xorg/Wayland (Linux)

vscode terminal usage tutorial vscode terminal usage tutorial Apr 15, 2025 pm 10:09 PM

vscode built-in terminal is a development tool that allows running commands and scripts within the editor to simplify the development process. How to use vscode terminal: Open the terminal with the shortcut key (Ctrl/Cmd). Enter a command or run the script. Use hotkeys (such as Ctrl L to clear the terminal). Change the working directory (such as the cd command). Advanced features include debug mode, automatic code snippet completion, and interactive command history.

How to check the warehouse address of git How to check the warehouse address of git Apr 17, 2025 pm 01:54 PM

To view the Git repository address, perform the following steps: 1. Open the command line and navigate to the repository directory; 2. Run the "git remote -v" command; 3. View the repository name in the output and its corresponding address.

How to run java code in notepad How to run java code in notepad Apr 16, 2025 pm 07:39 PM

Although Notepad cannot run Java code directly, it can be achieved by using other tools: using the command line compiler (javac) to generate a bytecode file (filename.class). Use the Java interpreter (java) to interpret bytecode, execute the code, and output the result.

Where to write code in vscode Where to write code in vscode Apr 15, 2025 pm 09:54 PM

Writing code in Visual Studio Code (VSCode) is simple and easy to use. Just install VSCode, create a project, select a language, create a file, write code, save and run it. The advantages of VSCode include cross-platform, free and open source, powerful features, rich extensions, and lightweight and fast.

What is the main purpose of Linux? What is the main purpose of Linux? Apr 16, 2025 am 12:19 AM

The main uses of Linux include: 1. Server operating system, 2. Embedded system, 3. Desktop operating system, 4. Development and testing environment. Linux excels in these areas, providing stability, security and efficient development tools.

vscode terminal command cannot be used vscode terminal command cannot be used Apr 15, 2025 pm 10:03 PM

Causes and solutions for the VS Code terminal commands not available: The necessary tools are not installed (Windows: WSL; macOS: Xcode command line tools) Path configuration is wrong (add executable files to PATH environment variables) Permission issues (run VS Code as administrator) Firewall or proxy restrictions (check settings, unrestrictions) Terminal settings are incorrect (enable use of external terminals) VS Code installation is corrupt (reinstall or update) Terminal configuration is incompatible (try different terminal types or commands) Specific environment variables are missing (set necessary environment variables)

See all articles