Improve session cookie hashing#27
Merged
Merged
Conversation
Repository owner
deleted a comment from
coveralls
Dec 13, 2022
There was a problem hiding this comment.
Pull Request Overview
This pull request upgrades the session cookie signing algorithm from SHA-1 to SHA256, improves cookie security by enforcing HttpOnly and Secure flags, and adjusts session expiration settings.
- Upgrades hashing method in sign.go and removes deprecated libs.go
- Updates cookie format and expiration duration in session.go and mars.go
- Adds tests and fuzz tests for signing and session decoding
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| sign_test.go | Adds tests to ensure proper secret key setup and signature functionality |
| sign_fuzz_test.go | Introduces fuzz tests for signature verification |
| sign.go | Implements session signing using SHA256 with updated encoding |
| session_fuzz_test.go | Fuzz testing for session cookie decoding |
| session.go | Updates cookie structure and session expiration duration |
| mars.go | Enhances cookie flag defaults and initializes secret key appropriately |
| libs.go | Removes legacy SHA-1 based signing code |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Currently, Mars uses SHA-1 to sign the content of the session cookies, which is considered broken for nearly 20 years now.
This PR changes this to use SHA256 by default and improves overall security by enabling the “http only” and “secure” flags where applicable and if not set by the app's configuration. Also, a random app secret will be used, if none is set by the application.