No Basic auth for connection requests by default

A fix for a security vulnerability reported by Maximilian Hils.
This commit is contained in:
Zaid Abdulla committed 2018-01-11 06:20:25 -08:00
1 parent 88a50a3387
commit bbe4def5cf
2 files changed
+13 -3

No files matched your search

+11 -2
View File
@@ -65,8 +65,12 @@ udpConReq = (address, un, key, callback) ->
return true return true
httpConReq = (url, username, password, timeout, callback) -> httpConReq = (url, username, password, allowBasicAuth, timeout, callback) ->
options = URL.parse(url) options = URL.parse(url)
if options.protocol != 'http:'
return callback(new Error('Invalid connection request URL or protocol'))
# Ensure socket is reused in case of digest authentication # Ensure socket is reused in case of digest authentication
options.agent = new http.Agent({maxSockets : 1}) options.agent = new http.Agent({maxSockets : 1})
@@ -85,6 +89,10 @@ httpConReq = (url, username, password, timeout, callback) ->
if res.statusCode == 401 and res.headers['www-authenticate']? if res.statusCode == 401 and res.headers['www-authenticate']?
authHeader = auth.parseAuthHeader(res.headers['www-authenticate']) authHeader = auth.parseAuthHeader(res.headers['www-authenticate'])
if authHeader.method is 'Basic' if authHeader.method is 'Basic'
if not allowBasicAuth
request.abort()
callback(new Error('Basic HTTP authentication not allowed'))
return
options.headers = {'Authorization' : auth.basic(username or '', password or '')} options.headers = {'Authorization' : auth.basic(username or '', password or '')}
else if authHeader.method is 'Digest' else if authHeader.method is 'Digest'
options.headers = { options.headers = {
@@ -130,6 +138,7 @@ httpConReq = (url, username, password, timeout, callback) ->
connectionRequest = (deviceId, callback) -> connectionRequest = (deviceId, callback) ->
CONNECTION_REQUEST_TIMEOUT = config.get('CONNECTION_REQUEST_TIMEOUT', deviceId) CONNECTION_REQUEST_TIMEOUT = config.get('CONNECTION_REQUEST_TIMEOUT', deviceId)
CONNECTION_REQUEST_ALLOW_BASIC_AUTH = config.get('CONNECTION_REQUEST_ALLOW_BASIC_AUTH', deviceId)
proj = { proj = {
'Device.ManagementServer.ConnectionRequestURL._value' : 1, 'Device.ManagementServer.ConnectionRequestURL._value' : 1,
'Device.ManagementServer.UDPConnectionRequestAddress._value' : 1, 'Device.ManagementServer.UDPConnectionRequestAddress._value' : 1,
@@ -158,7 +167,7 @@ connectionRequest = (deviceId, callback) ->
conReq = () -> conReq = () ->
udpSent = udpConReq(udpConnectionRequestAddress, username, password, (err) -> throw err if err) udpSent = udpConReq(udpConnectionRequestAddress, username, password, (err) -> throw err if err)
httpConReq(connectionRequestUrl, username, password, CONNECTION_REQUEST_TIMEOUT, (err) -> httpConReq(connectionRequestUrl, username, password, CONNECTION_REQUEST_ALLOW_BASIC_AUTH, CONNECTION_REQUEST_TIMEOUT, (err) ->
if udpSent if udpSent
return callback() return callback()
callback(err) callback(err)
+2 -1
View File
@@ -66,7 +66,8 @@ options = {
ACCESS_LOG_FORMAT : {type : 'string', default : ''}, ACCESS_LOG_FORMAT : {type : 'string', default : ''},
MAX_CONCURRENT_REQUESTS : {type : 'int', default: 20}, MAX_CONCURRENT_REQUESTS : {type : 'int', default: 20},
DATETIME_MILLISECONDS : {type: 'bool', default: true}, DATETIME_MILLISECONDS : {type: 'bool', default: true},
BOOLEAN_LITERAL : {type: 'bool', default: true} BOOLEAN_LITERAL : {type: 'bool', default: true},
CONNECTION_REQUEST_ALLOW_BASIC_AUTH: {type: 'bool', default: false}
# XML configuration # XML configuration
XML_RECOVER : {type : 'bool', default : false}, XML_RECOVER : {type : 'bool', default : false},