Skip to content

[SDK] Handle denied environment variable access - #8070

Merged
Kielek merged 3 commits into
open-telemetry:mainfrom
Kielek:codex/handle-denied-environment-access
Oct 30, 2026
Merged

Kielek merged 3 commits into
open-telemetry:mainfrom
Kielek:codex/handle-denied-environment-access

Conversation

@Kielek

@Kielek Kielek commented Oct 30, 2026 •

Copy link
Copy Markdown
Member

Related Codex Security Cloud finding: commit:4caf64fc74c48191ab4ac4df4c3318fe.

Changes

Denied environment-variable access can throw SecurityException during SDK/exporter initialization or configuration reload. Register a guarded environment provider at all 10 construction sites. Failed initial loads use defaults; failed reloads retain the last successful snapshot and allow a later retry. Guard deferred key reads in resource detection and the shared typed readers as well.

Regression tests exercise real permission denial on .NET Framework, reload recovery, readable resource values, host defaults, and propagation of other exception types. No public API changes.

Merge requirement checklist

  • CONTRIBUTING guidelines followed (license requirements, successful build/tests, etc.)
  • Tests added/updated
  • CHANGELOG.md file(s) updated for non-trivial changes
  • Changes in public API reviewed (if applicable)
  • AI usage disclosure:
    • No AI used
    • AI-assisted
    • Bulk AI-generated
  • I have the experience and knowledge necessary to understand, review, and validate all content in this PR1

Note

This PR description was generated with OpenAI Codex.

Footnotes

  1. Yes, I can answer maintainer questions about the content of this PR without using AI. ↩

Handle denied environment access during initial load and reload. Keep the
last successful snapshot and allow later recovery. Preserve readable resource
configuration and host defaults.

Addresses Codex Security Cloud finding commit:4caf64fc74c48191ab4ac4df4c3318fe.
@opentelemetry-pr-dashboard

opentelemetry-pr-dashboard Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Pull request dashboard status

Merged · refreshed 2026-10-30 15:43 UTC

Status above doesn't look right?
  • Anything look wrong? Report it with what you expected; it helps us improve the dashboard.

@github-actions github-actions Bot added pkg:OpenTelemetry.Exporter.OpenTelemetryProtocol Issues related to OpenTelemetry.Exporter.OpenTelemetryProtocol NuGet package pkg:OpenTelemetry.Exporter.Prometheus.HttpListener Issues related to OpenTelemetry.Exporter.Prometheus.HttpListener NuGet package pkg:OpenTelemetry.Exporter.Zipkin Issues related to OpenTelemetry.Exporter.Zipkin NuGet package pkg:OpenTelemetry.Extensions.Hosting Issues related to OpenTelemetry.Extensions.Hosting NuGet package pkg:OpenTelemetry Issues related to OpenTelemetry NuGet package labels Oct 30, 2026
Document the SDK, OTLP, Zipkin, Prometheus HttpListener, and hosting fixes
with their contribution link to PR open-telemetry#8070.

Addresses Codex Security Cloud finding commit:4caf64fc74c48191ab4ac4df4c3318fe.
@Kielek
Kielek marked this pull request as ready for review October 30, 2026 13:25
@Kielek
Kielek requested a review from a team as a code owner October 30, 2026 13:25

@martincostello martincostello left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Feels a bit OTT in practice, but it centralises some otherwise duplicated call blocks.

@codecov

codecov Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.73%. Comparing base (4e3d636) to head (75e31dc).
⚠️ Report is 1 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #8070      +/-   ##
==========================================
- Coverage   90.76%   90.73%   -0.03%     
==========================================
  Files         382      382              
  Lines       22581    22580       -1     
  Branches     4179     4178       -1     
==========================================
- Hits        20495    20489       -6     
- Misses       1503     1506       +3     
- Partials      583      585       +2     
Flag Coverage Δ
unittests-Project-Experimental 90.70% <100.00%> (-0.10%) ⬇️
unittests-Project-Stable 90.73% <100.00%> (-0.02%) ⬇️
unittests-Solution 90.76% <100.00%> (+0.03%) ⬆️
unittests-UnstableCoreLibraries-Experimental 43.17% <33.33%> (-0.06%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...etryProtocol/Implementation/ExperimentalOptions.cs 87.50% <100.00%> (ø)
...elemetryProtocol/Implementation/SdkLimitOptions.cs 100.00% <100.00%> (ø)
...orter.OpenTelemetryProtocol/OtlpExporterOptions.cs 97.88% <100.00%> (ø)
...heus.HttpListener/PrometheusHttpListenerOptions.cs 100.00% <100.00%> (ø)
...Telemetry.Exporter.Zipkin/ZipkinExporterOptions.cs 100.00% <100.00%> (ø)
.../Implementation/HostEnvironmentResourceDetector.cs 100.00% <100.00%> (ø)
...lder/ProviderBuilderServiceCollectionExtensions.cs 100.00% <100.00%> (ø)
.../Processor/BatchExportLogRecordProcessorOptions.cs 100.00% <100.00%> (ø)
...ics/Reader/PeriodicExportingMetricReaderOptions.cs 100.00% <100.00%> (ø)
...enTelemetry/Resources/ResourceBuilderExtensions.cs 100.00% <100.00%> (ø)
... and 1 more

... and 2 files with indirect coverage changes

Separate switch sections, fail explicitly on unexpected result types,
and qualify types instead of adding one-use namespace imports throughout
the modified files.

Addresses Codex Security Cloud finding commit:4caf64fc74c48191ab4ac4df4c3318fe.
@Kielek
Kielek force-pushed the codex/handle-denied-environment-access branch from 1e6d489 to 75e31dc Compare October 30, 2026 14:28
@Kielek
Kielek requested a review from martincostello October 30, 2026 14:30
@Kielek
Kielek added this pull request to the merge queue Oct 30, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Oct 30, 2026
@Kielek
Kielek added this pull request to the merge queue Oct 30, 2026
Merged via the queue into open-telemetry:main with commit 99d3c02 Oct 30, 2026
61 checks passed
@Kielek
Kielek deleted the codex/handle-denied-environment-access branch October 30, 2026 15:43
@martincostello martincostello added this to the v1.21.0 milestone Oct 30, 2026
This was referenced Nov 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pkg:OpenTelemetry.Exporter.OpenTelemetryProtocol Issues related to OpenTelemetry.Exporter.OpenTelemetryProtocol NuGet package pkg:OpenTelemetry.Exporter.Prometheus.HttpListener Issues related to OpenTelemetry.Exporter.Prometheus.HttpListener NuGet package pkg:OpenTelemetry.Exporter.Zipkin Issues related to OpenTelemetry.Exporter.Zipkin NuGet package pkg:OpenTelemetry.Extensions.Hosting Issues related to OpenTelemetry.Extensions.Hosting NuGet package pkg:OpenTelemetry Issues related to OpenTelemetry NuGet package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants