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)

How to use docker desktop How to use docker desktop Apr 15, 2025 am 11:45 AM

How to use Docker Desktop? Docker Desktop is a tool for running Docker containers on local machines. The steps to use include: 1. Install Docker Desktop; 2. Start Docker Desktop; 3. Create Docker image (using Dockerfile); 4. Build Docker image (using docker build); 5. Run Docker container (using docker run).

Difference between centos and ubuntu Difference between centos and ubuntu Apr 14, 2025 pm 09:09 PM

The key differences between CentOS and Ubuntu are: origin (CentOS originates from Red Hat, for enterprises; Ubuntu originates from Debian, for individuals), package management (CentOS uses yum, focusing on stability; Ubuntu uses apt, for high update frequency), support cycle (CentOS provides 10 years of support, Ubuntu provides 5 years of LTS support), community support (CentOS focuses on stability, Ubuntu provides a wide range of tutorials and documents), uses (CentOS is biased towards servers, Ubuntu is suitable for servers and desktops), other differences include installation simplicity (CentOS is thin)

What to do if the docker image fails What to do if the docker image fails Apr 15, 2025 am 11:21 AM

Troubleshooting steps for failed Docker image build: Check Dockerfile syntax and dependency version. Check if the build context contains the required source code and dependencies. View the build log for error details. Use the --target option to build a hierarchical phase to identify failure points. Make sure to use the latest version of Docker engine. Build the image with --t [image-name]:debug mode to debug the problem. Check disk space and make sure it is sufficient. Disable SELinux to prevent interference with the build process. Ask community platforms for help, provide Dockerfiles and build log descriptions for more specific suggestions.

How to view the docker process How to view the docker process Apr 15, 2025 am 11:48 AM

Docker process viewing method: 1. Docker CLI command: docker ps; 2. Systemd CLI command: systemctl status docker; 3. Docker Compose CLI command: docker-compose ps; 4. Process Explorer (Windows); 5. /proc directory (Linux).

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)

Detailed explanation of docker principle Detailed explanation of docker principle Apr 14, 2025 pm 11:57 PM

Docker uses Linux kernel features to provide an efficient and isolated application running environment. Its working principle is as follows: 1. The mirror is used as a read-only template, which contains everything you need to run the application; 2. The Union File System (UnionFS) stacks multiple file systems, only storing the differences, saving space and speeding up; 3. The daemon manages the mirrors and containers, and the client uses them for interaction; 4. Namespaces and cgroups implement container isolation and resource limitations; 5. Multiple network modes support container interconnection. Only by understanding these core concepts can you better utilize Docker.

What is vscode What is vscode for? What is vscode What is vscode for? Apr 15, 2025 pm 06:45 PM

VS Code is the full name Visual Studio Code, which is a free and open source cross-platform code editor and development environment developed by Microsoft. It supports a wide range of programming languages ​​and provides syntax highlighting, code automatic completion, code snippets and smart prompts to improve development efficiency. Through a rich extension ecosystem, users can add extensions to specific needs and languages, such as debuggers, code formatting tools, and Git integrations. VS Code also includes an intuitive debugger that helps quickly find and resolve bugs in your code.

How to switch Chinese mode with vscode How to switch Chinese mode with vscode Apr 15, 2025 pm 11:39 PM

VS Code To switch Chinese mode: Open the settings interface (Windows/Linux: Ctrl, macOS: Cmd,) Search for "Editor: Language" settings Select "Chinese" in the drop-down menu Save settings and restart VS Code

See all articles