# HG changeset patch # User Roy Marples # Date 1590328181 -3600 # Node ID 95976721c27ddd059aee4979171c291d41c37586 # Parent 9ea5c678d8a6266b38f60b9a817fe8c1f68058e1 privsep: Avoid the /proc/../ escape diff -r 9ea5c678d8a6 -r 95976721c27d src/privsep-root.c --- a/src/privsep-root.c Sun May 24 14:32:15 2020 +0100 +++ b/src/privsep-root.c Sun May 24 14:49:41 2020 +0100 @@ -288,6 +288,11 @@ ps_root_validpath(const struct dhcpcd_ctx *ctx, uint16_t cmd, const char *path) { + /* Avoid a previous directory attack to avoid /proc/../ + * dhcpcd should never use a path with double dots. */ + if (strstr(path, "..") != NULL) + return false; + if (cmd == PS_READFILE) { if (strcmp(ctx->cffile, path) == 0) return true;