[Osquery] Add osquery response action privilege checks to external Api#260947
[Osquery] Add osquery response action privilege checks to external Api#260947tomsonpl wants to merge 5 commits intoelastic:mainfrom
Conversation
|
🤖 Jobs for this PR can be triggered through checkboxes. 🚧
ℹ️ To trigger the CI, please tick the checkbox below 👇
|
|
/ci |
⏳ Build in-progress, with failures
Failed CI StepsHistorycc @tomsonpl |
|
|
||
| getEndpointService: () => endpointAppContextService, | ||
|
|
||
| getCheckOsqueryResponseActionAuthz: () => (params) => |
There was a problem hiding this comment.
🟡 Medium server/request_context_factory.ts:194
The new getCheckOsqueryResponseActionAuthz method accesses plugins.osquery.checkResponseActionAuthz without null-checking plugins.osquery. If the osquery plugin is optional and not installed, invoking this method throws TypeError: Cannot read property 'checkResponseActionAuthz' of undefined at runtime. Consider adding optional chaining: plugins.osquery?.checkResponseActionAuthz.
🤖 Copy this AI Prompt to have your agent fix this:
In file x-pack/solutions/security/plugins/security_solution/server/request_context_factory.ts around line 194:
The new `getCheckOsqueryResponseActionAuthz` method accesses `plugins.osquery.checkResponseActionAuthz` without null-checking `plugins.osquery`. If the osquery plugin is optional and not installed, invoking this method throws `TypeError: Cannot read property 'checkResponseActionAuthz' of undefined` at runtime. Consider adding optional chaining: `plugins.osquery?.checkResponseActionAuthz`.
Evidence trail:
- x-pack/solutions/security/plugins/security_solution/server/request_context_factory.ts lines 194-195 (REVIEWED_COMMIT): new code `getCheckOsqueryResponseActionAuthz: () => (params) => plugins.osquery.checkResponseActionAuthz(request, params)`
- x-pack/solutions/security/plugins/security_solution/server/plugin_contract.ts line 79: `osquery: OsqueryPluginSetup;` (non-optional type declaration)
- x-pack/solutions/security/plugins/security_solution/kibana.jsonc lines 81-95: `osquery` listed in `optionalPlugins` array
| } | ||
| break; | ||
| } | ||
| } else if (isOsqueryResponseAction(actionData)) { |
There was a problem hiding this comment.
🟡 Medium utils/rule_response_actions_validators.ts:175
When isOsqueryResponseAction matches a RuleResponseOsqueryAction from an existing rule, the authorization check at line 178-181 only looks for snake_case keys (saved_query_id, pack_id) in params, but RuleResponseOsqueryAction uses camelCase (savedQueryId, packId). This causes the check to always pass undefined for both fields, bypassing authorization validation for osquery actions with camelCase params.
🤖 Copy this AI Prompt to have your agent fix this:
In file x-pack/solutions/security/plugins/security_solution/server/endpoint/services/actions/utils/rule_response_actions_validators.ts around line 175:
When `isOsqueryResponseAction` matches a `RuleResponseOsqueryAction` from an existing rule, the authorization check at line 178-181 only looks for snake_case keys (`saved_query_id`, `pack_id`) in `params`, but `RuleResponseOsqueryAction` uses camelCase (`savedQueryId`, `packId`). This causes the check to always pass `undefined` for both fields, bypassing authorization validation for osquery actions with camelCase params.
Evidence trail:
1. x-pack/solutions/security/plugins/security_solution/server/endpoint/services/actions/utils/rule_response_actions_validators.ts lines 175-181 - authorization check only uses snake_case keys
2. x-pack/solutions/security/plugins/security_solution/server/endpoint/services/actions/utils/rule_response_actions_validators.ts lines 315-323 - `isOsqueryResponseAction` matches both `OsqueryResponseAction` and `RuleResponseOsqueryAction`
3. x-pack/solutions/security/plugins/security_solution/common/api/detection_engine/model/rule_response_actions/response_actions.gen.ts lines 78-84 - `OsqueryParamsCamelCase` uses camelCase keys (`savedQueryId`, `packId`)
4. x-pack/solutions/security/plugins/security_solution/common/api/detection_engine/model/rule_response_actions/response_actions.gen.ts lines 93-96 - `RuleResponseOsqueryAction` uses `params: OsqueryParamsCamelCase`
5. x-pack/solutions/security/plugins/security_solution/server/lib/detection_engine/rule_response_actions/osquery_response_action.test.ts lines 51-56 and 71-76 - test confirms `RuleResponseOsqueryAction` uses camelCase (`packId`, `savedQueryId`)
No description provided.