Skip to content

Commit

Permalink
[DCOM-293] Fix security misconfiguration vulnerability allowing local…
Browse files Browse the repository at this point in the history
… remote arbitrary code execution.
  • Loading branch information
beberlei committed Aug 31, 2015
1 parent f88896c commit 2b3648c
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 7 deletions.
3 changes: 2 additions & 1 deletion lib/Doctrine/ORM/Cache/Region/FileLockRegion.php
Expand Up @@ -61,7 +61,7 @@ class FileLockRegion implements ConcurrentRegion
*/
public function __construct(Region $region, $directory, $lockLifetime)
{
if ( ! is_dir($directory) && ! @mkdir($directory, 0777, true)) {
if ( ! is_dir($directory) && ! @mkdir($directory, 0775, true)) {
throw new \InvalidArgumentException(sprintf('The directory "%s" does not exist and could not be created.', $directory));
}

Expand Down Expand Up @@ -242,6 +242,7 @@ public function lock(CacheKey $key)
if ( ! @file_put_contents($filename, $lock->value, LOCK_EX)) {
return null;
}
chmod($filename, 0664);

return $lock;
}
Expand Down
Expand Up @@ -137,7 +137,7 @@ protected function execute(InputInterface $input, OutputInterface $output)

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

Expand Down
Expand Up @@ -79,7 +79,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
}

if ( ! is_dir($destPath)) {
mkdir($destPath, 0777, true);
mkdir($destPath, 0775, true);
}

$destPath = realpath($destPath);
Expand Down
3 changes: 2 additions & 1 deletion lib/Doctrine/ORM/Tools/EntityGenerator.php
Expand Up @@ -364,7 +364,7 @@ public function writeEntityClass(ClassMetadataInfo $metadata, $outputDirectory)
$dir = dirname($path);

if ( ! is_dir($dir)) {
mkdir($dir, 0777, true);
mkdir($dir, 0775, true);
}

$this->isNew = !file_exists($path) || (file_exists($path) && $this->regenerateEntityIfExists);
Expand All @@ -389,6 +389,7 @@ public function writeEntityClass(ClassMetadataInfo $metadata, $outputDirectory)
} elseif ( ! $this->isNew && $this->updateEntityIfExists) {
file_put_contents($path, $this->generateUpdatedEntityClass($metadata, $path));
}
chmod($path, 0664);
}

/**
Expand Down
3 changes: 2 additions & 1 deletion lib/Doctrine/ORM/Tools/EntityRepositoryGenerator.php
Expand Up @@ -147,11 +147,12 @@ public function writeEntityRepositoryClass($fullClassName, $outputDirectory)
$dir = dirname($path);

if ( ! is_dir($dir)) {
mkdir($dir, 0777, true);
mkdir($dir, 0775, true);
}

if ( ! file_exists($path)) {
file_put_contents($path, $code);
chmod($path, 0664);
}
}

Expand Down
5 changes: 3 additions & 2 deletions lib/Doctrine/ORM/Tools/Export/Driver/AbstractExporter.php
Expand Up @@ -130,7 +130,7 @@ public function setOutputDir($dir)
public function export()
{
if ( ! is_dir($this->_outputDir)) {
mkdir($this->_outputDir, 0777, true);
mkdir($this->_outputDir, 0775, true);
}

foreach ($this->_metadata as $metadata) {
Expand All @@ -139,12 +139,13 @@ public function export()
$path = $this->_generateOutputPath($metadata);
$dir = dirname($path);
if ( ! is_dir($dir)) {
mkdir($dir, 0777, true);
mkdir($dir, 0775, true);
}
if (file_exists($path) && !$this->_overwriteExistingFiles) {
throw ExportException::attemptOverwriteExistingFile($path);
}
file_put_contents($path, $output);
chmod($path, 0664);
}
}
}
Expand Down

1 comment on commit 2b3648c

@xrow
Copy link

@xrow xrow commented on 2b3648c Sep 2, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was reading (http://www.doctrine-project.org/2015/08/31/security_misconfiguration_vulnerability_in_various_doctrine_projects.html) that the mask is configurable by doctrine. This doesn`t look like it.

Please sign in to comment.