Skip to content

[Azure Monitor Exporter] Fix/quickpulse redirect validation#46966

Merged
hectorhdzg merged 1 commit into
Azure:mainfrom
hectorhdzg:fix/quickpulse-redirect-validation
May 20, 2026
Merged

[Azure Monitor Exporter] Fix/quickpulse redirect validation#46966
hectorhdzg merged 1 commit into
Azure:mainfrom
hectorhdzg:fix/quickpulse-redirect-validation

Conversation

@hectorhdzg
Copy link
Copy Markdown
Member

Problem
The QuickPulse redirect policy (_quickpulse/_policy.py) parsed the x-ms-qps-service-endpoint-redirect-v2 header and updated _base_url to any provided host without validation. An attacker with network-level access (MITM, DNS poisoning, compromised proxy) could redirect all future LiveMetrics traffic—including auth headers and telemetry data—to an attacker-controlled host, persisting for the lifetime of the process.

Fix
HTTPS-only enforcement: Rejects any redirect with a non-HTTPS scheme (prevents protocol downgrade)
Domain allowlist validation: Only accepts redirects to known Azure Monitor domain suffixes:
.livediagnostics.monitor.azure.com
.monitor.azure.com
.services.visualstudio.com
.applicationinsights.azure.com
Sovereign cloud variants (.azure.us, .azure.cn)
Logging: Emits a warning when a redirect is rejected
Tests: Adds comprehensive unit tests covering trusted/untrusted hosts, HTTP downgrade, and domain spoofing attempts

Copilot AI review requested due to automatic review settings May 18, 2026 21:14
@github-actions github-actions Bot added the Monitor - Exporter Monitor OpenTelemetry Exporter label May 18, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR hardens the Azure Monitor OpenTelemetry Exporter QuickPulse redirect handling to prevent malicious redirect targets from persisting for the lifetime of a process, by enforcing HTTPS-only redirects and validating redirect hosts against a trusted Azure Monitor domain allowlist.

Changes:

  • Added redirect-target validation logic (HTTPS enforcement + allowed domain suffixes) with warning logs on rejection.
  • Introduced _is_redirect_target_allowed helper for domain allowlist checks.
  • Expanded unit tests to cover accepted/rejected redirect scenarios.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/_quickpulse/_policy.py Adds HTTPS-only + domain allowlist validation and warning logs for rejected QuickPulse redirects.
sdk/monitor/azure-monitor-opentelemetry-exporter/tests/quickpulse/test_policy.py Adds new unit tests validating redirect acceptance/rejection and host allowlist behavior.

Comment thread sdk/monitor/azure-monitor-opentelemetry-exporter/tests/quickpulse/test_policy.py Outdated
@hectorhdzg hectorhdzg force-pushed the fix/quickpulse-redirect-validation branch 2 times, most recently from a276ad9 to 8618709 Compare May 19, 2026 20:25
The QuickPulse redirect policy previously accepted any Location header
value and updated _base_url without validation. This allowed potential
redirect poisoning where an attacker with network-level access could
redirect all LiveMetrics traffic (including auth headers and telemetry)
to an attacker-controlled host.

This fix:
- Enforces HTTPS-only scheme on redirect targets (no protocol downgrade)
- Validates redirect host against an allowlist of trusted Azure Monitor
  domain suffixes (.monitor.azure.com, .services.visualstudio.com,
  .applicationinsights.azure.com, and sovereign cloud variants)
- Uses urlparse hostname extraction to prevent userinfo (@) bypass attacks
- Rejects redirects containing username/password in the URL
- Returns None (rejecting the redirect) for untrusted targets
- Logs a warning when a redirect is rejected for observability
- Adds comprehensive unit tests for validation logic including userinfo
  bypass, domain spoofing, HTTP downgrade, and trusted domain acceptance
@hectorhdzg hectorhdzg force-pushed the fix/quickpulse-redirect-validation branch from 8618709 to 2bfbf26 Compare May 19, 2026 20:49
@hectorhdzg hectorhdzg merged commit f1aaee2 into Azure:main May 20, 2026
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Monitor - Exporter Monitor OpenTelemetry Exporter

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants