fix(ConfigManager): stop logging the MQTT password and MQTT_SECRET prefix
Both were printed at INFO on every boot. Serial/SD logs leave the device, and MQTT_SECRET derives every device's password. Only the username is logged now. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -37,8 +37,10 @@ void ConfigManager::initializeCleanDefaults() {
|
||||
// Must match the MQTT_SECRET in the backend .env exactly.
|
||||
mqttConfig.password = computeMqttPassword(deviceConfig.serial);
|
||||
|
||||
LOG_INFO(TAG, "🔑 MQTT auth — user: %s, password: %s", mqttConfig.user.c_str(), mqttConfig.password.c_str());
|
||||
LOG_INFO(TAG, "🔑 MQTT_SECRET prefix: %.8s...", MQTT_SECRET);
|
||||
// Never log the password or any part of MQTT_SECRET — serial/SD logs leave
|
||||
// the device (support sessions, log downloads), and the secret derives every
|
||||
// device's password.
|
||||
LOG_INFO(TAG, "🔑 MQTT auth — user: %s (password derived)", mqttConfig.user.c_str());
|
||||
|
||||
LOG_DEBUG(TAG, "ConfigManager - Clean defaults initialized with auto-generated identifiers");
|
||||
}
|
||||
|
||||
@@ -201,7 +201,7 @@ All files live under `/settings/` on the FAT SD card.
|
||||
`device_uid`, `hw_type`, and `hw_version` are written only by the factory provisioning tool. If any of these keys are absent in NVS, `begin()` logs a critical warning and the device will use empty strings. MQTT auth will fail and subsystems that gate on `getDeviceUID()` will behave incorrectly. Reflash the NVS partition using `esptool` and the provisioning binary.
|
||||
|
||||
**MQTT password is derived at boot, not stored.**
|
||||
`computeMqttPassword()` runs HMAC-SHA256(`MQTT_SECRET`, `deviceUID`) and takes the first 16 bytes (32 hex chars). The build flag `MQTT_SECRET` must match the value in the backend `.env` exactly. A mismatch will cause MQTT `CONNACK` error 5 (Not Authorized). The secret is logged at `INFO` level on boot — remove or gate this log line before shipping.
|
||||
`computeMqttPassword()` runs HMAC-SHA256(`MQTT_SECRET`, `deviceUID`) and takes the first 16 bytes (32 hex chars). The build flag `MQTT_SECRET` must match the value in the backend `.env` exactly. A mismatch will cause MQTT `CONNACK` error 5 (Not Authorized). Neither the password nor any part of the secret is logged (removed 2026-10-15); only the username is.
|
||||
|
||||
**SD card is required for user settings.**
|
||||
`begin()` returns `false` if `SD.begin()` fails. All `load*()` and `save*()` methods silently return `false` when the card is absent. The HealthMonitor reports ConfigManager as unhealthy when `isHealthy()` returns false (SD unmounted or UID empty). This is classified as a WARNING, not CRITICAL, so the firmware continues running with in-RAM defaults.
|
||||
|
||||
Reference in New Issue
Block a user