Skip to content

Commit

Permalink
Merge pull request #2948 from bjoernricks/same-site-session-cookie
Browse files Browse the repository at this point in the history
Avoid cross origin forgery by using same-site cookie
  • Loading branch information
bjoernricks committed Jun 3, 2021
2 parents 7b97bb0 + d0b8867 commit a6c8b7b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,15 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
## [20.8.2] - Unreleased

### Added
- Set SameSite=strict for the session cookie to avoid CSRF [#2948](https://github.com/greenbone/gsa/pull/2948)

### Changed
- Use greenbone sensor as default scanner type when opening the dialog if available [#2867](https://github.com/greenbone/gsa/pull/2867)

### Fixed
- Fixed setting whether to include related resources for new permissions [#2931](https://github.com/greenbone/gsa/pull/2891)
- Fixed setting secret key in RADIUS dialog, backport from [#2891](https://github.com/greenbone/gsa/pull/2891), [#2915](https://github.com/greenbone/gsa/pull/2915)

### Removed

[20.8.2]: https://github.com/greenbone/gsa/compare/v20.8.1...gsa-20.08
Expand Down
11 changes: 6 additions & 5 deletions gsad/src/gsad_http.c
Original file line number Diff line number Diff line change
Expand Up @@ -516,9 +516,9 @@ remove_sid (http_response_t *response)
* Tim Brown's suggested cookie included a domain attribute. How would
* we get the domain in here? Maybe a --domain option. */

value =
g_strdup_printf (SID_COOKIE_NAME "=0; expires=%s; path=/; %sHTTPonly",
expires, (is_use_secure_cookie () ? "secure; " : ""));
value = g_strdup_printf (
SID_COOKIE_NAME "=0; expires=%s; path=/; %sHTTPonly; SameSite=strict",
expires, (is_use_secure_cookie () ? "secure; " : ""));
ret = MHD_add_response_header (response, "Set-Cookie", value);
g_free (value);
return ret;
Expand Down Expand Up @@ -592,8 +592,9 @@ attach_sid (http_response_t *response, const char *sid)
* we get the domain in here? Maybe a --domain option. */

value = g_strdup_printf (
SID_COOKIE_NAME "=%s; expires=%s; max-age=%d; path=/; %sHTTPonly", sid,
expires, timeout, (is_use_secure_cookie () ? "secure; " : ""));
SID_COOKIE_NAME
"=%s; expires=%s; max-age=%d; path=/; %sHTTPonly; SameSite=strict",
sid, expires, timeout, (is_use_secure_cookie () ? "secure; " : ""));
ret = MHD_add_response_header (response, "Set-Cookie", value);
g_free (value);
return ret;
Expand Down

0 comments on commit a6c8b7b

Please sign in to comment.