Your message dated Tue, 03 Nov 2026 18:19:02 +0000
with message-id <[email protected]>
and subject line Bug#1152898: fixed in cron 3.0pl1-213
has caused the Debian Bug report #1152898,
regarding cron: final cron.deny entry is ignored without a trailing newline
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.)


-- 
1152898: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1152898
Debian Bug Tracking System
Contact [email protected] with problems
--- Begin Message ---
Package: cron
Version: 3.0pl1-212
Severity: normal
Tags: patch

The final username in an administrator-created /etc/cron.deny is not
matched if that line has no terminating newline. For example, when the
file consists of the bytes "blocked" without a trailing LF, the user
"blocked" can still run crontab(1), assuming no cron.allow file takes
precedence. The administrator expects that username to be denied. This
is conditional on use of cron.deny and the missing final LF; it does
not grant higher OS privileges.

The in_file() reader removes the final character unconditionally as
though it were a newline. The attached Debian -212 patch reads
complete physical records, matches a final unterminated line, handles
CRLF, and rejects overlong or NUL-containing records without consuming
a following valid entry. Its regression test covers those cases.

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 advised public bug
reports for these findings.

Regards,
Brett Sutton
Description: Match complete final lines in cron allow and deny files
Origin: other, private Daybreak audit
Forwarded: no

--- a/misc.c
+++ b/misc.c
@@ -427,9 +427,23 @@
 	char line[MAX_TEMPSTR];
 
 	rewind(file);
-	while (fgets(line, MAX_TEMPSTR, file)) {
-		if (line[0] != '\0')
-			line[strlen(line)-1] = '\0';
+	for (;;) {
+		size_t len = 0;
+		int ch, invalid = 0;
+		/* Consume exactly one physical record, even with embedded NULs. */
+		while ((ch = fgetc(file)) != EOF && ch != '\n') {
+			if (ch == '\0' || len == sizeof line - 1)
+				invalid = 1;
+			else
+				line[len++] = ch;
+		}
+		if (ch == EOF && len == 0)
+			break;
+		if (invalid)
+			continue;
+		line[len] = '\0';
+		if (len && line[len-1] == '\r')
+			line[len-1] = '\0';
 		if (0 == strcmp(line, string))
 			return TRUE;
 	}
@@ -437,6 +451,7 @@
 }
 
 
