Skip to content

Unprivileged user can read files as root

Moderate
mdecimus published GHSA-5pfx-j27j-4c6h May 15, 2024

Package

Stalwart Mail Server

Affected versions

<= 0.7.3

Patched versions

0.8.0

Description

Summary

When using RUN_AS_USER, the specified user (and therefore, web interface admins) can read arbitrary files as root.

Details

Traditional UNIX services (ISC bind just to give an example) start up with these steps, in order:

  1. Start as privileged binary somewhere in /usr (writable by root only)
  2. Read config from /etc including the listeners (writable by root only)
  3. Set up the listeners while still privileged
  4. Drop the privileges
  5. Access data somewhere in /var (writable by the unprivileged user)

What makes this secure is that the unprivileged user cannot write anything that is interpreted as root. stalwart-mail adopts the "privdrop after bind"-part, but ignores the "access unprivileged data only after privdrop"-part.

PoC

  1. Configure server.listener.https.bind = "%{file:/etc/shadow}%" (works as local user or via the API, rejected by the web interface)
  2. View the log after restart (either as local user or via the web interface):
Failed to parse setting "server.listener.https.bind": Invalid socket address "root:$y$j9T…(redacted)

Impact

Admins who have set up to run stalwart with RUN_AS_USER who:

  1. handed out admin credentials to the mail server but expect these to only grant access according to the RUN_AS_USER
  2. are attacked where the attackers managed to achieve Arbitrary Code Execution using another vulnerability

Severity

Moderate

CVSS overall score

This score calculates overall vulnerability severity from 0 to 10 and is based on the Common Vulnerability Scoring System (CVSS).
/ 10

CVSS v3 base metrics

Attack vector
Network
Attack complexity
Low
Privileges required
High
User interaction
None
Scope
Changed
Confidentiality
High
Integrity
None
Availability
None

CVSS v3 base metrics

Attack vector: More severe the more the remote (logically and physically) an attacker can be in order to exploit the vulnerability.
Attack complexity: More severe for the least complex attacks.
Privileges required: More severe if no privileges are required.
User interaction: More severe when no user interaction is required.
Scope: More severe when a scope change occurs, e.g. one vulnerable component impacts resources in components beyond its security scope.
Confidentiality: More severe when loss of data confidentiality is highest, measuring the level of data access available to an unauthorized user.
Integrity: More severe when loss of data integrity is the highest, measuring the consequence of data modification possible by an unauthorized user.
Availability: More severe when the loss of impacted component availability is highest.
CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:C/C:H/I:N/A:N

CVE ID

CVE-2024-35179

Weaknesses

Credits