Repository navigation
osquery extensions: verified, root-owned install with rollback and per-extension status - #28
Merged
Merged
Conversation
…r-extension status
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.
osquery extensions: verified, root-owned install with rollback and per-extension status
Companion to the osctrl change that adds an extension library, environment and host assignments, and the osctrld routes
POST /{env}/osctrld-extensions(list) andPOST /{env}/osctrld-extension(download). Builds on per-node flags overrides (#27).Problem
osctrld's extension sync wasn't safe to run as root, and osquery couldn't load what it installed:
extensions.load, never removed extensions dropped from the list, and an empty list did nothing.What changes
Protocol
{secret, uuid?, platform, arch, status?}. The UUID is the cached host UUID used by the flags step;platform/archcome fromruntime.GOOS/GOARCH.{name, sha256, size, url}per extension.POST <osctrl base>/<env>/osctrld-extensionwith{secret, sha256}, built from osctrld's own configured base. The list'surlis never used to choose where to connect.Safe install (
extensions.go,owner_posix.go,owner_windows.go)^[A-Za-z0-9_-]{1,64}$. The file is<name>.ext, or<name>.exeon Windows.0755, and the file is renamed over the target.SetNamedSecurityInfo.Extensions step (
extguard.go,service.go) runs after the flags step, with its own restart and check.Autoload file:
--extensions_autoloadfrom the current flagfile if set, otherwise osquery's default. Either way it must be a*.loadfile directly in osquery's base directory, root-owned, and not the flagfile, secret, certificate or osctrld state files.Removal: only files osctrld installed are removed; operator files are never touched. Replaced or removed files are renamed aside (
.prev) until verified, which also handles Windows file locks. Leftover temp files are swept.Verification: after the restart, within 60 s osqueryd must be running and each changed extension must have a running process from its installed path.
rejected.Interruptions: pending and restarted markers resume a check cut short by a crash, SIGTERM or a failed restart, restarting first when needed.
Status per extension, sent on the next request:
ok;rejected;kept: a removal failed (osqueryd went down, the file couldn't be moved aside, or the autoload file couldn't be written). It is re-sent on every sync until osctrl serves that name again.removed: removed successfully.okis also sent when osctrl serves a kept extension again at the version still installed.Errors are capped at 256 bytes, and the queue is deduplicated by name, newest kept, capped at 24 entries. The queue is dropped only on HTTP 400/413; it's kept on 401/403, 5xx and network errors.
Disabled extensions: if the flags set
--disable_extensions, files are still installed and the status says extensions are disabled.Security and operational impact
/etc/sudoersor/etc/ld.so.preload.kepton every sync, so osctrl keeps warning about it until it's gone.<flagfile>.osctrld-extensions-state.json, mode0600.keptandremoved.rejected, which osctrl doesn't flag.Validation
go test ./... -count=1passes, also with-race.go vet ./...is clean forGOOS=darwin,linuxandwindows;gofmt -l cmdprints nothing.golangci-lint run ./...: 0 issues, also withGOOS=windows.go build -o /dev/null ./cmd/osctrld: ok..load, protected files, symlinks), operator lines kept, drift repair, refusal reported once.kepton every failure path and re-sent each sync,removed,okwhen served again, caps, deduplication, drop only on 400/413.