-
Notifications
You must be signed in to change notification settings - Fork 581
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
feat: add auditd service #9620
feat: add auditd service #9620
Conversation
@dsseng you could try this PR |
Will rebase and take a look now |
working a bit on it to actually avoid printk output |
we can probably parse events if that makes it easier to consume for human beings ;) |
We can, yes
|
yeh I guess the library has |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM otherwise. Unsure if a test is possible. Did you test without SELinux? Is anything in the audit log in that case? If so, we can add an integration for len > 1
without selinux there was nothing, so I was not sure if it was working at all 😅 |
The current format fits well for |
Pretty weird, after my patch on top of your branch logs have some tens of messages, so an integration test should work |
First ones are these, so we surely can know something is in audit once it's initialized:
|
Ah, might be wrong, I've got SELinux cmdline as I didn't rebuild talosctl |
No, even without SE it has a bulk of audit logs, try that again with my suggested change |
9dd38b8
to
5a1b498
Compare
9cacf59
to
f009031
Compare
f009031
to
e93c44c
Compare
e93c44c
to
1b09f63
Compare
The library creates a socket without |
internal/app/auditd/auditd.go
Outdated
switch format { | ||
case "summary": | ||
sm := event.Summary | ||
|
||
fmt.Fprintf( | ||
s.writer, | ||
`%s: sequence=%v category=%v type=%v actor=%v/%v action=%v thing=%v/%v how=%v tags=%v`+"\n", | ||
event.Timestamp.Format("2006/01/02 15:04:05.000000"), event.Sequence, event.Category, event.Type, sm.Actor.Primary, sm.Actor.Secondary, | ||
sm.Action, sm.Object.Primary, sm.Object.Secondary, sm.How, event.Tags, | ||
) | ||
case "yaml": | ||
s.writer.Write([]byte("---\n")) //nolint:errcheck | ||
yaml.NewEncoder(s.writer).Encode(event) //nolint:errcheck | ||
case "json": | ||
json.NewEncoder(s.writer).Encode(event) //nolint:errcheck,errchkjson | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not a format SELinux tools, or maybe some generic Linux security tools people might want to pipe audit data into would accept. Honestly it looks way less human-readable than Linux default format :(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or maybe I'm doing something wrong that I cannot get raw logs using talosctl
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think raw should be closer, and we can adjust it
note to self: disable when platform mode is container |
this was already handled |
some thoughts, I think we should only enable if |
I think we should run As for the format, let's stick with something for now (e.g. We can probably make |
Yes, let's do raw for now, as it's likely to be more useful to people who use osquery or other common Linux tools for analyzing audit logs. And perhaps audit logs will be useful for later (e.g. if something doesn't work under SELinux it provides debug info), and also might be wanted by some customers (well, some users read audit) |
https://github.com/threathunters-io/laurel some examples of software reading audit |
Should we then skip dropping some audit events?
actually we can add a parser in talosctl client side or just point to |
yes, we better do this. Just give out events as given by the kernel from Talos, and then process on the client side (also make it configurable via cli opts)
Do we skip any? I believe 1300-2999 is quite complete |
That's where i'm confused the comment says so, but // Messages from 1300-2999 are valid audit messages.
if rawEvent.Type < auparse.AUDIT_USER_AUTH ||
rawEvent.Type > auparse.AUDIT_LAST_USER_MSG2 {
continue
} hmm I think it's the comment that's wrong since types b/w 1000-1100 are actually related to audit subsystem itself t (
AUDIT_GET AuditMessageType = 1000
AUDIT_SET AuditMessageType = 1001
AUDIT_LIST AuditMessageType = 1002
AUDIT_ADD AuditMessageType = 1003
AUDIT_DEL AuditMessageType = 1004
AUDIT_USER AuditMessageType = 1005
AUDIT_LOGIN AuditMessageType = 1006
AUDIT_WATCH_INS AuditMessageType = 1007
AUDIT_WATCH_REM AuditMessageType = 1008
AUDIT_WATCH_LIST AuditMessageType = 1009
AUDIT_SIGNAL_INFO AuditMessageType = 1010
AUDIT_ADD_RULE AuditMessageType = 1011
AUDIT_DEL_RULE AuditMessageType = 1012
AUDIT_LIST_RULES AuditMessageType = 1013
AUDIT_TRIM AuditMessageType = 1014
AUDIT_MAKE_EQUIV AuditMessageType = 1015
AUDIT_TTY_GET AuditMessageType = 1016
AUDIT_TTY_SET AuditMessageType = 1017
AUDIT_SET_FEATURE AuditMessageType = 1018
AUDIT_GET_FEATURE AuditMessageType = 1019
AUDIT_USER_AUTH AuditMessageType = 1100 |
Adds a auditd service that gathers all audit logs from kernel. Signed-off-by: Noel Georgi <git@frezbo.dev> Signed-off-by: Andrey Smirnov <andrey.smirnov@siderolabs.com> Signed-off-by: Noel Georgi <git@frezbo.dev>
1b09f63
to
9abf161
Compare
I've dropped the log format and will implement in client side as a different PR, now logs as standard auditd format |
/m |
We are using Are there any plans for machine config/ a controller for auditd? I'd expect at least the auditd rules are something that would make sense as machine config/controller. For other config, such as auditd plugins I think just dropping a config file into the respective auditd config dir would be fine since not everybody will use plugins (we use the |
No, no plans to so far besides what is in this PR. |
Is your config still working? If not, we might want to have a disable flag to avoid Talos capturing the audit logs on its own |
Adds a auditd service that gathers all audit logs from kernel.