[ Avaa Bypassed ]




Upload:

Command:

hmhc3928@52.15.244.11: ~ $
Security
========

The Doctrine library is operating very close to your database and as such needs
to handle and make assumptions about SQL injection vulnerabilities.

It is vital that you understand how Doctrine approaches security, because
we cannot protect you from SQL injection.

Please also read the documentation chapter on Security in Doctrine DBAL. This
page only handles Security issues in the ORM.

- `DBAL Security Page <http://www.doctrine-project.org/projects/doctrine-dbal/en/current/reference/security.html>`

If you find a Security bug in Doctrine, please report it on Jira and change the
Security Level to "Security Issues". It will be visible to Doctrine Core
developers and you only.

User input and Doctrine ORM
---------------------------

The ORM is much better at protecting against SQL injection than the DBAL alone.
You can consider the following APIs to be safe from SQL injection:

- ``\Doctrine\ORM\EntityManager#find()`` and ``getReference()``.
- All values on Objects inserted and updated through ``Doctrine\ORM\EntityManager#persist()``
- All find methods on ``Doctrine\ORM\EntityRepository``.
- User Input set to DQL Queries or QueryBuilder methods through
    - ``setParameter()`` or variants
    - ``setMaxResults()``
    - ``setFirstResult()``
- Queries through the Criteria API on ``Doctrine\ORM\PersistentCollection`` and
  ``Doctrine\ORM\EntityRepository``.

You are **NOT** safe from SQL injection when using user input with:

- Expression API of ``Doctrine\ORM\QueryBuilder``
- Concatenating user input into DQL SELECT, UPDATE or DELETE statements or
  Native SQL.

This means SQL injections can only occur with Doctrine ORM when working with
Query Objects of any kind. The safe rule is to always use prepared statement
parameters for user objects when using a Query object.

.. warning::

    Insecure code follows, don't copy paste this.

The following example shows insecure DQL usage:

.. code-block:: php

    <?php

    // INSECURE
    $dql = "SELECT u
              FROM MyProject\Entity\User u
             WHERE u.status = '" .  $_GET['status'] . "'
         ORDER BY " . $_GET['orderField'] . " ASC";

For Doctrine there is absolutely no way to find out which parts of ``$dql`` are
from user input and which are not, even if we have our own parsing process
this is technically impossible. The correct way is:

.. code-block:: php

    <?php

    $orderFieldWhitelist = array('email', 'username');
    $orderField = "email";

    if (in_array($_GET['orderField'], $orderFieldWhitelist)) {
        $orderField = $_GET['orderField'];
    }

    $dql = "SELECT u
              FROM MyProject\Entity\User u
             WHERE u.status = ?1
         ORDER BY u." . $orderField . " ASC";

    $query = $entityManager->createQuery($dql);
    $query->setParameter(1, $_GET['status']);


Preventing Mass Assignment Vulnerabilities
------------------------------------------

ORMs are very convenient for CRUD applications and Doctrine is no exception.
However CRUD apps are often vulnerable to mass assignment security problems
when implemented naively.

Doctrine is not vulnerable to this problem out of the box, but you can easily
make your entities vulnerable to mass assignment when you add methods of
the kind ``updateFromArray()`` or ``updateFromJson()`` to them. A vulnerable
entity might look like this:

.. code-block:: php

    <?php

    /**
     * @Entity
     */
    class InsecureEntity
    {
        /** @Id @Column(type="integer") @GeneratedValue */
        private $id;
        /** @Column */
        private $email;
        /** @Column(type="boolean") */
        private $isAdmin;

        public function fromArray(array $userInput)
        {
            foreach ($userInput as $key => $value) {
                $this->$key = $value;
            }
        }
    }

Now the possiblity of mass-asignment exists on this entity and can
be exploited by attackers to set the "isAdmin" flag to true on any
object when you pass the whole request data to this method like:

.. code-block:: php

    <?php
    $entity = new InsecureEntity();
    $entity->fromArray($_POST);

    $entityManager->persist($entity);
    $entityManager->flush();

You can spot this problem in this very simple example easily. However
in combination with frameworks and form libraries it might not be
so obvious when this issue arises. Be careful to avoid this
kind of mistake.

How to fix this problem? You should always have a whitelist
of allowed key to set via mass assignment functions.

.. code-block:: php

    public function fromArray(array $userInput, $allowedFields = array())
    {
        foreach ($userInput as $key => $value) {
            if (in_array($key, $allowedFields)) {
                $this->$key = $value;
            }
        }
    }

Filemanager

Name Type Size Permission Actions
advanced-configuration.rst File 16.18 KB 0644
annotations-reference.rst File 37.16 KB 0644
architecture.rst File 7.52 KB 0644
association-mapping.rst File 31.32 KB 0644
basic-mapping.rst File 17.24 KB 0644
batch-processing.rst File 5.77 KB 0644
best-practices.rst File 3.61 KB 0644
caching.rst File 13.24 KB 0644
change-tracking-policies.rst File 5.13 KB 0644
configuration.rst File 4.29 KB 0644
dql-doctrine-query-language.rst File 60.95 KB 0644
events.rst File 30.98 KB 0644
faq.rst File 9.95 KB 0644
filters.rst File 3.38 KB 0644
improving-performance.rst File 2.66 KB 0644
inheritance-mapping.rst File 20.79 KB 0644
installation.rst File 131 B 0644
limitations-and-known-issues.rst File 7.66 KB 0644
metadata-drivers.rst File 6.02 KB 0644
namingstrategy.rst File 4.38 KB 0644
native-sql.rst File 34.31 KB 0644
partial-objects.rst File 3.52 KB 0644
php-mapping.rst File 8.82 KB 0644
query-builder.rst File 20.6 KB 0644
second-level-cache.rst File 24.02 KB 0644
security.rst File 4.68 KB 0644
tools.rst File 16.8 KB 0644
transactions-and-concurrency.rst File 13.9 KB 0644
unitofwork-associations.rst File 2.74 KB 0644
unitofwork.rst File 6.73 KB 0644
working-with-associations.rst File 22.24 KB 0644
working-with-objects.rst File 31.61 KB 0644
xml-mapping.rst File 27.11 KB 0644
yaml-mapping.rst File 4.42 KB 0644