Skip to content

use-after-free in cupsdAcceptClient()

Moderate
zdohnal published GHSA-qjgh-5hcq-5f25 Jun 22, 2023

Package

No package listed

Affected versions

≥2.2.0

Patched versions

2.4.6

Description

Summary

Cups logs data of free memory to the logging service AFTER the connection has been closed, when it should have logged the data right before.

Details

The exact cause of this issue is the function httpClose(con->http) being called in scheduler/client.c before

httpClose(con->http); cupsdLogClient(con, CUPSDLOGWARN, "IP lookup failed - connection from %s closed!", httpGetHostname(con->http, NULL, 0));

The problem is that httpClose always, provided its argument is not null, frees the pointer at the end of the call, only for cupsdLogClient to pass the pointer to httpGetHostname.

This issue happens in function cupsdAcceptClient if LogLevel is warn or higher and in two scenarios:

  • there is a double-lookup for the IP Address (HostNameLookups Double is set in cupsd.conf) which fails to resolve,
  • or if CUPS is compiled with TCP wrappers and the connection is refused by rules from /etc/hosts.allow and /etc/hosts.deny.

Impact

This is a use-after-free bug, that impacts the entire cupsd process.

If you need an exploit scenario, consider: local (unprivileged) attacker who happens to be able to read the log using it to exfiltrate private keys and info from a privileged cups daemon
or simply denial-of-service by making it crash.

Fixed by commit

9809947

Severity

Moderate
5.3
/ 10

CVSS base metrics

Attack vector
Network
Attack complexity
Low
Privileges required
None
User interaction
None
Scope
Unchanged
Confidentiality
None
Integrity
None
Availability
Low
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L

CVE ID

CVE-2023-34241

Weaknesses

Credits