Skip to content

Commit

Permalink
fix(settings): mitigate xss
Browse files Browse the repository at this point in the history
Mitigate XSS on wifi scanning from injecting arbitrary code by using
`textConent` instead of `innerHTML`.

Partially Fixes Aircoookie#3233
  • Loading branch information
jkoelker committed Jun 10, 2023
1 parent 999bec1 commit d18d800
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions wled00/data/settings_wifi.htm
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

const button = gId("scan");
button.disabled = true;
button.innerHTML = "Scanning...";
button.textContent = "Scanning...";

fetch(url).then((response) => {
return response.json();
Expand Down Expand Up @@ -70,7 +70,7 @@
const option = cE("option");

option.setAttribute("value", networks[i].ssid);
option.innerHTML = `${networks[i].ssid} (${networks[i].rssi} dBm)`;
option.textContent = `${networks[i].ssid} (${networks[i].rssi} dBm)`;

if (networks[i].ssid === cs.value) {
option.setAttribute("selected", "selected");
Expand All @@ -81,14 +81,14 @@
const option = cE("option");

option.setAttribute("value", "!Cs");
option.innerHTML = `Other network...`;
option.textContent = `Other network...`;
select.appendChild(option);

cs.replaceWith(select);
}

button.disabled = false;
button.innerHTML = "Scan";
button.textContent = "Scan";
});
}
// replace WiFi select with custom SSID input field again
Expand Down

0 comments on commit d18d800

Please sign in to comment.