Your message dated Fri, 20 Nov 2026 18:07:43 +0000
with message-id <[email protected]>
and subject line Bug#1152899: fixed in cron 3.0pl1-214
has caused the Debian Bug report #1152899,
regarding cron: mail hostname handling can read past a full buffer
to be marked as done.
This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.
(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact [email protected]
immediately.)
--
1152899: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1152899
Debian Bug Tracking System
Contact [email protected] with problems
--- Begin Message ---
Package: cron
Version: 3.0pl1-212
Severity: normal
Tags: patch
When a hostname fills cron's fixed-size buffer, the mail-output path
can treat it as a NUL-terminated string even though gethostname() did
not supply a terminator. An AddressSanitizer harness reproduced a read
past the buffer. The relevant conditions are a maximum-length
administrator-controlled hostname, job output, and mail delivery. We
have not demonstrated a useful information leak or a production crash.
The attached Debian -212 patch reserves room for termination, checks
gethostname()'s return value, and uses a safe fallback on error. Its
regression test covers ordinary success, error, and a successful
full-buffer result without a NUL terminator.
The patched Debian source built in a disposable trixie container; the
focused regression and all 13 existing Debian integration tests
passed. Ubuntu versions 3.0pl1-200ubuntu1 and -209ubuntu1 have the
same issue. Debian and Ubuntu Security Teams recommended public bug
reports.
Regards,
Brett Sutton
Description: Terminate mail hostnames and handle lookup failures
Origin: other, private Daybreak audit
Forwarded: no
--- a/cron.h
+++ b/cron.h
@@ -345,3 +345,5 @@
extern char *DebugFlagNames[];
# endif /* DEBUGGING */
#endif /*MAIN_PROGRAM*/
+
+int cron_gethostname(char *, size_t);
--- a/do_command.c
+++ b/do_command.c
@@ -534,12 +534,12 @@
register char **env;
char **jobenv = build_env(e->envp);
auto char mailcmd[MAX_COMMAND];
- auto char hostname[MAXHOSTNAMELEN];
+ auto char hostname[MAXHOSTNAMELEN + 1];
char *content_type = env_get("CONTENT_TYPE",jobenv),
*content_transfer_encoding = env_get("CONTENT_TRANSFER_ENCODING",jobenv);
int encoding_auto = 0;
- (void) gethostname(hostname, MAXHOSTNAMELEN);
+ (void) cron_gethostname(hostname, sizeof hostname);
(void) snprintf(mailcmd, sizeof(mailcmd),
MAILARGS, MAILCMD, mailto);
if (!(mail = cron_popen(mailcmd, "w", e))) {
--- a/misc.c
+++ b/misc.c
@@ -792,3 +792,14 @@
return (offset);
}
#endif /* HAVE_TM_GMTOFF */
+
+int
+cron_gethostname(char *hostname, size_t size)
+{
+ if (size < sizeof "localhost")
+ return FALSE;
+ if (gethostname(hostname, size) != 0)
+ (void) strcpy(hostname, "localhost");
+ hostname[size - 1] = '\0';
+ return TRUE;
+}
\ No newline at end of file
--- /dev/null
+++ b/tests/hostname_regression.c
@@ -0,0 +1,49 @@
+#define MAIN_PROGRAM
+#define gethostname fake_gethostname
+#include "../misc.c"
+#undef gethostname
+#include <assert.h>
+
+static int hostname_mode;
+
+int
+fake_gethostname(char *name, size_t size)
+{
+ if (hostname_mode == 3) {
+ memset(name, 'h', size);
+ return 0;
+ }
+ if (hostname_mode == 1) {
+ memset(name, 'h', size);
+ errno = ENAMETOOLONG;
+ return -1;
+ }
+ if (hostname_mode == 2) {
+ if (size <= MAXHOSTNAMELEN)
+ return -1;
+ memset(name, 'h', MAXHOSTNAMELEN);
+ name[MAXHOSTNAMELEN] = '\0';
+ return 0;
+ }
+ memcpy(name, "testhost", 9);
+ return 0;
+}
+
+
+int main(void) {
+ char hostname[MAXHOSTNAMELEN + 1];
+ hostname_mode = 1;
+ assert(cron_gethostname(hostname, sizeof hostname));
+ assert(strcmp(hostname, "localhost") == 0);
+ hostname_mode = 2;
+ assert(cron_gethostname(hostname, sizeof hostname));
+ assert(strlen(hostname) == MAXHOSTNAMELEN);
+ hostname_mode = 3;
+ assert(cron_gethostname(hostname, sizeof hostname));
+ assert(hostname[sizeof hostname - 1] == '\0');
+ assert(strlen(hostname) == MAXHOSTNAMELEN);
+ hostname_mode = 0;
+ assert(cron_gethostname(hostname, sizeof hostname));
+ assert(strcmp(hostname, "testhost") == 0);
+ return 0;
+}
--- End Message ---
--- Begin Message ---
Source: cron
Source-Version: 3.0pl1-214
Done: Georges Khaznadar <[email protected]>
We believe that the bug you reported is fixed in the latest version of
cron, which is due to be installed in the Debian FTP archive.
A summary of the changes between this version and the previous one is
attached.
Thank you for reporting the bug, which will now be closed. If you
have further comments please address them to [email protected],
and the maintainer will reopen the bug report if appropriate.
Debian distribution maintenance software
pp.
Georges Khaznadar <[email protected]> (supplier of updated cron package)
(This message was generated automatically at their request; if you
believe that there is a problem with it please contact the archive
administrators by mailing [email protected])
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512
Format: 1.8
Date: Fri, 06 Nov 2026 09:13:53 +0100
Source: cron
Architecture: source
Version: 3.0pl1-214
Distribution: unstable
Urgency: medium
Maintainer: Georges Khaznadar <[email protected]>
Changed-By: Georges Khaznadar <[email protected]>
Closes: 1152899 1152900
Changes:
cron (3.0pl1-214) unstable; urgency=medium
.
* Replace host name by "localhost" when its length is excessive.
Closes: #1152899
* discard too long file names to prevent buffer overflows when
writing to /etc/cron.d; Closes: #1152900
Checksums-Sha1:
6a521c835c3a45566ab7461fa6d8649fcb7d7911 2189 cron_3.0pl1-214.dsc
aa81ae80a7ed08a1b981044d54a0b016f36820d8 143228 cron_3.0pl1-214.debian.tar.xz
3b305792eb353442d95be8617cee09ff3e0aba5e 6535 cron_3.0pl1-214_source.buildinfo
Checksums-Sha256:
30b3e5d4f218c41e27d41f65e38691180415b10b39ae899af60e6348ccf89dd5 2189
cron_3.0pl1-214.dsc
5eef515e6861cecce20ba49c928cac001ee1e7e499c7c4e1c21b97b88edc7fd5 143228
cron_3.0pl1-214.debian.tar.xz
c0653c599f71d90e5ec7984ce707d760b81123a6bca40b942e327256e9a42800 6535
cron_3.0pl1-214_source.buildinfo
Files:
b7a287d38d8c8a2242c5dbc186493061 2189 admin important cron_3.0pl1-214.dsc
54a7087202b1775720d1f81e607aeff7 143228 admin important
cron_3.0pl1-214.debian.tar.xz
001d2e9979b43cb5c48a8769391607a8 6535 admin important
cron_3.0pl1-214_source.buildinfo
-----BEGIN PGP SIGNATURE-----
iQJIBAEBCgAyFiEEM0CzZP9nFT+3zK6FHCgWkHE2rjkFAmsAiQsUHGdlb3JnZXNr
QGRlYmlhbi5vcmcACgkQHCgWkHE2rjne9RAAisXawXCMHDUCxUqtbwnKMCVB2V2P
f7FnO+xXfS00VVukVaCCB6tQM+n7Ki9m3D+UF9jIOlCeF/GQsb1hm6QvYRG6x1wF
WwOYCcRIXrANV4T9edFExXAf6Rd/PpXMVnPj0sPZkNJHvIbmiIpWb5YwRo8tgWHP
a4VA+bJv6pd8RGpMthfv5Hmuae5AX/Dgjb2IZHI1DHx7BhpooB6GUpIhmGufB5Wx
lXQ4ysMr8dqeKhq9g/YRkNUCq8cOAlo+wFJKu4aO4toeYWDoD1NSf9hlsZjSt7B0
jR/HNOcUUTQHg60bDHS/S+k26R++ff0spwm7qrnn9LkhKSGdDus8CWMNS214PLcP
I1+FdpzE6Te1muWTsG1R/izxqarGzDPIlz3PcXYOU2NHcJcVoILEmMLI0PcLQEDP
IN8S2US/Ar1rTmv+or2sfu/i9AEVKku4sUpEYeIxBg4RGxrwB/W7qcU6ouGhkwDD
ILRxX/e4QWF4BlVLn4h4ZQfsz+o2ewMSLr0rneKBSAlHi2CNDeVp5pyUd2rgF7W4
GiQ/2uddB60336ibGLsMFc27gm4MSLVi3duEA2joxgA7XlAa2ayJHhS4cGnCa4H0
U9nIQHYcgNiqhGnTFtG9yq9PtC3Z5dqXENZw2q/6zSI3kNJdA8vOzWRS389LjvWK
T1dSWRxVaf8WgU8=
=qhdU
-----END PGP SIGNATURE-----
pgpacbcJ8UeVp.pgp
Description: PGP signature
--- End Message ---