[Comgr] Use secure_getenv() for environment variable reads on glibc#3069
Open
lamb-j wants to merge 1 commit into
Open
[Comgr] Use secure_getenv() for environment variable reads on glibc#3069lamb-j wants to merge 1 commit into
lamb-j wants to merge 1 commit into
Conversation
Route all env-var reads in comgr-env.cpp through a __GLIBC__-gated COMGR_GETENV macro (secure_getenv on glibc, plain getenv elsewhere) so env-controlled file paths are ignored under AT_SECURE. Windows/macOS/musl take the getenv fallback, unchanged. Addresses security-triage finding SEC-00183 (ROCM-26567).
chinmaydd
reviewed
Jun 25, 2026
Comment on lines
+25
to
+29
| #if defined(__GLIBC__) | ||
| #define COMGR_GETENV secure_getenv | ||
| #else | ||
| #define COMGR_GETENV getenv | ||
| #endif |
There was a problem hiding this comment.
Windows seems to have an equivalent. Can we add handling for that ?
https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/getenv-s-wgetenv-s?view=msvc-170
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.
Routes all env-var reads in
comgr-env.cppthrough a__GLIBC__-gatedCOMGR_GETENVmacro (secure_getenvon glibc, plaingetenvelsewhere) so env-controlled file paths (AMD_COMGR_REDIRECT_LOGS,AMD_COMGR_CACHE_DIR,AMD_COMGR_SAVE_TEMPS,AMD_COMGR_TIME_STATISTICS, etc.) are ignored underAT_SECURE(setuid/setgid / file-capability processes).Windows, macOS, and musl have no
AT_SECUREconcept and nosecure_getenv(), so they take thegetenv()fallback — behavior there is unchanged.Addresses security-triage finding SEC-00183 (ROCM-26567). Path validation /
O_NOFOLLOWfrom the scan's remediation were intentionally not added: these env vars are documented features that legitimately take absolute user paths.