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

Avoid cross origin forgery by using same-site cookie #2948

Merged
merged 2 commits into from
Jun 3, 2021
Merged
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
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