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

Detect and fix improper file ownership on launch #722

Merged

Conversation

blaedj
Copy link
Contributor

@blaedj blaedj commented Mar 11, 2021

This commit:

  • detects a subset of what osquery will consider improper file
    perms/ownership on the extension binary
  • tries to fix those errors

We could and perhaps should apply this to the entire root directory,
and this doesn't yet work on windows.

This commit:
 - detects a subset of what osquery will consider improper file
 perms/ownership on the extension binary
 - tries to fix those errors

We could and perhaps should apply this to the entire root directory,
and this doesn't yet work on windows.
pkg/osquery/runtime/runtime.go Outdated Show resolved Hide resolved
pkg/osquery/runtime/runtime.go Outdated Show resolved Hide resolved
pkg/osquery/runtime/runtime.go Outdated Show resolved Hide resolved
pkg/osquery/runtime/runtime.go Outdated Show resolved Hide resolved
pkg/osquery/runtime/runtime.go Outdated Show resolved Hide resolved
@blaedj blaedj changed the title PoC for detecting & fixing improper file ownership on launch Detect and fix improper file ownership on launch Mar 11, 2021
This reverts commit 7b60a5d.

osqueryd is not in usr/local/, so is not likely to have perms
conflicting with homebrew.
@blaedj blaedj marked this pull request as ready for review March 12, 2021 16:56
Copy link
Contributor

@directionless directionless left a comment

Choose a reason for hiding this comment

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

Tested and appears to work as advertised. Yay!

Digging at a test case, I don't see a homebrew provided command or docs that creates this error. But chown $USER does cause this problem, and it shows up in various suggestions

@blaedj
Copy link
Contributor Author

blaedj commented Mar 17, 2021

            chown blaed ~/launcher_root_bad_perms
            sudo rm ~/launcher_root_bad_perms/kolide/bin/launcher
            sudo rm ~/launcher_root_bad_perms/kolide/bin/osquery-extension.ext

            cp ~/code/go/src/github.com/kolide/launcher/build/launcher ~/launcher_root_bad_perms/kolide/bin/
            cp ~/code/go/src/github.com/kolide/launcher/build/osquery-extension.ext ~/launcher_root_bad_perms/kolide/bin/

            sudo launchctl asuser 0 \
                 ~/launcher_root_bad_perms/kolide/bin/launcher \
                 -root_directory "~/launcher_root_bad_perms/kolide" \
                 -hostname localhost:5000 \
                 -enroll_secret_path secret.txt \
                 --osqueryd_path "~/launcher_root_bad_perms/kolide/bin/osqueryd" \
                 --insecure \
                 --insecure_transport \
                 -transport jsonrpc \
                 -autoupdate \
                 -update_channel="beta" \
                 -debug \
                 -with_initial_runner \
                 -disable_control_tls 

that's the script I used (or close to it) to test this out.

@directionless directionless merged commit e1a9027 into kolide:master Mar 17, 2021
@blaedj blaedj deleted the recover-from-unsafe-file-ownership branch March 17, 2021 00:25
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.

None yet

2 participants