Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrap tempfile usage to work around Windows/Golang bug #3724

Merged
merged 3 commits into from
Sep 5, 2024
Merged

Conversation

scudette
Copy link
Contributor

@scudette scudette commented Sep 5, 2024

This is a workaround to the introduction of GetTempPath2 in Windows. The Golang standard library switched to this API in recent Go version golang/go#56899

The GetTempPath2 API ignores the TEMP environment variable and always returns C:\Windows\SystemTemp for system level programs. This causes the os.TempDir() API to ignore our configuration of the correct temp location.

Since practically, we can not allow list the SystemTemp directory in e.g. EDR or other security products, this bug forces Velociraptor to write temp files in this common area ignoring the configuration file.

To work around this issue we wrap all calls to temporary files and ignore the os.TempDir() API completely.

This is a workaround to the introduction of GetTempPath2 in
Windows. The Golang standard library switched to this API in recent Go
version golang/go#56899

The GetTempPath2 API ignores the TEMP environment variable and
always returns C:\Windows\SystemTemp for system level programs. This
causes the os.TempDir() API to ignore our configuration of the
correct temp location.

Since practically, we can not allow list the SystemTemp directory in
e.g. EDR or other security products, this bug forces Velociraptor to
write temp files in this common area ignoring the configuration
file.

To work around this issue we wrap all calls to temporary files and
ignore the os.TempDir() API completely.
@scudette scudette merged commit 83980d6 into master Sep 5, 2024
3 checks passed
@scudette scudette deleted the tempfiles branch September 5, 2024 05:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant