Skip to content

Commit 9125f5a

Browse files
committed
Mitigate CSRF in profile's SSH Keys #212
1 parent 73a369a commit 9125f5a

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,12 @@ Professional support for Rdiffweb is available by contacting [IKUS Soft](https:/
107107

108108
# Changelog
109109

110+
## 2.4.3 (2022-09-14)
111+
112+
This releases include a security fix. If you are using an earlier version, you should upgrade to this release immediately.
113+
114+
* Mitigate CSRF in profile's SSH Keys #212
115+
110116
## 2.4.2 (2022-09-12)
111117

112118
This releases include a security fix. If you are using an earlier version, you should upgrade to this release immediately.

rdiffweb/controller/pref_sshkeys.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,10 @@ def render_prefs_panel(self, panelid, action=None, **kwargs): # @UnusedVariable
111111

112112
# Handle action
113113
form = SshForm()
114-
if action == "add":
114+
delete_form = DeleteSshForm()
115+
if action == "add" and form.is_submitted():
115116
self._add_key(action, form)
116-
elif action == 'delete':
117+
elif action == 'delete' and delete_form.is_submitted():
117118
self._delete_key(action, DeleteSshForm())
118119

119120
# Get SSH keys if file exists.

rdiffweb/controller/tests/test_page_prefs_ssh.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,18 @@ def test_add_invalid(self):
9999
self.assertInBody("Invalid SSH key.")
100100
self.assertEqual(0, len(list(user.authorizedkeys)))
101101

102+
def test_add_get_method(self):
103+
# Given an authenticated user
104+
user = self.app.store.get_user('admin')
105+
# When querying a page with parameters (HTTP GET)
106+
self.getPage(
107+
"/prefs/sshkeys?action=add&title=ssh1&key=ssh-rsa+AAAAB3NzaC1yc2EAAAADAQABAAAAgQCzurRNVKwb0ZJCmUgGenoe4vth5gnHxgnzjHSUO8r7IZiouB6DAciiVUAryV6MQm5trwIXNo0QDwFxyX99exIwUlDu3OzhZHKKbb721hCID17AWZMAQIgxQdu6b27s5YgJXsaxXWvEO2lSRVOnVXoCSI7mK5St%2FCJ8O1OdXivNIQ%3D%3D+noname%0D%0A"
108+
)
109+
# Then page return without error
110+
self.assertStatus(200)
111+
# Then ssh key is not added
112+
self.assertEqual(0, len(list(user.authorizedkeys)))
113+
102114
def test_delete(self):
103115
# Delete existing keys
104116
user = self.app.store.get_user('admin')

0 commit comments

Comments
 (0)