Skip to content

Better control on user injected environment values#36132

Merged
jentfoo merged 2 commits intomasterfrom
jent/mac_env_filter_fix
Dec 29, 2023
Merged

Better control on user injected environment values#36132
jentfoo merged 2 commits intomasterfrom
jent/mac_env_filter_fix

Conversation

@jentfoo
Copy link
Copy Markdown
Contributor

@jentfoo jentfoo commented Dec 29, 2023

Public release of private fix: https://github.com/gravitational/teleport-private/pull/1218
PR fixes: https://github.com/gravitational/teleport-private/issues/1214
Will be disclosed under advisory: GHSA-vfxf-76hv-v4w4

This change expands the filtering done on environment variables so that possible code execution variables for macOS are excluded. Additionally the user provided values are removed from a point of execution done under root.

This PR expands this protection further by filtering all DYLD_ and LD_ prefixed variables. However this change will not be backported and instead is planned to be a release as a behavior change in v15.

changelog: macOS agent environment filtering documented under GHSA-vfxf-76hv-v4w4

This commit includes two changes:
  * In `environment` we expanded the list of MacOS environment values which should be filtered.  It was demonstrated that these can be used to get code execution in MacOS.
  * In `reexec` we no longer provide the cmdmsg.Environment for the `teleport exec`.  As part of the development of a9055bc it was attempted to fully clear out the environment, but testing showed that to be potentially problematic.  It was believed the safest option was to use the cmd environment, however this introduces a new source of environment variables.  Because this exec happens under `root` this is particularly dangerous (even more so when combined with the missed OSX values mentioned above).  As such we now are only providing the filtered exec environment, which is a closer (but safer) option to the functionality prior to a9055bc.
@jentfoo jentfoo requested a review from AntonAM December 29, 2023 18:32
@jentfoo jentfoo added this pull request to the merge queue Dec 29, 2023
Merged via the queue into master with commit fcc97de Dec 29, 2023
@jentfoo jentfoo deleted the jent/mac_env_filter_fix branch December 29, 2023 19:46
@zmb3 zmb3 mentioned this pull request Mar 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

security Security Issues size/sm

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants