Repository navigation
Harden Anthropic localhost URL scheme validation - #63
Merged
christopherkarani merged 1 commit intoMay 18, 2026
Merged
Conversation
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 fixes a configuration-validation gap in Anthropic URL security checks and adds a regression test.
Root Cause
AnthropicConfiguration.validateSecureURL(_:)previously allowed any scheme for localhost hosts because localhost bypassed the scheme guard unconditionally:https://...(intended)http://localhost...(intended for local dev)ftp://localhost...and other non-HTTP schemes (unintended)That behavior weakens configuration safety and can route requests through unsupported or insecure schemes while appearing valid.
Changes
1) Added failing test first (TDD)
Tests/ConduitTests/Providers/Anthropic/AnthropicProviderTests.swiftLocalhost non-HTTP schemes are rejectedAnthropicConfiguration(baseURL: ftp://localhost:8080)throwsAIError.2) Hardened URL validation logic
Sources/Conduit/Providers/Anthropic/AnthropicConfiguration.swifthttpsfor all hostshttponly for localhost loopback hosts (localhost,127.0.0.1,::1)Why this is correct
Verification
swift test(full suite): passedswift build: passedRisk / Compatibility
ftp://localhost...), which now fail fast with a typed input error.