Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 23, 2025

When OTA lock is enabled and users attempt to modify security settings without providing the correct password, the UI displays "Security settings saved." despite silently ignoring the changes. This misleads users into thinking settings were updated when they weren't.

Changes

  • set.cpp: Return 401 error immediately with "Error" / "Password incorrect" message when OTA is locked and password validation fails
  • wled_server.cpp: Removed unnecessary error handling logic (error is now handled at validation point)

User-facing change

Before:

Security settings saved.
Redirecting...

After (incorrect password):

Error
Password incorrect

The fix returns a proper 401 HTTP status code when authentication fails, following standard HTTP patterns. Settings changes are only applied when the password is correct or OTA is unlocked.

Technical approach

The solution returns an error response immediately within the same HTTP request when password validation fails, avoiding the use of global state that could affect other requests. This follows proper REST API patterns for authentication failures.

Original prompt

This section details on the original issue you should resolve

<issue_title>Cannot update WLED on Quinled dig-uno, OTA permanently locked</issue_title>
<issue_description>### What happened?

I'm trying to update my Quinled Dig-Uno from version 0.15.0 to 0.15.2. Initially through HA, since that's what prompted me to update. However, HA cannot update the device and the report stays.

So instead I went to the web UI for this device and tried updating the device from there. This also fails with the message Please unlock OTA in security settings!

And that is where it gets weird. When I do go to settings -> Security & updates the Lock wireless (OTA) software update checkbox is checked, so I uncheck it and save the page.

Then I go back to the main screen and on the Info tab, try the update WLED button again. And here I get the exact same message. Please unlock OTA in security settings!

It seems that the lock setting for OTA updates is not saved and is permanently on. The Manual OTA Update button on the security page has the same problem and won't work, because this lock cannot be removed.

Apart from flashing the thing over USB, is there any way to unlock this OTA update feature so that I can update the device?

To Reproduce Bug

  • Attempt update, either from the info screen or the settings -> security screen
  • OTA lock is in place so update will fail
  • disable the lock in security screen and save
  • Attempt the update again: lock has been restored or was never removed, so updating still fails.

Expected Behavior

Once OTA lock checkbox is cleared and the page is saved, the lock state is actually updated and software updating can commence.

Install Method

Binary from WLED.me

What version of WLED?

0.15.0

Which microcontroller/board are you seeing the problem on?

ESP32

Relevant log/trace output

I don't know where to get these from.

Anything else?

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct</issue_description>

<agent_instructions>This issue revealed that:

If the Lock wireless (OTA) software update box is checked, the correct password must be entered in the password box to save unchecking it. Unfortunately, if the correct password is not entered, the UI provides no helpful feedback - it just says "saved" anyways and ignores the attempt to change the security settings.
please propose a solution that uses minimal code addition.</agent_instructions>

Comments on the Issue (you are @copilot in this section)

@DedeHai can you please provide your config.json file? @netmindz Please can you also confirm you are trying to do the update from the same network as the WLED device, check the IP address of your laptop/phone/pc and the WLED device are the same for the first 3 groups of numbers @willmmiles > And that is where it gets weird. When I do go to `settings -> Security & updates` the `Lock wireless (OTA) software update` checkbox is checked, so I uncheck it and save the page.

