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

generateRandomToken improvement. #1176

Open
wants to merge 3 commits into
base: hotfix
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
22 changes: 22 additions & 0 deletions .github/SECURITY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Security Policy

## Supported Versions

With some exceptions, only the latest minor version (4.x), currently receive patches for security vulnerabilities.
The previous minor version _might_ be patched if the fix is simple. No update shall be done to previous major version (aka 3.x) or previous minor releases at this time.

## Reporting a Vulnerability

Please report (suspected) security vulnerabilities to the main contributors (listed below) by contacting us directly or on [Chat](https://chat.userfrosting.com).
If you have a fix, don't hesitate to explain or attach it. Using the issue system should be avoided for suspected security vulnerabilities.
We'll try our best to reply in due time. If the issue is confirmed, we will see to release a patch as soon as possible depending on complexity.

### Main contributors:
- [@alexweissman](https://github.com/alexweissman)
- [@lcharette](https://github.com/lcharette) - [email protected]
- [@Silic0nS0ldier](https://github.com/Silic0nS0ldier)

## Comments on this Policy

If you have suggestions on how this process could be improved please submit a
pull request.
2 changes: 1 addition & 1 deletion app/sprinkles/account/src/Repository/TokenRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ public function removeExpired()
protected function generateRandomToken($gen = null)
{
do {
$gen = md5(uniqid(mt_rand(), false));
$gen = bin2hex(random_bytes(16));
} while ($this->classMapper->getClassMapping($this->modelIdentifier)
::where('hash', hash($this->algorithm, $gen))
->first());
Expand Down
3 changes: 1 addition & 2 deletions app/sprinkles/core/src/Util/Captcha.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,7 @@ public function __construct(Session $session, $key)
*/
public function generateRandomCode()
{
$md5_hash = md5(rand(0, 99999));
$this->code = substr($md5_hash, 25, 5);
$this->code = substr( bin2hex( random_bytes( 3 ) ), 0, 5 );
$enc = md5($this->code);

// Store the generated captcha value to the session
Expand Down