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

Fix audit rule removal upon osquery exit #7221

Merged
merged 1 commit into from
Aug 15, 2021

Conversation

prateeknischal
Copy link
Contributor

The audit rules were not getting removed when osquery exits as part of
the cleanup process. This was due to not adding the audit rule to the
cleanup list unless osquery was run with --audit_force_unconfigure. The
force unconfigure option is to remove the rules irrespective of the their
install exit code which was not followed in the #7063.

The current fix is going to install the rule for cleanup either the error
code is non-negative or osquery is asked to force reconfigure. This would
also fix the double adding of the audit rules as mentioned in #7205.

Smjert
Smjert previously requested changes Aug 3, 2021
Copy link
Member

@Smjert Smjert left a comment

Choose a reason for hiding this comment

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

@prateeknischal thanks for looking into this!

There's only one correction to be done and then it's good to go!

} else if (FLAGS_audit_debug) {
VLOG(1) << "Audit rule installed for all queued syscalls";
}

if (FLAGS_audit_force_unconfigure) {
if (FLAGS_audit_force_reconfigure || rule_add_error >= 0) {
Copy link
Member

@Smjert Smjert Aug 3, 2021

Choose a reason for hiding this comment

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

FLAGS_audit_force_reconfigure should be FLAGS_audit_force_unconfigure.
Reconfigure is a "stronger" operation than unconfigure and it lists all the rules currently active on it's own and removes them (among other things).
Unconfigure is meant to remove all rules that osquery has ever added, even if they have not been added in the current run. But rules that have been added by an administrator should not be touched.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Aah, the autocomplete, I had intended to write unconfigure, I would have accepted this suggestion from the autocomplete. I should have been more careful. Thank you for the review. I have updated the pull request.

The audit rules were not getting removed when osquery exits as part of
the cleanup process. This was due to not adding the audit rule to the
cleanup list unless osquery was run with --audit_force_unconfigure. The
force unconfigure option is to remove the rules irrespective of the their
install exit code which was not followed in the osquery#7063.

The current fix is going to install the rule for cleanup either the error
code is non-negative or osquery is asked to force reconfigure. This would
also fix the double adding of the audit rules as mentioned in osquery#7205.
@prateeknischal prateeknischal force-pushed the fix_audit_rule_uninstall branch from 4cf4dcc to 24fcf05 Compare August 3, 2021 17:45
@prateeknischal prateeknischal requested a review from Smjert August 3, 2021 17:46
@theopolis theopolis dismissed Smjert’s stale review August 15, 2021 01:16

changes applied

@theopolis theopolis merged commit a08056b into osquery:master Aug 15, 2021
aikuchin pushed a commit to aikuchin/osquery that referenced this pull request Jul 11, 2023
…1 to master

* commit 'f72b7c5510b8cd78c9d0450cbd1f31903681caa5': (53 commits)
  Add `TimeoutStopSec` to systemd unit files (osquery#7190)
  Prevent osquery from killing itself when the --force flag is used (osquery#7295)
  Linux: Support AF_PACKET sockets. (osquery#7282)
  libs: update openssl to 1.1.1l (osquery#7293)
  Correct macOS installed app bundle path in osqueryctl and doc (osquery#7289)
  macos path fix in launchd plist (osquery#7288)
  Update osquery installed artifacts default paths in code (osquery#7285)
  Update osquery installed artifacts paths in the documentation (osquery#7286)
  Update packaging SHA (osquery#7279)
  Change to the `disk_encryption` table to support QueryContext (osquery#7209)
  Add feature to skip denylist for event-based queries (osquery#7158)
  Support pid_with_namespace in more tables (osquery#7132)
  audit: socket_events improvements (osquery#7269)
  [linux][packaging] Update packaging paths (osquery#7271)
  Change logger_mode flag to be actually interpreted as an octal (osquery#7273)
  Update `uptime` table descrption (osquery#7270)
  [macOS][packaging] Create an app bundle along with other package_data (osquery#7263)
  Add case sensitive pragma to the pragma/actions authorizer allow list (osquery#7267)
  Fix audit rule removal upon osquery exit (osquery#7221)
  Fix osquery_info build_platform column value on Linux (osquery#7254)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants