macOS apps last_opened_time reports all versions/installed paths as having been opened when only one has
メンテナーはふだん 3 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 42/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 停滞
- 技術スタック
- cpp, macos
調査の方向性
まず、macOS のアプリテーブルの実装と、kMDItemLastUsedDate に対する Spotlight クエリを追跡します。2 つの bundle パスで問題を再現し、アプリを 1 つ開く前後でそれぞれの last_opened_time 値を比較します。開いた bundle のパスだけがタイムスタンプを受け取り、もう一方が -1 のままであれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Bug report
What operating system and version are you using?
+---------+-------+----------+
| version | build | platform |
+---------+-------+----------+
| 15.6 | 24G84 | darwin |
+---------+-------+----------+
What version of osquery are you using?
+---------+
| version |
+---------+
| 5.18.1 |
+---------+
What steps did you take to reproduce the issue?
- Install two different versions of an app in two different paths on the host. For example, I installed:
Firefox.app version 142.0 to/Applications/Firefox.app
Firefox.app version 129.0 to/Users/admin/Desktop/Firefox.app - Run
SELECT * FROM apps WHERE bundle_identifier='org.mozilla.firefox'and see that both apps are returned as distinct results with different versions and different paths. Both havelast_opened_time setto-1since neither has been opened yet. - Open ONLY ONE of the installed apps on the host. Then close the app. Do not open the other app.
- Run
SELECT * FROM apps WHERE bundle_identifier='org.mozilla.firefox'
What did you expect to see?
I expected to see the last_opened_time to show a new value for the app that I opened, but not the other, as only one of the app versions at one of the paths was opened.
What did you see instead?
Both apps have been updated with a last_opened_at timestamp. They are not the exact same timestamp, they differ slightly.
Output of commands before and after opening only the app located in /Users/admin/Desktop/Firefox.app
osquery> SELECT * from apps where bundle_identifier='org.mozilla.firefox';
+-------------+----------------------------------+-------------------+---------------------+-------------+----------------------+----------------+---------------------+-------------+---------+----------+--------------------+--------------+---------------+------------------------+----------------------------------+---------------------+-----------+------------------+
| name | path | bundle_executable | bundle_identifier | bundle_name | bundle_short_version | bundle_version | bundle_package_type | environment | element | compiler | development_region | display_name | info_string | minimum_system_version | category | applescript_enabled | copyright | last_opened_time |
+-------------+----------------------------------+-------------------+---------------------+-------------+----------------------+----------------+---------------------+-------------+---------+----------+--------------------+--------------+---------------+------------------------+----------------------------------+---------------------+-----------+------------------+
| Firefox.app | /Applications/Firefox.app | firefox | org.mozilla.firefox | Firefox | 142.0 | 14225.8.11 | APPL | | | | English | | Firefox 142.0 | 10.15.0 | public.app-category.productivity | 1 | | -1.0 |
| Firefox.app | /Users/admin/Desktop/Firefox.app | firefox | org.mozilla.firefox | Firefox | 129.0 | 12924.8.1 | APPL | | | | English | | Firefox 129.0 | 10.15.0 | public.app-category.productivity | 1 | | -1.0 |
+-------------+----------------------------------+-------------------+---------------------+-------------+----------------------+----------------+---------------------+-------------+---------+----------+--------------------+--------------+---------------+------------------------+----------------------------------+---------------------+-----------+------------------+
osquery> SELECT * from apps where bundle_identifier='org.mozilla.firefox';
+-------------+----------------------------------+-------------------+---------------------+-------------+----------------------+----------------+---------------------+-------------+---------+----------+--------------------+--------------+---------------+------------------------+----------------------------------+---------------------+-----------+------------------+
| name | path | bundle_executable | bundle_identifier | bundle_name | bundle_short_version | bundle_version | bundle_package_type | environment | element | compiler | development_region | display_name | info_string | minimum_system_version | category | applescript_enabled | copyright | last_opened_time |
+-------------+----------------------------------+-------------------+---------------------+-------------+----------------------+----------------+---------------------+-------------+---------+----------+--------------------+--------------+---------------+------------------------+----------------------------------+---------------------+-----------+------------------+
| Firefox.app | /Applications/Firefox.app | firefox | org.mozilla.firefox | Firefox | 142.0 | 14225.8.11 | APPL | | | | English | | Firefox 142.0 | 10.15.0 | public.app-category.productivity | 1 | | 1756230542.73983 |
| Firefox.app | /Users/admin/Desktop/Firefox.app | firefox | org.mozilla.firefox | Firefox | 129.0 | 12924.8.1 | APPL | | | | English | | Firefox 129.0 | 10.15.0 | public.app-category.productivity | 1 | | 1756230539.79383 |
+-------------+----------------------------------+-------------------+---------------------+-------------+----------------------+----------------+---------------------+-------------+---------+----------+--------------------+--------------+---------------+------------------------+----------------------------------+---------------------+-----------+------------------+
Per https://github.com/osquery/osquery/issues/4470 it sounds like osquery is using spotlight to gather this information. It also states
this metadata item is only valid for this specific application bundle. If the application is replaced/updated, Spotlight considers it a "new" app (which it technically is), for which the kMDItemLastUsedDate is no longer defined.
which is particularly problematic when incorporating osquery into other applications (Such as Fleet) because:
- Any time an app is updated, the last_opened_time is cleared out, which signals the app has never been opened. If an admin is looking to revoke unused software and sees that an app has never been opened, when in fact, only the most recently updated version has not yet been opened, they may erroneously assume they can revoke that software without adverse effect.
- If software with the same application bundle exists across multiple versions/install paths for an application, it becomes impossible to differentiate between which version of the software is currently being used because all versions/paths are updated with a last_opened_time even when they weren't opened. This results in the misconception that older, potentially vulnerable versions of an application are being used/opened, even if they are not.
- 主要言語
- C++
- スター
- 23.8k
- フォーク
- 2.7k
- 平均マージ
- 6日 11時間
- マージ済み PR(30日)
- 69
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
osquery/osquery のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
メンテナーはふだん 3 日以内に返信
-
usb_devices: usb_address and usb_port are wrong for bus/device numbers 8–99 on Linux (zero-padded udev values parsed as octal)対応中かも @mjatin2007 が 6 日前に担当しました。 オープンLinux virtual tables
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 3 日以内に返信
-
Update the expired Slack invite link in README再び着手できるかも @ayushkrsingh946 が 39 日前に担当しましたが、オープン中のプルリクエストはありません。 オープンmaintainer task
難易度 1/5 1時間未満 初心者へのやさしさ 68/100
osquery/osquery#9215 · コメント 4 件 ·
メンテナーはふだん 3 日以内に返信
-
fix(docs): debugging guide incorrectly says invalid configuration blocks daemon startup対応中かも @nightcityblade が 54 日前に担当しました。 オープンconfiguration documentation
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
osquery/osquery#9143 · コメント 1 件 ·
メンテナーはふだん 3 日以内に返信
-
scheduled_tasks.hidden returns the task's Enabled state instead of Hidden (Windows)対応中かも @a-bonfim-tech が 67 日前に担当しました。 オープンbug triage virtual tables Windows
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
メンテナーはふだん 3 日以内に返信
osquery/osquery の issue をすべて見る
似ている issue
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
[Bug]: pip install -U cudaq-qec fails with a conflict that names cudaq-qec itself対応中かも @fedonman が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
task
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
SparseLinearAlgebra/spla#316 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 83/100
メンテナーはふだん 1 日以内に返信