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

Update the Rails security guide #25035

Merged
merged 1 commit into from
May 16, 2016
Merged

Conversation

ralinc
Copy link
Contributor

@ralinc ralinc commented May 16, 2016

Bring up-to-date the information about the session id in the
Sessions section. The guide currently says that the session
id is a md5 hash while the implementation uses a random hex
string.

Fixes #25032.

[ci skip]

Bring up-to-date the information about the session id in the
Sessions section. The guide currently says that the session
id is a md5 hash while the implementation uses a random hex
string.

Fixes rails#25032.

[ci skip]
@rails-bot
Copy link

Thanks for the pull request, and welcome! The Rails team is excited to review your changes, and you should hear from @matthewd (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@@ -50,9 +50,9 @@ User.find(session[:user_id])

### Session id

NOTE: _The session id is a 32 byte long MD5 hash value._
NOTE: _The session id is a 32-character random hex string._
Copy link
Member

Choose a reason for hiding this comment

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

Don't believe this is 32, can you check and confirm?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The code:

def generate_sid
    sid = SecureRandom.hex(16)
    sid.encode!(Encoding::UTF_8)
    sid
end

The line SecureRandom.hex(16) generates 32-character string as per documentation:

SecureRandom::hex

The argument n specifies the length, in bytes, of the random number to be generated. The length of the resulting hexadecimal string is twice n.

@vipulnsward vipulnsward merged commit a3aa536 into rails:master May 16, 2016
@vipulnsward
Copy link
Member

Thanks @ralinchimev !

@ralinc ralinc deleted the update-security-guide branch May 16, 2016 20:07
@ralinc
Copy link
Contributor Author

ralinc commented May 16, 2016

Thank you @vipulnsward

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants