Skip to content

Commit 626cca1

Browse files
committed
Define field limit for SSH Key title
1 parent 667657c commit 626cca1

File tree

3 files changed

+26
-2
lines changed

3 files changed

+26
-2
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,14 +107,15 @@ Professional support for Rdiffweb is available by contacting [IKUS Soft](https:/
107107

108108
# Changelog
109109

110-
## 2.4.8 (2022-09-24)
110+
## 2.4.8 (2022-09-26)
111111

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

114114
* Clean-up invalid path on error page
115115
* Limit username field length [CVE-2022-3290](https://nvd.nist.gov/vuln/detail/CVE-2022-3290)
116116
* Limit user's email field length [CVE-2022-3272](https://nvd.nist.gov/vuln/detail/CVE-2022-3272)
117117
* Limit user's root directory field length [CVE-2022-3295](https://nvd.nist.gov/vuln/detail/CVE-2022-3295)
118+
* Limit SSH Key title field length [CVE-2022-3298](https://nvd.nist.gov/vuln/detail/CVE-2022-3298)
118119

119120
## 2.4.7 (2002-09-21)
120121

rdiffweb/controller/pref_sshkeys.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,13 @@ class SshForm(CherryForm):
5050
title = StringField(
5151
_('Title'),
5252
description=_('The title is an optional description to identify the key. e.g.: bob@thinkpad-t530'),
53-
validators=[validators.data_required()],
53+
validators=[
54+
validators.data_required(),
55+
validators.length(
56+
max=256,
57+
message=_('Title too long.'),
58+
),
59+
],
5460
)
5561
key = StringField(
5662
_('Key'),

rdiffweb/controller/tests/test_page_prefs_ssh.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,23 @@ def test_add_get_method(self):
111111
# Then ssh key is not added
112112
self.assertEqual(0, len(list(user.authorizedkeys)))
113113

114+
def test_add_with_title_too_long(self):
115+
# Given an authenticated user without any ssh keys
116+
user = self.app.store.get_user('admin')
117+
for key in user.authorizedkeys:
118+
user.delete_authorizedkey(key.fingerprint)
119+
self.assertEqual(0, len(list(user.authorizedkeys)))
120+
# When adding a key with title too long.
121+
self._add_ssh_key(
122+
"title" * 52,
123+
"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDSEN5VTn9MLituZvdYTZMbZEaMxe0UuU7BelxHkvxzSpVWtazrIBEc3KZjtVoK9F3+0kd26P4DzSQuPUl3yZDgyZZeXrF6p2GlEA7A3tPuOEsAQ9c0oTiDYktq5/Go8vD+XAZKLd//qmCWW1Jg4datkWchMKJzbHUgBrBH015FDbGvGDWYTfVyb8I9H+LQ0GmbTHsuTu63DhPODncMtWPuS9be/flb4EEojMIx5Vce0SNO9Eih38W7jTvNWxZb75k5yfPJxBULRnS5v/fPnDVVtD3JSGybSwKoMdsMX5iImAeNhqnvd8gBu1f0IycUQexTbJXk1rPiRcF13SjKrfXz ikus060@ikus060-t530",
124+
)
125+
# Then page return with error
126+
self.assertStatus('200 OK')
127+
self.assertInBody('Title too long.')
128+
# Then key is not added
129+
self.assertEqual(0, len(list(user.authorizedkeys)))
130+
114131
def test_delete(self):
115132
# Delete existing keys
116133
user = self.app.store.get_user('admin')

0 commit comments

Comments
 (0)