kotlin-sdk/kotlin-sdk-server
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Pavel Gorgulov 5cb3c1de12
fix: enable DNS rebinding protection by default (#659)
Add `DnsRebindingProtection` Ktor route-scoped plugin and enable it by
default across all http transports

## Motivation and Context
DNS rebinding protection was disabled by default
(`enableDnsRebindingProtection = false`), and sse endpoints
(`Route.mcp()`) had zero protection. Same vulnerability as typescript
sdk
[GHSA-w48q-cv73-mx4w](https://github.com/modelcontextprotocol/typescript-sdk/security/advisories/GHSA-w48q-cv73-mx4w)

## How Has This Been Tested?
all tests pass

## Breaking Changes
- `Route.mcp()`, `Application.mcp()` signatures changed (new
`enableDnsRebindingProtection`, `allowedHosts`, `allowedOrigins`
params), binary incompatible on JVM
- `enableDnsRebindingProtection` default changed from `false` to `true`
on `mcpStreamableHttp`/`mcpStatelessStreamableHttp`
- Default allowed hosts: `localhost`, `127.0.0.1`, `[::1]` — opt out
with `enableDnsRebindingProtection = false`
- Host validation is now port-agnostic (matches ts sdk)
- Origin validation now allows missing `Origin` header (non-browser
clients)
- `Configuration.enableDnsRebindingProtection`, `.allowedHosts`,
`.allowedOrigins` deprecated in favor of the plugin

## Types of changes
- [x] Bug fix (non-breaking change which fixes an issue)
- [x] New feature (non-breaking change which adds functionality)
- [x] Breaking change (fix or feature that would cause existing
functionality to change)
- [ ] Documentation update

## Checklist
- [x] I have read the [MCP
Documentation](https://modelcontextprotocol.io)
- [x] My code follows the repository's style guidelines
- [x] New and existing tests pass locally
- [x] I have added appropriate error handling
- [x] I have added or updated documentation as needed
2026-05-05 11:05:59 +02:00
..
api fix: enable DNS rebinding protection by default (#659) 2026-05-05 11:05:59 +02:00
src fix: enable DNS rebinding protection by default (#659) 2026-05-05 11:05:59 +02:00
build.gradle.kts refactor: explicit locked detekt config (#729) 2026-04-29 12:31:49 +02:00
detekt-baseline-main.xml refactor: explicit locked detekt config (#729) 2026-04-29 12:31:49 +02:00
Module.md fix!: Migrate Ktor extension functions from Routing to Route (#237) (#531) 2026-02-18 16:43:37 +02:00