httpserver: restrict /websocket/raw to localhost - #3759
Closed
Greninja44 wants to merge 2 commits into
Closed
Conversation
Fix two bugs in DroneCAN.GetParameters() that caused parameter enumeration to stop before retrieving all parameters: 1. SemaphoreSlim(1) allowed the while loop to send duplicate GetSet requests before receiving responses. When both duplicate responses arrived, the index was incremented twice, skipping intermediate parameter indices. Changed to SemaphoreSlim(0) so the loop blocks until each response arrives. 2. Message filter used a single AND condition that failed to filter out service messages from wrong nodes. A stray GetSet_res with name_len==0 from another node could trigger premature end-of-enumeration. Fixed to use two separate conditions matching the proven pattern in SetParameter().
The /websocket/raw WebSocket endpoint accepts unauthenticated connections from any network interface, allowing remote hosts to inject arbitrary MAVLink commands into the active vehicle link. Add an IPAddress.IsLoopback() check on the TCP remote endpoint before completing the WebSocket handshake, consistent with the existing protections on /guided? and POST /guide. Fixes ArduPilot#3757
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #3757
The
/websocket/rawWebSocket endpoint on TCP/56781 accepts unauthenticated connections from any network interface. Remote hosts can inject arbitrary MAVLink commands into the active vehicle link — for example, changing the flight mode of a disarmed drone.This adds an
IPAddress.IsLoopback()check on the TCP remote endpoint before completing the WebSocket handshake, consistent with the existing protections on/guided?andPOST /guide(added in ec2b6fc and 980d2b8).Applied to both the desktop server (
Utilities/httpserver.cs) and the Xamarin copy (ExtLibs/Xamarin/Xamarin/Linked/httpserver.cs).All built-in clients (WASM, HUD, Blazor) connect to
localhostand are unaffected.