+
 /* int allowed(char *username)
  *	returns TRUE if (ALLOW_FILE exists and user is listed)
  *	or (DENY_FILE exists and user is NOT listed)
--- /dev/null
+++ b/tests/deny_regression.c
@@ -0,0 +1,41 @@
+#define MAIN_PROGRAM
+#include "../misc.c"
+#include <assert.h>
+
+static void
+check_deny_lines(void)
+{
+	FILE *file = tmpfile();
+	char long_name[MAX_TEMPSTR + 10];
+	char truncated[MAX_TEMPSTR];
+	assert(file != NULL);
+	fputs("blocked", file);
+	assert(in_file("blocked", file));
+	freopen(NULL, "w+", file);
+	fputs("blocked\n", file);
+	assert(in_file("blocked", file));
+	freopen(NULL, "w+", file);
+	fputs("blocked\r\n", file);
+	assert(in_file("blocked", file));
+	freopen(NULL, "w+", file);
+	memset(long_name, 'a', sizeof long_name - 1);
+	long_name[sizeof long_name - 1] = '\0';
+	memset(truncated, 'a', sizeof truncated - 1);
+	truncated[sizeof truncated - 1] = '\0';
+	fprintf(file, "%s\nblocked\n", long_name);
+	assert(!in_file(truncated, file));
+	assert(in_file("blocked", file));
+	fclose(file);
+	file = tmpfile();
+	assert(file != NULL);
+	{
+		static const char malformed[] = "junk\0junk\nblocked\n";
+		assert(fwrite(malformed, 1, sizeof malformed - 1, file) == sizeof malformed - 1);
+	}
+	assert(!in_file("junk", file));
+	assert(in_file("blocked", file));
+	fclose(file);
+}
+
+
+int main(void) { check_deny_lines(); return 0; }

--- End Message ---
--- Begin Message ---
Source: cron
Source-Version: 3.0pl1-213
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: Tue, 03 Nov 2026 18:40:11 +0100
Source: cron
Architecture: source
Version: 3.0pl1-213
Distribution: unstable
Urgency: medium
Maintainer: Georges Khaznadar <[email protected]>
Changed-By: Georges Khaznadar <[email protected]>
Closes: 1152898
Changes:
 cron (3.0pl1-213) unstable; urgency=medium
 .
   * replace a last character in a line by '\0' only when this
     character is '\n'. Closes: #1152898; thanks to Brett Sutton
     for reporting this bug.
Checksums-Sha1:
 b80bdffe06d726e8231103180a12d4b70499d87f 2189 cron_3.0pl1-213.dsc
 fee71c2556d95571d5774982805ea3d18df882fb 142864 cron_3.0pl1-213.debian.tar.xz
 eb269bbba6820992209760e29e9b0a7779115798 6488 cron_3.0pl1-213_source.buildinfo
Checksums-Sha256:
 80c5853f45441f4e8f5182e66d2ff7552cc5a19c24bfa8b1ff3f7c4302554ccb 2189 
cron_3.0pl1-213.dsc
 2422b9d6e09caa230fff7db255b96aae36d2efb079dc8e10e1e9f59b2e4b6b84 142864 
cron_3.0pl1-213.debian.tar.xz
 129821cf6bf55b3a8a94d402393103a86a364b862fdcc4eec0cc3bc7bb31de85 6488 
cron_3.0pl1-213_source.buildinfo
Files:
 4938ec29b09f7c29d2822e9f241e7ed5 2189 admin important cron_3.0pl1-213.dsc
 2789a166fb3daad7080dbb02c693600b 142864 admin important 
cron_3.0pl1-213.debian.tar.xz
 9d35c2d7f3cd37511be4d00922a83b8d 6488 admin important 
cron_3.0pl1-213_source.buildinfo

-----BEGIN PGP SIGNATURE-----

iQJIBAEBCgAyFiEEM0CzZP9nFT+3zK6FHCgWkHE2rjkFAmrqHcsUHGdlb3JnZXNr
QGRlYmlhbi5vcmcACgkQHCgWkHE2rjnPQw/+OQR2+0eDocw06V4KGWLnsHzxw3k1
MwEbFHm/2JJuBtGq7yKPIYVNwoFb2VXJdfs/lA4VEeiDtVohNGkN+TmukqQuyahS
C5tlvgEz5udw9krlBvlUHrk7Q185sBasOAoDjzfrR1Pf0/v3WaQx/rPGF2u74GUp
b5fQrwU2Vo2eigMTutxQwmdCpOMl60KKGJyU2Odca3ZSWDHPaqQljUPK80+yDTML
GxAQCT11Cvy22TMPyYopQ/vE5vVIG0BlRPxXE2sxVk4pIxH/7W9+BaSW1icBQxIg
nevIqlKRjgACvchXtNZzHM1N/u7PcLSbtq7xg3dCArYEPBspTHyzPv6NhDCZ2/Df
Ms4/OJ/Ok7kk+keMd/7JwQIpHsNJDHtR1x80nznCa/OJ4XDrd/s5f7Un78x824fG
0H2LXTtvjnw6G6NWajwLvMjE9GyhrYgznaRELYaVZEMUHIs6n7cIgvVci4vy560D
ujjwq9S3hce8JzrBC0K8b0I37Db3tFTOAXZ3r3NJkM3rFJHRdqKazpOGkxYwyjtD
TltuW1ug8um9WK/hmou4FYZjA+GiPQ+y26vetKzAjhYrRChO9cLzraThxbPqtKCl
CNqoRzc+xZ+TkZi/JJG8sS6VmeQ+BkGBVrRQGChnS6/MkSR5aYv/oB6ouKLMSZYL
k6/N+kjgXFTbxik=
=gYFb
-----END PGP SIGNATURE-----

Attachment: pgpAHEEpnkfHC.pgp
Description: PGP signature


--- End Message ---

Reply via email to