ArduinoCore-renesas icon indicating copy to clipboard operation
ArduinoCore-renesas copied to clipboard

WiFi passwords containing a double quote, comma, or backslash are not escaped correctly when sent to the WiFi USB bridge

Open gkjfdh opened this issue 1 year ago • 2 comments

When serializing command arguments, the software that communicates the WiFi password to the WiFi USB bridge doesn't escape these three special characters that the firmware on the other side interprets. As a result, that firmware mis-parses passwords that contain them and fails to connect.

Sample code, which never successfully connects:

#include <WiFiS3.h>

// #include "Modem.h"

void setup() {
  Serial.begin(9600);

  Serial.println("Starting wifi");
  
  // modem.begin();
  // modem.debug(Serial, 2);

  int status = WL_IDLE_STATUS;
  while(status != WL_CONNECTED) {
    status = WiFi.begin("my_ssid", "goofy\"password");
    Serial.print("status = ");
    Serial.println(status);
    delay(2000);
  }

  Serial.println("Connected!");
  while(1);
}

void loop() {
  // put your main code here, to run repeatedly:
}

SSID and password serialized out with no escaping here:

https://github.com/arduino/ArduinoCore-renesas/blob/ecc4ed83cd35d4ec109347615de8205d7810554c/libraries/WiFiS3/src/WiFi.cpp#L57

Relevant debugging output from the modem class (thanks to whoever put that in there!):

REQUEST: AT+BEGINSTA=my_ssid,goofy"password

Parser code in the firmware that's interpreting the double quote:

https://github.com/arduino/uno-r4-wifi-usb-bridge/blob/94d5bb2e8c2cb5492345bfb84d787fde65d1c183/UNOR4USBBridge/parser.cpp#L161

It's possible to work around this by adding extra escaping in the string in the sketch, e.g.

status = WiFi.begin("my_ssid", "goofy\\\"password");

Which results in this going over the wire, successfully connecting.

REQUEST: AT+BEGINSTA=my_ssid,goofy\"password

Additional context

Additional reports

  • https://github.com/arduino/ArduinoCore-renesas/issues/430#issuecomment-3034243774

gkjfdh avatar Feb 07 '25 04:02 gkjfdh

Moi aussi!

SJrX avatar Jul 04 '25 02:07 SJrX

I can confirm here the topic with the comma. Took me hours to find out what of my 63 characters caused the problem.

So if you have problems with

const char* password = "simplepassword,"

use

const char* password = "simplepassword\\,"

as a workaround.

bauerflo77 avatar Jul 22 '25 10:07 bauerflo77