Skip to content

Mask the meter keys in the configuration JSON and the GUI - #1339

Merged
gskjold merged 1 commit into
mainfrom
mask-meter-keys
Dec 4, 2026
Merged

gskjold merged 1 commit into
mainfrom
mask-meter-keys

Conversation

@gskjold

@gskjold gskjold commented Nov 26, 2026

Copy link
Copy Markdown
Member

Why

The meter encryption and authentication keys were returned in clear text by /configuration.json and by the MQTT getconfig reply (published to <publish topic>/config), and shown in the configuration page. Every other secret in that JSON (web password, Wi-Fi PSK, MQTT password) is already replaced by ***. Anyone who can read the configuration endpoint or the MQTT topic could read the keys.

Changes

  • AmsJsonGenerator::generateConfigurationJson() emits *** for a key that is set and an empty string for one that is not. This covers both the HTTP endpoint and MQTT getconfig, which share the generator. An unset authentication key used to be reported as 32 zeros and is now empty.
  • AmsWebServer::handleSave() treats *** in mek / mea as "keep the stored key", like the password fields. An empty field still clears the key and 32 hex digits replace it.
  • MQTT setconfig: no behaviour change, comment only. A value that is not 32 characters was already ignored, so a getconfig → setconfig round trip keeps the keys.
  • UI: meterKeyPattern also accepts ***, so the form validates without retyping the key. ui/dist rebuilt.

Not changed: the configuration file download still includes the keys when "include secrets" is ticked, the same as the passwords.

Verification

  • pio run -e esp32s2 and pio run -e esp8266 build.
  • pio test -e native_config passes.
  • Not tested on a device: the save paths (keep on ***, clear on empty, replace on 32 hex digits) and the GUI form have not been exercised on hardware.

🤖 Generated with Claude Code

@gskjold gskjold added this to the v2.6.1 milestone Dec 4, 2026
The meter encryption and authentication keys were returned in clear text
by /configuration.json and by the MQTT getconfig reply, and shown in the
configuration page. Report them as "***" when set and empty when not, the
same way the web, Wi-Fi and MQTT passwords are handled.

Saving the form with "***" keeps the stored key; an empty field still
clears it and 32 hex digits replace it. MQTT setconfig already ignored
values that are not 32 characters.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
@github-actions

github-actions Bot commented Dec 4, 2026

Copy link
Copy Markdown

🔧 PR Build Artifacts

Version: a5bb3b7

All environments built successfully. Download the zip files:

Artifacts expire after 7 days. View workflow run

@gskjold
gskjold merged commit 40f10a1 into main Dec 4, 2026
8 checks passed
@gskjold
gskjold deleted the mask-meter-keys branch December 4, 2026 09:40
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