From 0e657ae839f2f02cebbab3c14309d15f68085a2f Mon Sep 17 00:00:00 2001 From: Dhanraj E Date: Fri, 20 Nov 2026 02:12:05 +0530 Subject: [PATCH] cf-serverd: Fixed off-by-one stack overflow in acl_CheckPath() A 4096 character request path (OPENDIR/STAT on a directory with a PATH_MAX - 1 canonical path) wrote the NUL one byte past mangled_path. Skip the special variable check when the path does not fit. Changelog: Title Signed-off-by: Dhanraj E --- cf-serverd/server_access.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cf-serverd/server_access.c b/cf-serverd/server_access.c index 8ef0aa5c892..c960b987721 100644 --- a/cf-serverd/server_access.c +++ b/cf-serverd/server_access.c @@ -327,6 +327,11 @@ bool acl_CheckPath(const struct acl *acl, const char *reqpath, * e.g. turn "/path/to/192.168.1.1.json" * to "/path/to/$(connection.ip).json" */ char mangled_path[PATH_MAX]; + if (reqpath_len >= sizeof(mangled_path)) + { + /* Does not fit, same as an overflow in ReplaceSpecialVariables(). */ + return access; + } memcpy(mangled_path, reqpath, reqpath_len + 1); size_t mangled_path_len = ReplaceSpecialVariables(mangled_path, sizeof(mangled_path),