Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2b3648c

Browse files
committed
[DCOM-293] Fix security misconfiguration vulnerability allowing local remote arbitrary code execution.
1 parent f88896c commit 2b3648c

6 files changed

Lines changed: 11 additions & 7 deletions

File tree

lib/Doctrine/ORM/Cache/Region/FileLockRegion.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class FileLockRegion implements ConcurrentRegion
6161
*/
6262
public function __construct(Region $region, $directory, $lockLifetime)
6363
{
64-
if ( ! is_dir($directory) && ! @mkdir($directory, 0777, true)) {
64+
if ( ! is_dir($directory) && ! @mkdir($directory, 0775, true)) {
6565
throw new \InvalidArgumentException(sprintf('The directory "%s" does not exist and could not be created.', $directory));
6666
}
6767

@@ -242,6 +242,7 @@ public function lock(CacheKey $key)
242242
if ( ! @file_put_contents($filename, $lock->value, LOCK_EX)) {
243243
return null;
244244
}
245+
chmod($filename, 0664);
245246

246247
return $lock;
247248
}

lib/Doctrine/ORM/Tools/Console/Command/ConvertMappingCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
137137

138138
// Process destination directory
139139
if ( ! is_dir($destPath = $input->getArgument('dest-path'))) {
140-
mkdir($destPath, 0777, true);
140+
mkdir($destPath, 0775, true);
141141
}
142142
$destPath = realpath($destPath);
143143

lib/Doctrine/ORM/Tools/Console/Command/GenerateProxiesCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
7979
}
8080

8181
if ( ! is_dir($destPath)) {
82-
mkdir($destPath, 0777, true);
82+
mkdir($destPath, 0775, true);
8383
}
8484

8585
$destPath = realpath($destPath);

lib/Doctrine/ORM/Tools/EntityGenerator.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ public function writeEntityClass(ClassMetadataInfo $metadata, $outputDirectory)
364364
$dir = dirname($path);
365365

366366
if ( ! is_dir($dir)) {
367-
mkdir($dir, 0777, true);
367+
mkdir($dir, 0775, true);
368368
}
369369

370370
$this->isNew = !file_exists($path) || (file_exists($path) && $this->regenerateEntityIfExists);
@@ -389,6 +389,7 @@ public function writeEntityClass(ClassMetadataInfo $metadata, $outputDirectory)
389389
} elseif ( ! $this->isNew && $this->updateEntityIfExists) {
390390
file_put_contents($path, $this->generateUpdatedEntityClass($metadata, $path));
391391
}
392+
chmod($path, 0664);
392393
}
393394

394395
/**

lib/Doctrine/ORM/Tools/EntityRepositoryGenerator.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,11 +147,12 @@ public function writeEntityRepositoryClass($fullClassName, $outputDirectory)
147147
$dir = dirname($path);
148148

149149
if ( ! is_dir($dir)) {
150-
mkdir($dir, 0777, true);
150+
mkdir($dir, 0775, true);
151151
}
152152

153153
if ( ! file_exists($path)) {
154154
file_put_contents($path, $code);
155+
chmod($path, 0664);
155156
}
156157
}
157158

lib/Doctrine/ORM/Tools/Export/Driver/AbstractExporter.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ public function setOutputDir($dir)
130130
public function export()
131131
{
132132
if ( ! is_dir($this->_outputDir)) {
133-
mkdir($this->_outputDir, 0777, true);
133+
mkdir($this->_outputDir, 0775, true);
134134
}
135135

136136
foreach ($this->_metadata as $metadata) {
@@ -139,12 +139,13 @@ public function export()
139139
$path = $this->_generateOutputPath($metadata);
140140
$dir = dirname($path);
141141
if ( ! is_dir($dir)) {
142-
mkdir($dir, 0777, true);
142+
mkdir($dir, 0775, true);
143143
}
144144
if (file_exists($path) && !$this->_overwriteExistingFiles) {
145145
throw ExportException::attemptOverwriteExistingFile($path);
146146
}
147147
file_put_contents($path, $output);
148+
chmod($path, 0664);
148149
}
149150
}
150151
}

0 commit comments

Comments
 (0)