ssh2shell 2.0.10 → 2.0.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ssh2shell",
3
- "version": "2.0.10",
3
+ "version": "2.0.12",
4
4
  "author": "cmp-202",
5
5
  "description": "A wrapper class for ssh2 to run multiple sequential commands in an SSH shell session, handle command responses, and tunnel through to other hosts using nested host objects",
6
6
  "main": "./lib/ssh2shell.js",
@@ -323,7 +323,6 @@ class SSH2Shell extends Stream
323
323
  sshFlags += "T" if @sshObj.server.ssh.disablePseudoTTY
324
324
  sshFlags += "t" if @sshObj.server.ssh.forcePseudoTTY
325
325
  sshFlags += "v" if @sshObj.server.ssh.verbose
326
-
327
326
  sshOptions += " -c " + @sshObj.server.ssh.cipherSpec if @sshObj.server.ssh.cipherSpec
328
327
  sshOptions += " -e " + @sshObj.server.ssh.escape if @sshObj.server.ssh.escape
329
328
  sshOptions += " -E " + @sshObj.server.ssh.logFile if @sshObj.server.ssh.logFile
@@ -332,7 +331,14 @@ class SSH2Shell extends Stream
332
331
  sshOptions += " -l " + @sshObj.server.ssh.loginName if @sshObj.server.ssh.loginName
333
332
  sshOptions += " -m " + @sshObj.server.ssh.macSpec if @sshObj.server.ssh.macSpec
334
333
  shellQuote = (value) -> "'" + String(value).replace(/'/g, "'\\''") + "'"
335
- sshOptions += " -o " + shellQuote("#{option}=#{value}") for option, value of (@sshObj.server.ssh.options or {})
334
+ shellControlChars = /[;&|`$\n\r]/
335
+ for option, value of (@sshObj.server.ssh.options or {})
336
+ if shellControlChars.test(option) or shellControlChars.test(value)
337
+ @.emit 'error',"Malicious characters detected in SSH options.","Security Alert",true
338
+ return
339
+ safeOption = String(option).replace(/[^a-zA-Z0-9]/g, "")
340
+ safeValue = shellQuote(value)
341
+ sshOptions += " -o #{safeOption}=#{safeValue}"
336
342
  sshOptions += ' -o "StrictHostKeyChecking=no"'
337
343
  sshOptions += " -p #{@sshObj.server.port}"
338
344
  @sshObj.sshAuth = false