Skip to content

[Osquery] Add osquery response action privilege checks to external Api#260947

Draft
tomsonpl wants to merge 5 commits intoelastic:mainfrom
tomsonpl:fix-osquery-response-action
Draft

[Osquery] Add osquery response action privilege checks to external Api#260947
tomsonpl wants to merge 5 commits intoelastic:mainfrom
tomsonpl:fix-osquery-response-action

Conversation

@tomsonpl
Copy link
Copy Markdown
Contributor

@tomsonpl tomsonpl commented Apr 2, 2026

No description provided.

@tomsonpl tomsonpl self-assigned this Apr 2, 2026
@elasticmachine
Copy link
Copy Markdown
Contributor

🤖 Jobs for this PR can be triggered through checkboxes. 🚧

ℹ️ To trigger the CI, please tick the checkbox below 👇

  • Click to trigger kibana-pull-request for this PR!
  • Click to trigger kibana-deploy-project-from-pr for this PR!
  • Click to trigger kibana-deploy-cloud-from-pr for this PR!
  • Click to trigger kibana-entity-store-performance-from-pr for this PR!
  • Click to trigger kibana-storybooks-from-pr for this PR!

@tomsonpl
Copy link
Copy Markdown
Contributor Author

tomsonpl commented Apr 2, 2026

/ci

@elasticmachine
Copy link
Copy Markdown
Contributor

elasticmachine commented Apr 2, 2026

⏳ Build in-progress, with failures

Failed CI Steps

History

cc @tomsonpl


getEndpointService: () => endpointAppContextService,

getCheckOsqueryResponseActionAuthz: () => (params) =>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 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)) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 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`)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants