aws-samples / aws-iot-securetunneling-localproxy

AWS Iot Secure Tunneling local proxy reference C++ implementation
https://docs.aws.amazon.com/iot/latest/developerguide/what-is-secure-tunneling.html
Apache License 2.0
73 stars 69 forks source link

Got "Segmentation fault" and localproxy process is terminated when send message from source connect #123

Closed nimysan closed 1 year ago

nimysan commented 1 year ago

Describe the bug

While localproxy is running and there is source connect from Secure Shell (SSH)(Iot Core Management Console), Got "Segmentation fault" and localproxy process is terminated.

Platform: Raspberry pi 4
Linux raspberrypi 5.15.84-v7l+ #1613 SMP Thu Jan 5 12:01:26 GMT 2023 armv7l GNU/Linux

[2023-02-17 17:00:23.236221] (0xb6f7e040) [warning] Found access token supplied via CLI arg. Consider using environment variable AWSIOT_TUNNEL_ACCESS_TOKEN instead
[2023-02-17 17:00:23.236555] (0xb6f7e040) [debug] v2 local proxy starts with v1 local proxy format
[2023-02-17 17:00:23.236739] (0xb6f7e040) [debug] /home/amazon/config does not exist!
[2023-02-17 17:00:23.236917] (0xb6f7e040) [info] Starting proxy in destination mode
[2023-02-17 17:00:23.245448] (0xb6f7e040) [info] Attempting to establish web socket connection with endpoint wss://data.tunneling.iot.ap-southeast-1.amazonaws.com:443
[2023-02-17 17:00:23.499852] (0xb6f7e040) [debug] Resolved proxy server IP: 18.139.235.229
[2023-02-17 17:00:23.548128] (0xb6f7e040) [debug] Connected successfully with proxy server
[2023-02-17 17:00:23.654216] (0xb6f7e040) [debug] Successfully completed SSL handshake with proxy server
[2023-02-17 17:00:23.748523] (0xb6f7e040) [info] Web socket session ID: 02f4d9fffefc3638-00001803-0001101e-50b78f53833b6afc-f2898409
[2023-02-17 17:00:23.748651] (0xb6f7e040) [debug] Web socket subprotocol selected: aws.iot.securetunneling-3.0
[2023-02-17 17:00:23.748716] (0xb6f7e040) [info] Successfully established websocket connection with proxy server: wss://data.tunneling.iot.ap-southeast-1.amazonaws.com:443
[2023-02-17 17:00:23.748852] (0xb6f7e040) [debug] Seting up web socket pings for every 20000 milliseconds
[2023-02-17 17:00:23.749037] (0xb6f7e040) [debug] Scheduled next read:
[2023-02-17 17:00:23.749373] (0xb6f7e040) [debug] Extracting service Ids from control message 5
[2023-02-17 17:00:23.749465] (0xb6f7e040) [info] Updated port mapping for v1 format:
[2023-02-17 17:00:23.749525] (0xb6f7e040) [info] SSH = 22
[2023-02-17 17:00:23.749612] (0xb6f7e040) [debug] Starting web socket read loop continue reading...
[2023-02-17 17:00:23.749715] (0xb6f7e040) [debug] Starting web socket read loop while web socket is already reading. Ignoring...
[2023-02-17 17:00:41.275693] (0xb6f7e040) [debug] Received service id : , stream id: 117
[2023-02-17 17:00:41.275879] (0xb6f7e040) [info] Attempting to establish tcp socket connection to: 22
[2023-02-17 17:00:41.276013] (0xb6f7e040) [info] Setting up dest socket with tcp connection id 1
[2023-02-17 17:00:41.276148] (0xb6f7e040) [debug] Resolved destination host to IP: 127.0.0.1, connecting ...
[2023-02-17 17:00:41.276555] (0xb6f7e040) [info] Connected to 127.0.0.1, port: 22
[2023-02-17 17:00:41.276680] (0xb6f7e040) [debug] Starting web socket read loop continue reading...
[2023-02-17 17:00:41.276915] (0xb6f7e040) [debug] Web socket read loop stopped
[2023-02-17 17:00:41.333286] (0xb6f7e040) [debug] Prepare to send data message: service id: SSH stream id: 117 connection id: 1
Segmentation fault

To Reproduce

Steps to reproduce the behavior:

  1. Gene
  2. run localproxy with client access token on raspberry pi 4, it's ok.
  3. on the secure ssh from web, try to connect to the device and input username/password.
  4. Error produced.

Expected behavior

Connect to device and open the shell

Actual behavior

Localproxy is terminated and failed to open shell

RogerZhongAWS commented 1 year ago

Hello, thanks for reporting this issue. Does this only happen if you use web console to connect as the source? What happens if you try running localproxy on the source instead?

HarshGandhi-AWS commented 1 year ago

Its been a while since we last heard from you @nimysan. Closing this issue now. Please feel free to open this issue if you continue facing issues using local proxy.