Common stuff for all my devices' web server pages: css, login, log, ipv4, ipv6, firmware update, clock, reset info etc.

Dependents:   oldheating gps motorhome heating

Security

A password has to be set whenever there has been a software reset. Resets following faults or power on do not require a new password as the hash is restored from the RTC GPREG register.

The password is not saved on the device; instead a 32 bit hash of the password is saved. It would take 2^31 attempts to brute force the password: this could be done in under a month if an attempt were possible every millisecond. To prevent this a 200 ms delay is introduced in the reply to the login form, that gives a more reasonable 13 years to brute force the password.

Once the password is accepted a random session id is created. This is 36 bit to give six base 64 characters but without an extra delay. If an attempt could be made every ms then this would still take over a year to brute force.

The most likely attack would to use a dictionary with, say, 10 million entries against the password which would still take 20 days to do.

Committer:
andrewboyson
Date:
Tue Mar 05 12:26:36 2019 +0000
Revision:
53:27d56a22a450
Parent:
51:c605b2794b44
Child:
55:3d1e52e3e9b7
Removed firmware checksum

Who changed what in which revision?

UserRevisionLine numberNew contents of line
andrewboyson 50:edd44fe9320f 1 "'use strict';\n"
andrewboyson 50:edd44fe9320f 2 "\n"
andrewboyson 48:4e678727c4c9 3 "var file;\n"
andrewboyson 46:1822fdbe6c0c 4 "var xhr;\n"
andrewboyson 48:4e678727c4c9 5 "\n"
andrewboyson 50:edd44fe9320f 6 "function log(text)\n"
andrewboyson 50:edd44fe9320f 7 "{\n"
andrewboyson 50:edd44fe9320f 8 " document.getElementById('result').textContent = text;\n"
andrewboyson 50:edd44fe9320f 9 "}\n"
andrewboyson 51:c605b2794b44 10 "function displayResponse()\n"
andrewboyson 51:c605b2794b44 11 "{\n"
andrewboyson 51:c605b2794b44 12 " var topics = xhr.responseText.split('\\f');\n"
andrewboyson 51:c605b2794b44 13 " log(topics[0]);\n"
andrewboyson 51:c605b2794b44 14 " if (topics.length > 1) document.getElementById('list').textContent = topics[1];\n"
andrewboyson 51:c605b2794b44 15 "}\n"
andrewboyson 46:1822fdbe6c0c 16 "function xhrOnLoad()\n"
andrewboyson 46:1822fdbe6c0c 17 "{\n"
andrewboyson 51:c605b2794b44 18 " if (xhr.status == 200) displayResponse();\n"
andrewboyson 50:edd44fe9320f 19 " else log('Upload failed');\n"
andrewboyson 46:1822fdbe6c0c 20 "}\n"
andrewboyson 46:1822fdbe6c0c 21 "function xhrOnError()\n"
andrewboyson 46:1822fdbe6c0c 22 "{\n"
andrewboyson 50:edd44fe9320f 23 " log('Upload error');\n"
andrewboyson 46:1822fdbe6c0c 24 "}\n"
andrewboyson 48:4e678727c4c9 25 "function startXhr()\n"
andrewboyson 48:4e678727c4c9 26 "{\n"
andrewboyson 50:edd44fe9320f 27 " log('Uploading...');\n"
andrewboyson 48:4e678727c4c9 28 " \n"
andrewboyson 48:4e678727c4c9 29 " xhr = new XMLHttpRequest();\n"
andrewboyson 48:4e678727c4c9 30 "\n"
andrewboyson 48:4e678727c4c9 31 " xhr.onload = xhrOnLoad;\n"
andrewboyson 48:4e678727c4c9 32 " xhr.onerror = xhrOnError;\n"
andrewboyson 48:4e678727c4c9 33 "\n"
andrewboyson 53:27d56a22a450 34 " xhr.open('POST', '/firmware-ajax'); //Defaults to async=true\n"
andrewboyson 48:4e678727c4c9 35 " xhr.send(file);\n"
andrewboyson 48:4e678727c4c9 36 "}\n"
andrewboyson 48:4e678727c4c9 37 "\n"
andrewboyson 46:1822fdbe6c0c 38 "function startUpload()\n"
andrewboyson 46:1822fdbe6c0c 39 "{\n"
andrewboyson 46:1822fdbe6c0c 40 " var fileInput = document.getElementById('fileInput');\n"
andrewboyson 46:1822fdbe6c0c 41 "\n"
andrewboyson 46:1822fdbe6c0c 42 " if (fileInput.files.length == 0)\n"
andrewboyson 46:1822fdbe6c0c 43 " {\n"
andrewboyson 50:edd44fe9320f 44 " log('Please choose a file');\n"
andrewboyson 46:1822fdbe6c0c 45 " return;\n"
andrewboyson 46:1822fdbe6c0c 46 " }\n"
andrewboyson 46:1822fdbe6c0c 47 "\n"
andrewboyson 46:1822fdbe6c0c 48 " if (fileInput.files.length > 1)\n"
andrewboyson 46:1822fdbe6c0c 49 " {\n"
andrewboyson 50:edd44fe9320f 50 " log('Please choose just one file');\n"
andrewboyson 46:1822fdbe6c0c 51 " return;\n"
andrewboyson 46:1822fdbe6c0c 52 " }\n"
andrewboyson 48:4e678727c4c9 53 " \n"
andrewboyson 48:4e678727c4c9 54 " file = fileInput.files[0];\n"
andrewboyson 48:4e678727c4c9 55 " \n"
andrewboyson 53:27d56a22a450 56 " startXhr();\n"
andrewboyson 48:4e678727c4c9 57 "}\n"
andrewboyson 48:4e678727c4c9 58 ""