Fix: Mitigate Unauthenticated RCE via CSRF and DNS Rebinding#124
Merged
Conversation
ArshVermaGit
commented
May 27, 2026
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.
Description
This PR addresses a critical security vulnerability where the local DevShell server implicitly trusted all incoming requests, leading to Unauthenticated Remote Code Execution (RCE) via Cross-Site Request Forgery (CSRF) or DNS Rebinding.
Because the API endpoints natively execute bash commands on the host machine, an attacker could previously exploit a developer by having them visit a malicious webpage, which would then send unauthorized requests to
http://127.0.0.1:5000/api/exec.Resolved Issue
Resolves #123
Changes Made
before_requesthook inapp.pythat strictly validates theHostheader. The server now rejects any requests where the host is not127.0.0.1orlocalhost.OriginandRefererheaders on all state-modifying requests. Requests originating from unauthorized domains (or missing these headers while presenting a browserUser-Agent) are now actively blocked with a403 Forbiddenresponse.Security Impact
These validations act as a robust layer of defense against browser-based attacks targeting the local development server, effectively neutralizing the RCE threat without requiring complex authentication mechanisms or dynamic CSRF tokens.
Testing
curl -H "Host: malicious.com" ...(Returns403 Forbidden).curl -X POST -H "Origin: http://malicious.com" ...(Returns403 Forbidden).