uuid4 from Math.random is a security flaw

This commit is contained in:
Florian Mounier
2017-02-13 10:45:17 +01:00
parent 8553bbd0cb
commit 964fd07143
6 changed files with 18 additions and 28 deletions

View File

@@ -25,12 +25,6 @@ ws =
$ = document.querySelectorAll.bind(document)
uuid = ->
'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace /[xy]/g, (c) ->
r = Math.random() * 16 | 0
v = if c is 'x' then r else (r & 0x3|0x8)
v.toString(16)
document.addEventListener 'DOMContentLoaded', ->
term = null
@@ -46,7 +40,7 @@ document.addEventListener 'DOMContentLoaded', ->
wsUrl += document.location.host + rootPath
path = location.pathname
if path.indexOf('/session') < 0
path += "session/#{uuid()}"
path += "session/#{document.body.getAttribute('data-session-token')}"
path += location.search