File tree Expand file tree Collapse file tree
src/PrefillGravityForms/GravityForms Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -316,6 +316,29 @@ private function getCertificateLocation(): string
316316 */
317317 private function getRootPathToCertificates (): string
318318 {
319- return (! empty (GravityFormsSettings::make ()->get ('location-root-path-certificates ' ))) ? GravityFormsSettings::make ()->get ('location-root-path-certificates ' ) : storage_path ('certificates ' );
319+ $ configured = GravityFormsSettings::make ()->get ('location-root-path-certificates ' );
320+ $ fallback = storage_path ('certificates ' );
321+
322+ if (empty ($ configured )) {
323+ return $ fallback ;
324+ }
325+
326+ $ realPath = realpath ($ configured );
327+
328+ if (false === $ realPath ) {
329+ return $ fallback ;
330+ }
331+
332+ $ safeBase = realpath (\ABSPATH . '/../../ ' );
333+
334+ if (! str_starts_with ($ realPath , $ safeBase . DIRECTORY_SEPARATOR )) {
335+ return $ fallback ;
336+ }
337+
338+ if (! is_dir ($ realPath ) || ! is_readable ($ realPath )) {
339+ return $ fallback ;
340+ }
341+
342+ return $ realPath ;
320343 }
321344}
You can’t perform that action at this time.
0 commit comments