Do not audit ephemeral users#26965
Conversation
Signed-off-by: Michael Boquard <michael@redpanda.com>
tests/rptest/tests/audit_log_test.py
Outdated
| @skip_fips_mode | ||
| @cluster(num_nodes=5) | ||
| def test_no_ephemeral_user(self): | ||
| """ | ||
| Verifies that ephemeral users do not generate audit messages | ||
| """ | ||
| self.setup_cluster() | ||
|
|
||
| user_rpk = self.get_rpk() | ||
|
|
||
| _ = user_rpk.list_topics() | ||
|
|
||
| start_time = time.time() | ||
|
|
||
| # Read all records that have the audit log user for two seconds - should not get any records | ||
| records = self.read_all_from_audit_log(partial(self.authn_filter_function, self.kafka_rpc_service_name, "__auditing", 99, "SASL-SCRAM"), | ||
| lambda records: time.time() >= start_time + 2) | ||
|
|
||
| assert len(records) == 0, f'Expected 0 records: {records}' |
There was a problem hiding this comment.
I did verify that if the changes I made in audit_log_manager.cc were removed that this test fails
rockwotj
left a comment
There was a problem hiding this comment.
I thought we had a discussion about this when first doing the project? When did we start producing audit logs for the audit log, doesn't that result in cycles where we always write to the audit log because we keep writing we wrote to it?
tests/rptest/tests/audit_log_test.py
Outdated
| start_time = time.time() | ||
|
|
||
| # Read all records that have the audit log user for two seconds - should not get any records | ||
| records = self.read_all_from_audit_log(partial(self.authn_filter_function, self.kafka_rpc_service_name, "__auditing", 99, "SASL-SCRAM"), |
There was a problem hiding this comment.
does this have produce auditing on?
We already excluded the produces to the audit log. This is just expands that to include all audit events for all ephemeral users |
2384986 to
f6cd5f1
Compare
|
Force push:
|
f6cd5f1 to
e774c77
Compare
|
Force push:
|
Does that mean there is logic we can remove/cleanup now? |
Retry command for Build#69563please wait until all jobs are finished before running the slash command |
CI test resultstest results on build#69563
test results on build#69665
|
pgellert
left a comment
There was a problem hiding this comment.
Looks good.
The new test is failing in CI, I suspect it's because of the stop condition. It's probably worth running it on repeat a couple times on CI to make sure it never fails.
| _audit_user.type_id = _principal.type() == principal_type::user | ||
| ? audit::user::type::user | ||
| : _principal.type() == principal_type::ephemeral_user | ||
| ? audit::user::type::system | ||
| : audit::user::type::other; |
There was a problem hiding this comment.
nit:
switch statement instead of if/elseif ternary
Oh good point, yeah probably |
Actually that's an older test that did validate that the audit user did authenticate and generate an audit event. This change makes that part of the test unecessary. |
e774c77 to
2a16a3c
Compare
|
Force push:
|
If ephemeral user, make the user type by system in OCSF Signed-off-by: Michael Boquard <michael@redpanda.com>
2a16a3c to
08de292
Compare
|
Force push:
|
Ephemeral users are used by auditing and schema registry. There is no reason to audit the auditing ephemeral user as that does not correspond to a user derived action. For schema registry, there are already audit events tracked when the user access SR via the SR API. It isn't necessary to audit that the SR client has performed an action. Signed-off-by: Michael Boquard <michael@redpanda.com>
08de292 to
6b1d48e
Compare
|
Force push:
|
| == security::audit::event_type::produce | ||
| && principal == security::audit_principal; | ||
| /// Skips auditing ephemeral users | ||
| inline bool skip_auditing(const security::acl_principal& principal) { |
There was a problem hiding this comment.
why do we need this check at both levels?
There was a problem hiding this comment.
This allows the Kafka API to short circuit earlier in the auditing checks. The other check would apply to all other interfaces (existing or future) that need to generate audit events. I'd say it's a slight optimization just on the Kafka API.
There was a problem hiding this comment.
Would be useful to add a comment in the source to that effect that it's only an optimization.
| == security::audit::event_type::produce | ||
| && principal == security::audit_principal; | ||
| /// Skips auditing ephemeral users | ||
| inline bool skip_auditing(const security::acl_principal& principal) { |
There was a problem hiding this comment.
Would be useful to add a comment in the source to that effect that it's only an optimization.
|
/backport v25.2.x |
|
/backport v25.1.x |
|
/backport v24.3.x |
|
Failed to create a backport PR to v25.1.x branch. I tried: |
|
Failed to create a backport PR to v24.3.x branch. I tried: |
Redpanda will no longer generate audit events for ephemeral users. Ephemeral users are only used by internal Redpanda services (SR and auditing).
Fixes: CORE-12910
Backports Required
Release Notes
Improvements