Add ownership checks for storage directories#46725
Merged
Merged
Conversation
6dd46aa to
48418a3
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds hardening for local storage by verifying directory ownership on Unix-like systems and using atomic file creation to mitigate race-condition style attacks.
Changes:
- Switch temp-file writes to
os.open(..., O_CREAT | O_EXCL, ...)to prevent overwrite/race conditions when creating.tmpfiles. - Add Unix directory ownership validation (must be owned by current uid or root) before enabling local storage.
- Expand unit tests to cover ownership outcomes and attacker scenarios (pre-created dirs, symlinks, pre-created temp files).
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| sdk/monitor/azure-monitor-opentelemetry-exporter/tests/test_storage.py | Updates existing tests for os.open and adds new tests for directory ownership and attack scenarios. |
| sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/_storage.py | Implements atomic .tmp creation via O_EXCL and adds Unix ownership checks using lstat/getuid. |
| sdk/monitor/azure-monitor-opentelemetry-exporter/CHANGELOG.md | Documents the new ownership-check behavior in the unreleased changelog. |
JacksonWeber
reviewed
May 5, 2026
JacksonWeber
approved these changes
May 5, 2026
88c3147 to
bdec112
Compare
595a955 to
a4878a5
Compare
JacksonWeber
approved these changes
May 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
All SDK Contribution checklist:
General Guidelines and Best Practices
Testing Guidelines