CVE-2024-5742: Nano: running `chmod` and `chown` on the filename allows malicious user to replace the emergency file with a malicious symlink to a root-owned file

Published May 2, 2024
·
Updated

A vulnerability was found in GNU Nano that allows a possible privilege escalation through an insecure temporary file. If Nano is killed while editing, a file it saves to an emergency file with the permissions of the running user provides a window of opportunity for attackers to escalate privileges through a malicious symlink.

Other sources

Nano: running chmod and chown on the filename allows malicious user to replace the emergency file with a malicious symlink to a root-owned file

Microsoft

When nano is killed while it has a modified buffer, it saves this buffer to an emergency .save file and then chmods and chowns this file to the permissions and owner of the original file. This means that when nano is run as root and edits a user-owned file in a directory that is writable by that user, it gives a malicious user a window of opportunity to replace the .save file with a malicious symlink to a root-owned file. To be exploitable, it requires that the malicious user is able to kill the nano run by root. The original reporters of the problem said this:

We think it will mostly have an impact on multi-user systems. Where an admin might open a user's file -- for example to fix a broken config file. This could be in a user directory, requiring the admin to either become the user, or become root. If an admin does the latter, this attack can be performed - as long as the user can kill nano of course. One such example might be when root is logged in over ssh to a low-privilege user machine and the user can turn off the wifi on that machine.

https://bugzilla.redhat.com/showbug.cgi?id=2277586 https://git.savannah.gnu.org/cgit/nano.git/commit/?id=5e7a3c2e7e118c7f12d5dfda9f9140f638976aa2

Red Hat

Affected Software

9 affected componentsFixes available
redhat/nano<8.0
8.0
debian/nano
5.4-2+deb11u37.2-1+deb12u18.3-1
GNU Nano>=2.2.0<8.0
redhat Enterprise Linux=6.0
redhat Enterprise Linux=7.0
redhat Enterprise Linux=8.0
redhat Enterprise Linux=9.0
Microsoft azl3 nano 6.4-2
Microsoft cbl2 nano 6.0-3

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade redhat/nano to a version that resolves this vulnerability.

    Fixed in 8.0
  2. Upgrade

    Upgrade debian/nano to a version that resolves this vulnerability.

    Fixed in 5.4-2+deb11u3Fixed in 7.2-1+deb12u1Fixed in 8.3-1

Event History

Jun 12, 2024
CVE Published
via MITRE·08:53 AM
Data Sourced
via MITRE·08:53 AM
DescriptionSeverityWeakness
Data Sourced
via NVD·09:15 AM
DescriptionSeverityWeaknessAffected Software
Jul 10, 2024
Data Sourced
via Microsoft·07:00 AM
DescriptionSeverityWeakness
Data Sourced
via Microsoft·07:00 AM
Affected Software
Updated
via Microsoft·07:00 AM
DescriptionSeverity
Oct 15, 2024
Data Sourced
via Launchpad·05:23 PM
Description
Nov 2, 2024
Data Sourced
via Ubuntu·01:14 PM
RemedyDescriptionSeverityAffected Software
Free Weekly Intel

Don't miss critical vulnerabilities

Join thousands of security professionals who receive our weekly digest of trending CVEs, zero-days, and exploited vulnerabilities.

No spam. Unsubscribe anytime.

Frequently Asked Questions

1

What is the severity of CVE-2024-5742?

The severity of CVE-2024-5742 is classified as a privilege escalation vulnerability.

2

How do I fix CVE-2024-5742?

To fix CVE-2024-5742, update GNU Nano to version 8.0 or above.

3

Which versions of GNU Nano are affected by CVE-2024-5742?

CVE-2024-5742 affects GNU Nano versions prior to 8.0.

4

Can CVE-2024-5742 affect Red Hat Enterprise Linux?

Yes, CVE-2024-5742 can potentially affect Red Hat Enterprise Linux versions 6.0 to 8.0.

5

What kind of attacks can CVE-2024-5742 facilitate?

CVE-2024-5742 may allow attackers to escalate privileges under certain conditions during file editing.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203