Skip to content

Commit e70e8d2

Browse files
authored
Merge pull request #45 from RafaelFernandesBR/teleNVDA
Correction for CVE-2025-26326
2 parents 75fcc34 + 9f677ad commit e70e8d2

File tree

1 file changed

+53
-8
lines changed

1 file changed

+53
-8
lines changed

addon/globalPlugins/remoteClient/dialogs.py

Lines changed: 53 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -220,15 +220,42 @@ def on_client_or_server(self, evt):
220220
self.panel = ServerPanel(parent=self.container)
221221
self.main_sizer.Fit(self)
222222

223+
def is_sequential(self, password):
224+
if len(password) < 3:
225+
return False
226+
for i in range(len(password) - 2):
227+
if ord(password[i]) == ord(password[i + 1]) - 1 == ord(password[i + 2]) - 2:
228+
return True
229+
return False
230+
223231
def on_ok(self, evt):
224-
if self.client_or_server.GetSelection() == 0 and (not self.panel.host.GetValue() or not self.panel.key.GetValue()):
225-
gui.messageBox(_("Both host and key must be set."), _("Error"), wx.OK | wx.ICON_ERROR)
226-
self.panel.host.SetFocus()
227-
elif self.client_or_server.GetSelection() == 1 and not self.panel.port.GetValue() or not self.panel.key.GetValue():
228-
gui.messageBox(_("Both port and key must be set."), _("Error"), wx.OK | wx.ICON_ERROR)
229-
self.panel.port.SetFocus()
230-
else:
231-
evt.Skip()
232+
if self.client_or_server.GetSelection() == 0:
233+
if not self.panel.host.GetValue() or not self.panel.key.GetValue():
234+
gui.messageBox(_("Both host and key must be set."), _("Error"), wx.OK | wx.ICON_ERROR)
235+
self.panel.host.SetFocus()
236+
return
237+
elif len(self.panel.key.GetValue()) < 6:
238+
gui.messageBox(_("The key must be longer than 6 characters."), _("Error"), wx.OK | wx.ICON_ERROR)
239+
self.panel.key.SetFocus()
240+
return
241+
elif self.is_sequential(self.panel.key.GetValue()):
242+
gui.messageBox(_("The key must not be sequential."), _("Error"), wx.OK | wx.ICON_ERROR)
243+
self.panel.key.SetFocus()
244+
return
245+
elif self.client_or_server.GetSelection() == 1:
246+
if not self.panel.port.GetValue() or not self.panel.key.GetValue():
247+
gui.messageBox(_("Both port and key must be set."), _("Error"), wx.OK | wx.ICON_ERROR)
248+
self.panel.port.SetFocus()
249+
return
250+
elif len(self.panel.key.GetValue()) < 6:
251+
gui.messageBox(_("The key must be longer than 6 characters."), _("Error"), wx.OK | wx.ICON_ERROR)
252+
self.panel.key.SetFocus()
253+
return
254+
elif self.is_sequential(self.panel.key.GetValue()):
255+
gui.messageBox(_("The key must not be sequential."), _("Error"), wx.OK | wx.ICON_ERROR)
256+
self.panel.key.SetFocus()
257+
return
258+
evt.Skip()
232259

233260
class OptionsDialog(SettingsPanel):
234261

@@ -356,6 +383,16 @@ def onSave(self):
356383
elif self.client_or_server.GetSelection() and not self.port.GetValue() or not self.key.GetValue():
357384
gui.messageBox(_("Both port and key must be set."), _("Error"), wx.OK | wx.ICON_ERROR)
358385
raise
386+
if len(self.key.GetValue()) < 6:
387+
# Translators: error message for key/password length less than 6 characters
388+
gui.messageBox(_("The key must be longer than 6 characters."), _("Error"), wx.OK | wx.ICON_ERROR)
389+
self.key.SetFocus()
390+
raise
391+
elif self.is_sequential(self.key.GetValue()):
392+
# Translators: error message for key/password being sequential, example 123456
393+
gui.messageBox(_("The key must not be sequential."), _("Error"), wx.OK | wx.ICON_ERROR)
394+
self.key.SetFocus()
395+
raise
359396
NVDAConfig.conf.profiles[-1].name = self.originalProfileName
360397
config = configuration.get_config()
361398
cs = config['controlserver']
@@ -378,6 +415,14 @@ def onSave(self):
378415
config['ui']['portcheck'] = self.portcheck.GetValue()
379416
config.write()
380417

418+
def is_sequential(self, password):
419+
if len(password) < 3:
420+
return False
421+
for i in range(len(password) - 2):
422+
if ord(password[i]) == ord(password[i + 1]) - 1 == ord(password[i + 2]) - 2:
423+
return True
424+
return False
425+
381426
class CertificateUnauthorizedDialog(wx.MessageDialog):
382427

383428
def __init__(self, parent, fingerprint=None):

0 commit comments

Comments
 (0)