You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I named my router "<script>alert(1)</script>" because I thought it'd be funny, and sometimes I run into websites that randomly break :) In this case, navigating to the wifi settings page caused it.
To Reproduce Bug
Set your router's SSID to something containing the string "</script>" and navigate to the wifi settings page
Expected Behavior
I expect the page to be properly displayed
Install Method
Binary from WLED.me
What version of WLED?
0.13.1
Which microcontroller/board are you seeing the problem on?
Hey! This issue has been open for quite some time without any new comments now. It will be closed automatically in a week if no further activity occurs.
Thank you for using WLED!
#!/bin/bashecho"=== Revisions ==="
git rev-parse HEAD
gh api repos/wled/WLED/branches/main --jq '.commit.sha'echo"=== Outlines ==="
ast-grep outline wled00/xml.cpp --items all
ast-grep outline wled00/wled_server.cpp --items all --match 'settings|Settings|serve'
ast-grep outline wled00/data/settings_wifi.htm --items all ||trueecho"=== Script creation and serving references ==="
rg -n -C 3 'settingsScript|generateSettings|/settings|addWiFi\(|getSettings|innerHTML|loadJS' wled00/xml.cpp wled00/wled_server.cpp wled00/data/settings_wifi.htm wled00/data/common.js wled00/data/settings.htm 2>/dev/null
echo"=== Numbered source excerpts ==="
cat -n wled00/xml.cpp | sed -n '1,115p;175,270p'
cat -n wled00/data/settings_wifi.htm | sed -n '1,180p;200,275p'
cat -n wled00/wled_server.cpp | sed -n '750,885p'
Length of output: 83947
Script executed:
#!/bin/bashecho"=== Settings JavaScript response ==="
cat -n wled00/wled_server.cpp | sed -n '715,745p'echo"=== JavaScript loading ==="
cat -n wled00/data/common.js | sed -n '112,150p'echo"=== Stored and scanned network handling ==="
cat -n wled00/set.cpp | sed -n '20,52p'
cat -n wled00/json.cpp | sed -n '1050,1090p'
Length of output: 6828
@softhack007 The reported SSID <script>alert(1)</script>should no longer break the page or trigger the alert, based on the current code. The settings data is now served as a separate JavaScript resource, so </script> does not close an inline script element.
SSID handling is still unsafe for other values:
getSettingsJS() inserts the saved SSID into JavaScript without escaping it. A quote can break the script, and a crafted saved SSID can inject JavaScript.
addWiFi() also inserts the SSID into HTML without escaping it. For example, an SSID containing & can display as &.
I checked main at 0e1f77a. This is a code inspection; I did not test it on a device or in a browser.
Learnings used
Learnt from: softhack007
Repo: wled/WLED PR: 0
File: :0-0
Timestamp: 2026-10-03T14:59:43.661Z
Learning: In wled/WLED, softhack007 prefers contributors to answer maintainer questions directly with short explanations in their own words, even if the explanations are technically imprecise or the English is imperfect. Contributors should state uncertainty and actual test results rather than relay unverified AI-generated technical answers. AI may assist with translation or wording, but should not manufacture explanations that shift fact-checking and AI-session supervision onto maintainers.
@coderabbitai would we need to create our own "escape string" function, or is there a function in the framework - or in JS for the UI part - that we could use?
Apply the same treatment to the enterprise identity fields. Alternatively, create the inputs and assign their .value properties directly. I followed the repository guidance to reuse common.js helpers.
Firmware: WLED bundles ArduinoJson 6.18.1. Its serializeJson() can write a quoted string literal to settingsScript, so it can replace the raw %s insertion. Do not add another pair of quotes around its output. The SSID and enterprise identity strings need this treatment; printSetFormValue() also needs attention for other string settings.
There is one limitation: the bundled serializer writes some control characters raw. If we need valid JSON for arbitrary control characters, we need validation or a serializer that escapes all of them.
The UI escape alone cannot fix injection in the generated JavaScript: the firmware must serialize the values safely first. I inspected the code but did not test this on a device or in a browser.
Learnings used
Learnt from: CR
Repo: wled/WLED PR: 0
File: CONTRIBUTING.md:0-0
Timestamp: 2026-10-31T16:42:25.881Z
Learning: Applies to wled00/data/index.js : Applicability reference:
AGENTS.md: # AGENTS.md — WLED AI Coding Agent & AI Code Review Reference
## Required User Agreement
### No agent-posted replies or issues
Reviewer time is limited, and checking long AI-generated explanations for reasoning errors and hallucinations is costly. Even after the user agreement is confirmed:
- Creating or updating pull requests remains allowed (after the user agreement is confirmed). Keep PR descriptions concise and factual, and include a summary written by the user in their own words, leading with what they want to achieve or what bothers them in plain language, as described in [CONTRIBUTING.md](CONTRIBUTING.md#opening-issues--feature-requests).
Source excerpt:
# Thank you for making WLED better!
## Coding Guidelines
### Code style
#### Indentation
We use tabs for indentation in Web files (.html/.css/.js) and spaces (2 per indentation level) for all other files.
You are all set if you have enabled `Editor: Detect Indentation` in VS Code.
Learnt from: CR
Repo: wled/WLED PR: 0
File: CONTRIBUTING.md:0-0
Timestamp: 2026-10-31T16:42:25.881Z
Learning: Applies to wled00/data/common.js : Applicability reference:
AGENTS.md: # AGENTS.md — WLED AI Coding Agent & AI Code Review Reference
## Required User Agreement
### No agent-posted replies or issues
Reviewer time is limited, and checking long AI-generated explanations for reasoning errors and hallucinations is costly. Even after the user agreement is confirmed:
- Creating or updating pull requests remains allowed (after the user agreement is confirmed). Keep PR descriptions concise and factual, and include a summary written by the user in their own words, leading with what they want to achieve or what bothers them in plain language, as described in [CONTRIBUTING.md](CONTRIBUTING.md#opening-issues--feature-requests).
Source excerpt:
# Thank you for making WLED better!
## Coding Guidelines
### Code style
#### Indentation
We use tabs for indentation in Web files (.html/.css/.js) and spaces (2 per indentation level) for all other files.
You are all set if you have enabled `Editor: Detect Indentation` in VS Code.
Learnt from: CR
Repo: wled/WLED PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-12-02T16:50:37.145Z
Learning: Applies to wled00/data/** : Source excerpt:
# AGENTS.md — WLED AI Coding Agent & AI Code Review Reference
## Web UI Code Style (wled00/data/)
- **Tab indentation** for HTML, JS, and CSS
- camelCase for JS functions/variables
- Reuse helpers from `common.js` — do not duplicate utilities
Learnt from: softhack007
Repo: wled/WLED PR: 0
File: :0-0
Timestamp: 2026-10-03T14:59:43.661Z
Learning: In wled/WLED, softhack007 prefers contributors to answer maintainer questions directly with short explanations in their own words, even if the explanations are technically imprecise or the English is imperfect. Contributors should state uncertainty and actual test results rather than relay unverified AI-generated technical answers. AI may assist with translation or wording, but should not manufacture explanations that shift fact-checking and AI-session supervision onto maintainers.
#!/bin/bashecho'=== Revision ==='
git rev-parse HEAD
echo'=== Source outlines ==='
ast-grep outline wled00/xml.cpp --items all --match 'Settings|settings'||true
ast-grep outline wled00/util.cpp --items all --match 'printSetForm'||true
ast-grep outline wled00/data/common.js --items all --match '^esc$'||trueecho'=== Wi-Fi settings data and escaping ==='
rg -n -C 3 'function esc\b|function addWiFi\b|addWiFi\(|settingsScript|printSetFormValue\s*\(' wled00/data/common.js wled00/data/settings_wifi.htm wled00/xml.cpp wled00/util.cpp | head -n 240
echo'=== Browser code ==='
cat -n wled00/data/common.js | sed -n '145,165p'
cat -n wled00/data/settings_wifi.htm | sed -n '110,155p'echo'=== ArduinoJson version and escape implementation ==='
rg -n -m 8 'ARDUINOJSON_VERSION|class EscapeSequence|class TextFormatter|class JsonSerializer' wled00/src/dependencies/json/ArduinoJson-v6.h
cat -n wled00/src/dependencies/json/ArduinoJson-v6.h | sed -n '5375,5425p;6140,6175p;6420,6455p'echo'=== Server settings script serving ==='
cat -n wled00/wled_server.cpp | sed -n '715,745p'
Length of output: 26380
@softhack007 We can reuse existing functions for most of this:
UI:esc() in common.js escapes text for a quoted HTML attribute. For example, use value="${esc(ssid)}" in addWiFi(). Apply it to the other string values inserted into HTML too. Alternatively, create the inputs and assign their .value properties. The repository guidance favors reusing common.js helpers.
Firmware: The bundled ArduinoJson 6.18.1 can use serializeJson() to write a quoted string literal to the settings JavaScript. Do not add another pair of quotes around its output.
The bundled serializer does not escape every control character. If those characters must be preserved, we need a different serializer or our own escaping function. UI escaping alone cannot fix unsafe JavaScript generated by the firmware.
I inspected the code at 0e1f77a. I did not test this in a browser or on a device.
Learnings used
Learnt from: CR
Repo: wled/WLED PR: 0
File: CONTRIBUTING.md:0-0
Timestamp: 2026-10-31T16:42:25.881Z
Learning: Applies to wled00/data/common.js : Applicability reference:
AGENTS.md: # AGENTS.md — WLED AI Coding Agent & AI Code Review Reference
## Required User Agreement
### No agent-posted replies or issues
Reviewer time is limited, and checking long AI-generated explanations for reasoning errors and hallucinations is costly. Even after the user agreement is confirmed:
- Creating or updating pull requests remains allowed (after the user agreement is confirmed). Keep PR descriptions concise and factual, and include a summary written by the user in their own words, leading with what they want to achieve or what bothers them in plain language, as described in [CONTRIBUTING.md](CONTRIBUTING.md#opening-issues--feature-requests).
Source excerpt:
# Thank you for making WLED better!
## Coding Guidelines
### Code style
#### Indentation
We use tabs for indentation in Web files (.html/.css/.js) and spaces (2 per indentation level) for all other files.
You are all set if you have enabled `Editor: Detect Indentation` in VS Code.
Learnt from: CR
Repo: wled/WLED PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-12-02T16:50:37.145Z
Learning: Applies to wled00/data/** : Source excerpt:
# AGENTS.md — WLED AI Coding Agent & AI Code Review Reference
## Web UI Code Style (wled00/data/)
- **Tab indentation** for HTML, JS, and CSS
- camelCase for JS functions/variables
- Reuse helpers from `common.js` — do not duplicate utilities
Learnt from: softhack007
Repo: wled/WLED PR: 0
File: :0-0
Timestamp: 2026-10-03T14:59:43.661Z
Learning: In wled/WLED, softhack007 prefers contributors to answer maintainer questions directly with short explanations in their own words, even if the explanations are technically imprecise or the English is imperfect. Contributors should state uncertainty and actual test results rather than relay unverified AI-generated technical answers. AI may assist with translation or wording, but should not manufacture explanations that shift fact-checking and AI-session supervision onto maintainers.
#!/bin/bashecho'=== Source maps ==='forfin wled00/data/index.js wled00/data/settings_um.htm wled00/data/settings_time.htm wled00/data/settings_ui.htm wled00/data/settings_wifi.htm wled00/data/settings_leds.htm wled00/set.cpp wled00/data/pixelforge/pixelforge.htm;doecho"--- $f"; ast-grep outline "$f" --items all 2>/dev/null | head -n 100
doneecho'=== Settings data, controls and validation ==='
cat -n wled00/xml.cpp | sed -n '203,295p;510,518p;570,598p;636,654p;686,711p'
cat -n wled00/util.cpp | sed -n '135,160p'
rg -n -C 2 'serverDescription|apSSID|cmDNS|alexaInvocationName|mqttServer|mqttUser|mqttClientID|mqttDeviceTopic|mqttGroupTopic|ntpServerName|getCustomText|linked_remotes' wled00/set.cpp wled00/json.cpp wled00/cfg.cpp
echo'=== Main UI named text ==='
cat -n wled00/data/index.js | sed -n '390,505p;565,660p;805,900p;1168,1190p'echo'=== Settings UI generators ==='
cat -n wled00/data/settings_um.htm | sed -n '1,90p;160,260p'
cat -n wled00/data/settings_time.htm | sed -n '35,90p;94,170p'
cat -n wled00/data/settings_ui.htm | sed -n '35,120p'echo'=== Other candidates ==='
cat -n wled00/data/settings_wifi.htm | sed -n '15,90p;110,190p'
cat -n wled00/data/pixelforge/pixelforge.htm | sed -n '765,805p'
Length of output: 76208
Script executed:
#!/bin/bashecho'=== Usermod field building ==='
cat -n wled00/data/settings_um.htm | sed -n '90,135p'echo'=== Preset and segment rendering ==='
cat -n wled00/data/index.js | sed -n '590,650p;750,805p;1070,1098p;1960,1985p;2060,2152p;2165,2198p;2230,2245p'echo'=== Related name sources and sinks ==='
rg -n -C 2 'pName\(|qlName\(|inst\.n|serverDescription|\bsd\b|setSegName|seg.*\.n|["\x27]n["\x27]' wled00/data/index.js wled00/data/settings_sec.htm wled00/json.cpp wled00/set.cpp | head -n 250
echo'=== Firmware settings input validation ==='
cat -n wled00/set.cpp | sed -n '20,60p;100,118p;150,168p;470,480p;545,568p;594,603p'echo'=== UI settings data and usermod source ==='
cat -n wled00/data/settings_ui.htm | sed -n '1,35p;120,180p'
rg -n -C 2 'addInfo\(|addI\(|addDropdown\(|addO\(' wled00 --glob '*.{cpp,h}'| head -n 90
echo'=== Common HTML helper usage in main UI ==='
rg -n -C 2 '\besc\s*\(|common\.js|htmlEscape|escapeHtml' wled00/data/index.js wled00/data/index.htm wled00/data/common.js
echo'=== XML description output ==='
cat -n wled00/xml.cpp | sed -n '1,32p;40,53p'
Length of output: 40350
Script executed:
#!/bin/bashecho'=== Settings helper call sites across repository ==='
rg -n -C 1 '\b(printSetFormValue|printSetClassElementHTML)\s*\(' --glob '*.{cpp,h}'| grep -vE '^wled00/xml\.cpp|^wled00/util\.cpp'| head -n 140
echo'=== Main UI script loading ==='
rg -n -C 2 '<script|common\.js|index\.js|function esc' wled00/data/index.htm wled00/data/index.js wled00/wled_server.cpp
echo'=== Usermod config value handling ==='
rg -n -C 2 'case SUBPAGE_UM|umCfg|json\.um|strlcpy\(.*request->arg|enterpriseAnonIdentity|enterpriseIdentity' wled00/set.cpp wled00/data/settings_um.htm | head -n 180
echo'=== Usermod settings string examples ==='
rg -n -C 2 'addToConfig|readFromConfig' usermods -g '*.{cpp,h}'| head -n 75
echo'=== Main UI info and ledmap labels ==='
cat -n wled00/data/index.js | sed -n '700,742p;900,925p;2115,2128p'echo'=== JSON configuration handling in UI settings ==='
cat -n wled00/data/settings_ui.htm | sed -n '69,107p'
Length of output: 22454
@softhack007 Yes. I found other fields that need output handling beyond the Wi-Fi SSID.
Firmware-generated JavaScript
The string overload of printSetFormValue() inserts values without JavaScript escaping. It affects the AP SSID, mDNS name, device name, Alexa name, MQTT server/user/client ID/topics, NTP server and LED bus custom text. A double quote can break the settings script; a backslash can change the value.
The security page also inserts the device name separately. The ESP-NOW remote list has another direct insertion. Its browser-side MAC check happens after the script is parsed.
Usermod settings insert configuration strings into HTML attributes. The UI settings generator also inserts dynamically generated settings into unquoted attributes.
Other output
The /win XML response inserts the device name without XML escaping. For example, & can make the XML invalid.
I would serialize firmware values for the JavaScript context, then use DOM .value or .textContent for browser text where possible. For quoted HTML attributes, esc() is an option. The main UI does not currently load common.js, so it would need access to that helper first. This follows the repository guidance to reuse common helpers. The usermod generator also embeds keys in an inline JavaScript handler; HTML escaping alone is not sufficient for that nested context.
Not every path needs the same change: the timer preset options already use esc(), and scanned Wi-Fi options use DOM properties.
I inspected revision 0e1f77a. This was a targeted inspection, not a complete audit. I did not test it in a browser or on a device.
Learnings used
Learnt from: CR
Repo: wled/WLED PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-12-02T16:50:37.145Z
Learning: Applies to wled00/data/** : Source excerpt:
# AGENTS.md — WLED AI Coding Agent & AI Code Review Reference
## Web UI Code Style (wled00/data/)
- **Tab indentation** for HTML, JS, and CSS
- camelCase for JS functions/variables
- Reuse helpers from `common.js` — do not duplicate utilities
Learnt from: softhack007
Repo: wled/WLED PR: 0
File: :0-0
Timestamp: 2026-10-03T14:59:43.661Z
Learning: In wled/WLED, softhack007 prefers contributors to answer maintainer questions directly with short explanations in their own words, even if the explanations are technically imprecise or the English is imperfect. Contributors should state uncertainty and actual test results rather than relay unverified AI-generated technical answers. AI may assist with translation or wording, but should not manufacture explanations that shift fact-checking and AI-session supervision onto maintainers.
Activity
stale commentedon Sep 21, 2022
Hey! This issue has been open for quite some time without any new comments now. It will be closed automatically in a week if no further activity occurs.
Thank you for using WLED!
vladtepesch commentedon Dec 25, 2022
https://xkcd.com/327/
*scnr*
softhack007 commentedon Dec 2, 2026
@coderabbitai does the current code still support this hack?
coderabbitai commentedon Dec 2, 2026
Analysis chain
Script executed:
Length of output: 2461
Script executed:
Length of output: 25888
Script executed:
Length of output: 83947
Script executed:
Length of output: 6828
@softhack007The reported SSID<script>alert(1)</script>should no longer break the page or trigger the alert, based on the current code. The settings data is now served as a separate JavaScript resource, so</script>does not close an inline script element.SSID handling is still unsafe for other values:
getSettingsJS()inserts the saved SSID into JavaScript without escaping it. A quote can break the script, and a crafted saved SSID can inject JavaScript.addWiFi()also inserts the SSID into HTML without escaping it. For example, an SSID containing&can display as&.I checked
mainat0e1f77a. This is a code inspection; I did not test it on a device or in a browser.Learnings used
You are interacting with an AI system.
softhack007 commentedon Dec 2, 2026
@coderabbitai would we need to create our own "escape string" function, or is there a function in the framework - or in JS for the UI part - that we could use?
coderabbitai commentedon Dec 2, 2026
Analysis chain
Script executed:
Length of output: 45719
Script executed:
Length of output: 21725
Script executed:
Length of output: 8481
Script executed:
Length of output: 6183
@softhack007We probably do not need a new HTML escape function. The firmware side needs a separate solution because it generates JavaScript, not HTML.UI:
common.jsalready providesesc(). InaddWiFi(), it can escape the SSID for the quoted HTML attribute:Apply the same treatment to the enterprise identity fields. Alternatively, create the inputs and assign their
.valueproperties directly. I followed the repository guidance to reusecommon.jshelpers.Firmware: WLED bundles ArduinoJson 6.18.1. Its
serializeJson()can write a quoted string literal tosettingsScript, so it can replace the raw%sinsertion. Do not add another pair of quotes around its output. The SSID and enterprise identity strings need this treatment;printSetFormValue()also needs attention for other string settings.There is one limitation: the bundled serializer writes some control characters raw. If we need valid JSON for arbitrary control characters, we need validation or a serializer that escapes all of them.
The UI escape alone cannot fix injection in the generated JavaScript: the firmware must serialize the values safely first. I inspected the code but did not test this on a device or in a browser.
Learnings used
You are interacting with an AI system.
coderabbitai commentedon Dec 2, 2026
Analysis chain
Script executed:
Length of output: 26380
@softhack007We can reuse existing functions for most of this:esc()incommon.jsescapes text for a quoted HTML attribute. For example, usevalue="${esc(ssid)}"inaddWiFi(). Apply it to the other string values inserted into HTML too. Alternatively, create the inputs and assign their.valueproperties. The repository guidance favors reusingcommon.jshelpers.serializeJson()to write a quoted string literal to the settings JavaScript. Do not add another pair of quotes around its output.The bundled serializer does not escape every control character. If those characters must be preserved, we need a different serializer or our own escaping function. UI escaping alone cannot fix unsafe JavaScript generated by the firmware.
I inspected the code at
0e1f77a. I did not test this in a browser or on a device.Learnings used
You are interacting with an AI system.
softhack007 commentedon Dec 2, 2026
@coderabbitai please check if other UI fields and settings will also need escaping, to prevent unexpected behaviour.
coderabbitai commentedon Dec 2, 2026
Analysis chain
Script executed:
Length of output: 36892
Script executed:
Length of output: 36890
Script executed:
Length of output: 76208
Script executed:
Length of output: 40350
Script executed:
Length of output: 22454
@softhack007Yes. I found other fields that need output handling beyond the Wi-Fi SSID.Firmware-generated JavaScript
printSetFormValue()inserts values without JavaScript escaping. It affects the AP SSID, mDNS name, device name, Alexa name, MQTT server/user/client ID/topics, NTP server and LED bus custom text. A double quote can break the settings script; a backslash can change the value.Browser HTML
Other output
/winXML response inserts the device name without XML escaping. For example,&can make the XML invalid.I would serialize firmware values for the JavaScript context, then use DOM
.valueor.textContentfor browser text where possible. For quoted HTML attributes,esc()is an option. The main UI does not currently loadcommon.js, so it would need access to that helper first. This follows the repository guidance to reuse common helpers. The usermod generator also embeds keys in an inline JavaScript handler; HTML escaping alone is not sufficient for that nested context.Not every path needs the same change: the timer preset options already use
esc(), and scanned Wi-Fi options use DOM properties.I inspected revision
0e1f77a. This was a targeted inspection, not a complete audit. I did not test it in a browser or on a device.Learnings used
You are interacting with an AI system.
softhack007 commentedon Dec 2, 2026
coderabbitai commentedon Dec 2, 2026