Skip to content

Commit caf30b8

Browse files
committed
[DCOM-293] Fix security misconfiguration vulnerability allowing local remote arbitrary code execution.
1 parent 0cf7e0e commit caf30b8

File tree

5 files changed

+9
-6
lines changed

5 files changed

+9
-6
lines changed

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

+1-1
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

+1-1
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

+2-1
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ public function writeEntityClass(ClassMetadataInfo $metadata, $outputDirectory)
340340
$dir = dirname($path);
341341

342342
if ( ! is_dir($dir)) {
343-
mkdir($dir, 0777, true);
343+
mkdir($dir, 0775, true);
344344
}
345345

346346
$this->isNew = !file_exists($path) || (file_exists($path) && $this->regenerateEntityIfExists);
@@ -365,6 +365,7 @@ public function writeEntityClass(ClassMetadataInfo $metadata, $outputDirectory)
365365
} elseif ( ! $this->isNew && $this->updateEntityIfExists) {
366366
file_put_contents($path, $this->generateUpdatedEntityClass($metadata, $path));
367367
}
368+
chmod($path, 0664);
368369
}
369370

370371
/**

lib/Doctrine/ORM/Tools/EntityRepositoryGenerator.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,12 @@ public function writeEntityRepositoryClass($fullClassName, $outputDirectory)
9696
$dir = dirname($path);
9797

9898
if ( ! is_dir($dir)) {
99-
mkdir($dir, 0777, true);
99+
mkdir($dir, 0775, true);
100100
}
101101

102102
if ( ! file_exists($path)) {
103103
file_put_contents($path, $code);
104+
chmod($path, 0664);
104105
}
105106
}
106107
}

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

+3-2
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)