Skip to content

Osquerybeat: lock down flagfile, prevent global defaults#27611

Merged
aleksmaus merged 1 commit intoelastic:masterfrom
aleksmaus:feature/lockdown_flagsfile
Aug 31, 2021
Merged

Osquerybeat: lock down flagfile, prevent global defaults#27611
aleksmaus merged 1 commit intoelastic:masterfrom
aleksmaus:feature/lockdown_flagsfile

Conversation

@aleksmaus
Copy link
Copy Markdown
Contributor

@aleksmaus aleksmaus commented Aug 26, 2021

What does this PR do?

Lock down flagfile, prevent global defaults, otherwise the osqueryi and osqueryd processes try to load defaults from
osquery.flags.defaults file from OSQUERY_HOME locations:
https://github.com/osquery/osquery/blob/2cd5b42c8f8fa52c6d251c6537595c7c59c90f4c/osquery/utils/config/default_paths.h

and can potentially mess with configuration if it was not specified by us via the command line flags.

This could be considered a bug or a feature, for example without this change you can create
/var/osquery/osquery.flags.defaults on Mac with content
--disable_tables=users
and this will prevent any osquery instance (including ours) from querying this table.

Why is it important?

This change prevents global osquery defaults flagfile from affecting our osquery instance configuration.

Checklist

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas

Screenshots

Empty osquery.flags file is created in the osquery "data" directory
Screen Shot 2021-08-26 at 10 31 44 AM

Logs

Starting our osqueryd instance with flagfile parameter

{"log.level":"debug","@timestamp":"2021-08-26T10:27:57.567-0400","log.logger":"osquerybeat","log.origin":{"file.name":"osqd/osqueryd.go","file.line":157},"message":"start osqueryd process: args: [/Users/amaus/elastic/beats/x-pack/elastic-agent/build/distributions/elastic-agent-8.0.0-SNAPSHOT-darwin-x86_64/data/elastic-agent-8b4759/install/osquerybeat-8.0.0-SNAPSHOT-darwin-x86_64/osqueryd --force=true --disable_watchdog --utc --pidfile=osquery/osquery.pid --database_path=osquery/osquery.db --extensions_socket=/var/run/609582505/osquery.sock --logger_path=osquery --extensions_autoload=osquery/osquery.autoload --flagfile=osquery/osquery.flags --extensions_interval=3 --extensions_timeout=10 --config_plugin=osq_config --logger_plugin=osq_logger --config_refresh=60 --verbose --disable_logging=false]","service.name":"osquerybeat","ecs.version":"1.6.0"} 

@aleksmaus aleksmaus added Team:Asset Mgt backport-v7.16.0 Automated backport with mergify labels Aug 26, 2021
@botelastic botelastic bot added needs_team Indicates that the issue/PR needs a Team:* label and removed needs_team Indicates that the issue/PR needs a Team:* label labels Aug 26, 2021
@aleksmaus aleksmaus changed the title Osquerybeat: lock down flagsfile, prevent global defaults Osquerybeat: lock down flagfile, prevent global defaults Aug 26, 2021
@elasticmachine
Copy link
Copy Markdown
Contributor

💚 Build Succeeded

the below badges are clickable and redirect to their specific view in the CI or DOCS
Pipeline View Test View Changes Artifacts preview preview

Expand to view the summary

Build stats

  • Start Time: 2021-08-26T14:32:58.408+0000

  • Duration: 54 min 9 sec

  • Commit: 7cb5d12

Test stats 🧪

Test Results
Failed 0
Passed 3840
Skipped 0
Total 3840

Trends 🧪

Image of Build Times

Image of Tests

💚 Flaky test report

Tests succeeded.

Expand to view the summary

Test stats 🧪

Test Results
Failed 0
Passed 3840
Skipped 0
Total 3840

Copy link
Copy Markdown

@scunningham scunningham left a comment

Choose a reason for hiding this comment

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

ok

@aleksmaus aleksmaus merged commit e3adb91 into elastic:master Aug 31, 2021
mergify bot pushed a commit that referenced this pull request Aug 31, 2021
aleksmaus added a commit that referenced this pull request Aug 31, 2021
…7666)

(cherry picked from commit e3adb91)

Co-authored-by: Aleksandr Maus <aleksandr.maus@elastic.co>
mdelapenya added a commit to mdelapenya/beats that referenced this pull request Sep 1, 2021
* master:
  Forward port 7.14.1 changelog to master  (elastic#27687)
  Addressing multiple dashboard issues: deps loading once, field conversion, etc. (elastic#27669)
  Remove adaptive queue sizes from agent's spec files (elastic#27653)
  Osquerybeat: Improve testability and unit test coverage (elastic#27591)
  Osquerybeat: lockdown flagsfile, prevent global defaults (elastic#27611)
  Import the references of dashboard assets using the Saved Objects API (elastic#27647)
  Fix bug with override path in cgroups (elastic#27620)
  Allow Kibana client to authorize with Elasticsearch API key (elastic#27540)
  Filebeat auditd: Fix Top Exec Commands dashboard visualization (elastic#27638)
  [elastic-agent] Fix docker tar.gz generation for complete image (elastic#27621)
  Follow up changes in dashboards in mage check && fix minor issue (elastic#27553)
  [Heartbeat] Fix bug where `enabled: false` is ignored. (elastic#27615)
  Support kube_state_metrics v2.0.0 (elastic#27552)
Icedroid pushed a commit to Icedroid/beats that referenced this pull request Nov 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants