fix(security): allow HTTP for localhost and loopback addresses#3286
Closed
aayush598 wants to merge 1 commit intosimstudioai:stagingfrom
Closed
fix(security): allow HTTP for localhost and loopback addresses#3286aayush598 wants to merge 1 commit intosimstudioai:stagingfrom
aayush598 wants to merge 1 commit intosimstudioai:stagingfrom
Conversation
|
@aayush598 is attempting to deploy a commit to the Sim Team on Vercel. A member of the Team first needs to authorize it. |
Contributor
Greptile SummaryThis PR enables HTTP requests to localhost addresses (localhost, 127.0.0.1, ::1) to support local development while preserving all existing SSRF protections for external URLs. Key Changes:
Security Assessment:
The bracket-stripping logic in both files ( Confidence Score: 5/5
Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[URL Validation Request] --> B{Parse URL}
B --> C{Check Protocol}
C -->|Not http/https| D[Reject: Invalid Protocol]
C -->|http/https| E{Detect Loopback?}
E -->|Yes: localhost/127.0.0.1/::1| F{Protocol Check}
F -->|http or https| G[Allow - Local Dev]
E -->|No: External URL| H{Protocol = https?}
H -->|No| I[Reject: HTTPS Required]
H -->|Yes| J{Check IP}
J -->|Private IP Range| K[Reject: Private IP Blocked]
J -->|Public IP| L{Check Port}
L -->|Blocked Port| M[Reject: Port Blocked]
L -->|Allowed Port| N[Accept]
G --> O[DNS Resolution]
N --> O
O --> P{Resolved IP Private?}
P -->|Yes & Not Loopback| Q[Reject: SSRF Protection]
P -->|No or Loopback| R[Success]
Last reviewed commit: ad24c94 |
6 tasks
Collaborator
|
being tracked in #3304 now |
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.
Summary
This PR restores support for HTTP on localhost for local development while preserving existing SSRF protections and HTTPS requirements for external URLs.
Previously, HTTP requests to localhost were rejected due to strict HTTPS enforcement and private IP blocking. This prevented local development and testing without configuring HTTPS.
This change allows HTTP requests for loopback addresses while maintaining security constraints for all other hosts.
Allowed loopback addresses:
localhost
127.0.0.1
::1
Security protections remain unchanged for non-loopback addresses.
Fixes #3112
Type of Change
Testing
Tested locally using the development server.
Verified Working
Allowed:
Blocked:
Automated Tests
Added unit tests covering:
localhost URLs
IPv4 loopback addresses
IPv6 loopback addresses
HTTPS enforcement for external URLs
Private IP blocking
All tests pass successfully.
Reviewers should focus on:
validateExternalUrl()
validateUrlWithDNS()
Loopback detection logic
SSRF protection behavior
Checklist
Screenshots/Videos
Not applicable