Remove metadata IP blocklist from DB check URL validation#453
Remove metadata IP blocklist from DB check URL validation#453
Conversation
The metadata IP blocklist (169.254.169.254, etc.) is vulnerable to DNS rebinding attacks (TOCTOU between validation and runtime), performs DNS resolution in the reconcile loop which adds latency and fragility, and is inherently incomplete. Scheme validation (blocking file://, gopher://, etc.) remains as the effective SSRF mitigation layer. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
@nickmisasi: Adding the "do-not-merge/release-note-label-needed" label because no release-note block was detected, please follow our release note process to remove it. DetailsI understand the commands that are listed here |
|
/release-note-none |
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
📝 WalkthroughWalkthroughThis change removes IP range filtering and DNS resolution logic from database external URL validation. The validateDBCheckURL function now performs only basic URL parsing, scheme validation, and hostname presence checks, eliminating metadata IP blocking behaviour and associated test coverage. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@pkg/mattermost/database_external.go`:
- Around line 177-179: The current URL validation only checks parsed.Hostname(),
allowing literal IPs (e.g., 169.254.169.254) which is an SSRF risk; change the
validation in the same block that checks parsed.Hostname() to also call
net.ParseIP(parsed.Hostname()) and return an error if it returns non-nil (i.e.,
the host is a literal IP). Import the "net" package if needed and keep the
existing DNS/name checks intact while deterministically rejecting literal IP
hosts (refer to the parsed variable and the hostname check where you added `if
parsed.Hostname() == ""`).
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 07054181-bc00-49e2-941b-3a54e29028b9
📒 Files selected for processing (2)
pkg/mattermost/database_external.gopkg/mattermost/database_external_test.go
💤 Files with no reviewable changes (1)
- pkg/mattermost/database_external_test.go
Summary
169.254.169.254,100.100.100.200,fd00:ec2::254) and associated DNS resolution fromvalidateDBCheckURLhostnameResolver/defaultResolveHostnameIPsfunctions and test stubfile://,gopher://, etc.) which provides effective SSRF mitigationWhy
The metadata IP blocklist was vulnerable to DNS rebinding (TOCTOU between validation at reconcile time and actual request at pod runtime), performed DNS resolution in the reconcile loop adding latency and fragility, and was inherently incomplete. Scheme validation is the effective layer here; network-level controls (e.g., NetworkPolicies) are the correct place to block metadata endpoint access.
Test plan
file://,gopher://,ftp://,javascript:blockingmysql://scheme)🤖 Generated with Claude Code
Summary by CodeRabbit
Refactor
Tests