Re: [SMARTY] Bug in security?

From: Date: Sun, 29 Jun 2003 09:52:51 +0000
Subject: Re: [SMARTY] Bug in security?
References: 1 2  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-9792@lists.php.net to get a copy of this message
On Sat, Jun 28, 2003 at 04:15:40PM +0100, John Wards wrote: > ----- Original Message ----- > From: "John Wards" <j.wards@sportnetwork.net> > > Within smarty.class there is a bit of code that looks like this (around > > line: 1430) > > > > if (substr(realpath($resource_name),0, strlen(realpath($curr_dir))) == > > realpath($curr_dir)) { > > $_smarty_secure = true; > > break; > > } > > This fixes it if $resource_name is a path to a file, but it doesn't work if > $resource_name is a directory. Would $resource_name ever be a directory for > any reason? > > if (substr(realpath($resource_name),0, strlen(realpath($curr_dir))) == > realpath($curr_dir)) { > //Double Check > $temp = basename($resource_name); > $temp2 = str_replace("/".$temp,"",$resource_name); > if(realpath($curr_dir) == $temp2){ > $_smarty_secure = true; > break; > } > } > > Can anyone think of a better solution? > hmm, i tried this: if (substr($_rp = realpath($params['resource_name']),0, strlen(realpath($curr_dir))) == realpath($curr_dir) && $_rp{strlen($curr_dir)} == DIRECTORY_SEPARATOR) { $_smarty_secure = true; break; } it looks good to me, but i have to test it more excessively. > Cheers > John

« previous php.smarty.general (#9792) next »