Skip to content

Require a WPA2 password when the device is set up as an access point - #1338

Merged
gskjold merged 1 commit into
mainfrom
require-ap-password
Dec 4, 2026
Merged

gskjold merged 1 commit into
mainfrom
require-ap-password

Conversation

@gskjold

@gskjold gskjold commented Nov 26, 2026

Copy link
Copy Markdown
Member

Why

When the device is configured to run as an access point (network mode "AP"), nothing made sure the AP had a password:

  • An empty password was accepted and stored, and WiFi.softAP() then starts an open network. In AP mode checkSecurity() grants access without the web login, so anyone in radio range could reach the full web interface.
  • A password of 1–7 characters was stored as well. Both Arduino cores reject that in softAP(), but the handler ignored the return value and reported the AP as connected.

The only guard was required on the password field in the setup wizard (browser validation only, no minimum length). The configuration page had none.

Changes

  • /save refuses AP mode when the password is shorter than 8 characters, for both the setup wizard and the configuration page (*** is resolved to the stored password first).
  • AmsConfiguration::setNetworkConfig() does not store a new AP config without a valid WPA2 password. This is the common path for the web form, MQTT setconfig and config file import. A config that is already stored as an open AP is left alone, so its other fields (hostname etc.) can still be saved.
  • WiFiAccessPointConnectionHandler::connect() checks the softAP() result; on failure it turns the radio off and reports not connected.
  • Setup and configuration forms: password is required with minlength=8 in AP mode. ui/dist rebuilt.

Not changed

  • A device that is already configured as an open AP keeps running that way after an upgrade, so nobody is locked out. It has to set a password the next time the network settings are saved from the web UI.
  • The temporary setup AP (before the device is configured) is still open.
  • The UI does not show the message from a failed /save, so the browser validation is what the user sees; the server check is the backstop.

Verification

  • pio test -e native_config: 6/6 pass, including four new tests for the storage rule.
  • pio run -e esp8266 -e esp32s2 build. ESP8266 flash is at 99.2 %.
  • Not tested on a device: the /save rejection, the form validation and the softAP() failure path are verified by reading and building only.

🤖 Generated with Claude Code

@gskjold gskjold added this to the v2.6.1 milestone Dec 4, 2026
@gskjold
gskjold force-pushed the require-ap-password branch from 82629c7 to 6ac9712 Compare December 4, 2026 09:20
Access point mode accepted an empty password, which starts an open AP, and
the web interface does not ask for a login in AP mode. A password of 1-7
characters was stored as well, although softAP() rejects it; the handler
ignored that and reported the AP as up.

- /save refuses AP mode with a password shorter than 8 characters.
- setNetworkConfig() does not store a new AP config without a valid
  password, which also covers MQTT setconfig and config file import. A
  config already stored that way is left alone so its other fields can
  still be saved.
- The AP handler checks the softAP() result and turns the radio off when
  it fails.
- The setup and configuration forms require 8 characters in AP mode.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
@gskjold
gskjold force-pushed the require-ap-password branch from 6ac9712 to cd0799d Compare December 4, 2026 09:34
@gskjold
gskjold merged commit 0e6be1f into main Dec 4, 2026
7 checks passed
@gskjold
gskjold deleted the require-ap-password branch December 4, 2026 09:34
@github-actions

github-actions Bot commented Dec 4, 2026

Copy link
Copy Markdown

🔧 PR Build Artifacts

Version: cd0799d

All environments built successfully. Download the zip files:

Artifacts expire after 7 days. View workflow run

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.

1 participant