@DutchessNicole If the Lock wireless (OTA) software update box is checked, the correct password must be entered in the password box to save unchecking it. Unfortunately, if the correct password is not entered, the UI provides no helpful feedback - it just says "saved" anyways and ignores the attempt to change the security settings. (I'd class that as a bug for sure - definitely something we can work on.)

I'm inferring that you weren't expecting the lock to be enabled, and consequently don't have a password to put in. The default OTA password is "wledota"; maybe try that. If that doesn't work, unfortunately recovering a lost password is (intentionally) rather difficult. If this is the case, you may need to back up your config and presets and factory reset your device to unstick it. (If you try that, I also suggest editing the config backup to set { "ota": { "lock": false } } to avoid having the backup restore cause the same problem.)

As far as the "lock OTA" box being unexpectedly set - maybe it was ticked accidentally, maybe some bad config was pushed at some point, maybe some other bug -- hard to know. :(

(Re the subnet questions: 0.16 (the current development branch/nightlies) adds a security feature where, by default, WLED will no longer accept OTAs from other subnets, as a weak but cheap defense for those devices exposed when they shouldn't be. This feature can be disabled via the security settings - you'll probably want to adjust if or when you update to that version.)</comment_new>
<comment_new>@willmmiles
@dimmas375 It looks like you're using the ESP02 build, which is for an ESP8266 with only 2MB of flash. It might not be possible to OTA update those devices as the firmware may be too big to store both the new...


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 23, 2025

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.


Comment @coderabbitai help to get the list of available commands and usage tips.

Copilot AI changed the title [WIP] Fix OTA update lock issue on Quinled Dig-Uno Add password validation feedback for OTA lock security settings Dec 23, 2025
Copilot AI requested a review from DedeHai December 23, 2025 06:10
wled00/set.cpp Outdated

if (pwdCorrect) //allow changes if correct pwd or no ota active
{
otaPasswordIncorrect = false; // clear flag on successful save
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

invert the logic, call it "otaPassCorrect"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in commit b7485e2. Renamed flag to otaPassCorrect with inverted logic.

if (doReboot) strcpy_P(s2, PSTR("Rebooting, please wait ~10 seconds..."));
else if (otaPwdErr) {
strcpy_P(s, PSTR("Settings NOT saved!"));
strcpy_P(s2, PSTR("Incorrect password. Enter correct OTA password to change OTA lock settings."));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use "Error" for s and "Password incorect" for s2

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in commit b7485e2. Changed to "Error" / "Password incorrect".

@@ -0,0 +1 @@
. No newline at end of file
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this leftover file

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in commit b7485e2. Removed the leftover symlink.

@DedeHai
Copy link
Collaborator

DedeHai commented Dec 23, 2025

@copilot please update according to review comments

…ror message, remove leftover file

Co-authored-by: DedeHai <[email protected]>
Copy link
Contributor Author

Copilot AI commented Dec 23, 2025

@copilot please update according to review comments

All review comments have already been addressed in commit b7485e2:

  • ✅ Flag renamed to otaPassCorrect with inverted logic
  • ✅ Error message changed to "Error" / "Password incorrect"
  • ✅ Leftover _codeql_detected_source_root file removed

No further changes are needed.

@DedeHai DedeHai marked this pull request as ready for review December 23, 2025 10:44
@DedeHai DedeHai requested a review from willmmiles December 23, 2025 10:44
@DedeHai
Copy link
Collaborator

DedeHai commented Dec 23, 2025

tested, works as intended

Copy link
Member

@willmmiles willmmiles left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not the correct approach - we should not be adding a global variable that makes one HTTP request change the result of another. If a request is denied due to an incorrect password, it should return a 401.

@DedeHai
Copy link
Collaborator

DedeHai commented Dec 23, 2025

@copilot please update according to the requested change.

Copy link
Contributor Author

Copilot AI commented Dec 23, 2025

@copilot please update according to the requested change.

Done in commit 38b159d. Removed global flag and now return 401 status immediately when password is incorrect, within the same HTTP request context.

Copilot AI changed the title Add password validation feedback for OTA lock security settings Return 401 on incorrect OTA password instead of misleading success message Dec 23, 2025
Copilot AI requested a review from DedeHai December 23, 2025 18:51
aOtaEnabled = request->hasArg(F("AO"));
#endif
otaSameSubnet = request->hasArg(F("SU"));
} else if (otaLock) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is better, but we should only return failure if any of the OTA-related values have been changed without a correct password. We do not want to return 401s if none of these values were altered. For example, the code as written would generate errors to a user who was enabling a settings PIN, even if they didn't attempt to make any OTA settings changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cannot update WLED on Quinled dig-uno, OTA permanently locked

3 participants