Skip to content

fix(security): Add URL scheme validation to prevent credential interception#169

Open
DennisTraub wants to merge 2 commits intoaws:mainfrom
DennisTraub:fix/url-scheme-validation
Open

fix(security): Add URL scheme validation to prevent credential interception#169
DennisTraub wants to merge 2 commits intoaws:mainfrom
DennisTraub:fix/url-scheme-validation

Conversation

@DennisTraub
Copy link
Contributor

Summary

  • Add validate_endpoint_url() function to enforce HTTPS for remote endpoints
  • Allow HTTP for localhost addresses (development/testing)
  • Integrate validation into both CLI and client library entry points

Fixes #168

Problem

Endpoint URLs were not validated for HTTPS scheme, which could expose AWS credentials via man-in-the-middle attacks since SigV4 signing headers would be transmitted unencrypted.

Changes

File Change
mcp_proxy_for_aws/utils.py Add validate_endpoint_url() function
mcp_proxy_for_aws/utils.py Integrate into get_service_name_and_region_from_endpoint()
mcp_proxy_for_aws/client.py Integrate into aws_iam_streamablehttp_client()
tests/unit/test_utils.py Add 13 tests for URL validation
tests/unit/test_client.py Add 2 security tests

Testing

  • All 153 unit tests pass
  • New tests cover: HTTPS URLs, HTTP remote (rejected), HTTP localhost (allowed), missing scheme, unsupported schemes

Backward Compatibility

  • Existing HTTPS endpoints: ✅ No change
  • HTTP localhost: ✅ Allowed for development
  • HTTP remote: ❌ Now rejected with clear error message

@DennisTraub DennisTraub requested a review from a team as a code owner February 6, 2026 22:56
@DennisTraub DennisTraub force-pushed the fix/url-scheme-validation branch from a113a12 to 6d4e41c Compare February 6, 2026 23:00
wzxxing
wzxxing previously approved these changes Feb 13, 2026
@wzxxing wzxxing enabled auto-merge (squash) February 13, 2026 08:42
@wzxxing
Copy link
Contributor

wzxxing commented Feb 13, 2026

Thanks, but the formatting failed. Could you please run

uv pre-commit install

then run

pre-commit run --all-files

DennisTraub and others added 2 commits February 13, 2026 14:34
…eption

AWS credentials must be transmitted over HTTPS to prevent interception
via man-in-the-middle attacks. This adds validation to reject HTTP
endpoints for remote hosts while allowing HTTP for localhost during
local development.

- Add validate_endpoint_url() function to utils.py
- Integrate validation into get_service_name_and_region_from_endpoint()
- Integrate validation into aws_iam_streamablehttp_client()
- Add comprehensive tests for URL scheme validation

🤖 Generated with [Claude Code](https://claude.com/claude-code)
auto-merge was automatically disabled February 13, 2026 13:42

Head branch was pushed to by a user without write access

@DennisTraub DennisTraub dismissed stale reviews from JacquesPotgieter and wzxxing via c59770e February 13, 2026 13:42
@DennisTraub DennisTraub force-pushed the fix/url-scheme-validation branch from 6d4e41c to c59770e Compare February 13, 2026 13:42
@DennisTraub
Copy link
Contributor Author

Fixed the style issues, should be ready to be merged now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(security): Add URL scheme validation to prevent credential interception

3 participants