Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added a tip about hashing the result of nextBytes() #5472

Merged
merged 2 commits into from
Jul 16, 2015
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions components/security/secure_tools.rst
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,14 @@ to work correctly. Just pass a file name to enable it::

.. note::

If you're using the Symfony Framework, you can access a secure random
instance directly from the container: its name is ``security.secure_random``.
If you're using the Symfony Framework, you can get a secure random number
generator via the ``security.secure_random`` service.

.. tip::

The ``nextBytes()`` method returns a binary string which may contain the
``\0`` character. If you store this value in a database or include it as
part of the URL, make sure to hash the value returned by ``nextBytes()``
(to do that, you can use a simple ``md5()`` PHP function).
Copy link
Member

Choose a reason for hiding this comment

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

Not sure if we should limit the tip to these two scenarios. There could be lots of third-party systems you need so send data to which may or may not be capable of handling strings containing the null byte. Could we/should we write this more generic?

Copy link
Member Author

Choose a reason for hiding this comment

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

I agree. I've reworded this tip. Thanks.


.. _`Timing attack`: http://en.wikipedia.org/wiki/Timing_attack