Skip to content

Add indices:admin/mappings/get to ml_full_access role for Agentic Search - #6076

Draft
owaiskazi19 wants to merge 4 commits into
opensearch-project:mainfrom
owaiskazi19:fix/ml-full-access-mappings-get
Draft

owaiskazi19 wants to merge 4 commits into
opensearch-project:mainfrom
owaiskazi19:fix/ml-full-access-mappings-get

Conversation

@owaiskazi19

Copy link
Copy Markdown
Member

Description

Adds indices:admin/mappings/get to the ml_full_access role to support Agentic Search (QueryPlanningTool). QPT needs to retrieve index mappings to generate accurate OpenSearch DSL queries from natural language input.

Dependency

This PR depends on opensearch-project/ml-commons#4785, which changes QueryPlanningTool to use GetMappingsRequest instead of GetIndexRequest. Without that ml-commons change, QPT would require the broader indices:admin/get permission. With it, only indices:admin/mappings/get is needed.

Security implications

This permission does not expose system index mappings. System indices are protected by multiple layers:

  1. System index permission layer — When plugins.security.system_indices.permissions.enabled is true (default), accessing system indices requires the system:admin/system_index permission, which ml_full_access does not have.
  2. Security config index protection — The .opendistro_security index has additional hardcoded protection that filters it from wildcard requests when plugins.security.filter_securityindex_from_all_requests is enabled.
  3. Scoped access — QPT calls getMappings with a specific user-provided index name, not *.

This is a read-only metadata permission — it only exposes field names and types, not document data.

Consistent with existing roles — indices:admin/mappings/get is already used by knn_full_access, query_assistant_access, and reports_read_access with the same index_patterns: ['*'] scope.

Related Issue

opensearch-project/ml-commons#4775

Check List

  • New functionality includes testing
    • N/A (config-only change to a predefined role)
  • New functionality has been documented
    • N/A
  • Commits are signed off as per the DCO using --signoff

@cwperks

cwperks commented Apr 7, 2026

Copy link
Copy Markdown
Member

TY @owaiskazi19 . The changes LGTM but the build on main is broken atm due to Jackson 3.x upgrade in core. I will have a PR raised mometarily for that.

@cwperks

cwperks commented Apr 7, 2026

Copy link
Copy Markdown
Member

@owaiskazi19 it may be good to take this opportunity to extract the ml roles from this repo and provide them as classpath resources from within the ml repo instead. See #6038

Comment thread config/roles.yml
- index_patterns:
- '*'
allowed_actions:
- 'indices:admin/mappings/get'

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.

we also need indices:data/read/search* because agentic search also samples documents from the index, should we add that too?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Good call. QPT's async chain has two steps: (1) getMappings for index structure, and (2) a search to sample a document. indices:data/read/search* would be needed for it

QueryPlanningTool samples documents from the target index using a
matchAllQuery search. This requires indices:data/read/search* permission
which is consistent with other full_access roles (anomaly_full_access,
ppl_full_access, asynchronous_search_full_access, forecast_full_access).

Signed-off-by: Owais Kazi <[email protected]>
@owaiskazi19
owaiskazi19 force-pushed the fix/ml-full-access-mappings-get branch from 4eae239 to 75b48d7 Compare April 10, 2026 18:22
@github-actions

Copy link
Copy Markdown
Contributor

PR Code Analyzer ❗

AI-powered 'Code-Diff-Analyzer' found issues on commit 4f980b7.

⛔ Hard block: Issues at High severity or above will block this PR from merging.

PathLineSeverityDescription
config/roles.yml335mediumThe ml_full_access role is granted 'indices:data/read/search*' against the wildcard index pattern '*', giving broad search access across ALL indices in the cluster. Combined with 'indices:admin/mappings/get', a compromised ML account could enumerate schema and exfiltrate data from any index, including sensitive ones unrelated to ML workloads. Verify whether ML functionality genuinely requires cluster-wide search rather than access scoped to specific ML-related index patterns.

The table above displays the top 10 most important findings.

Total: 1 | Critical: 0 | High: 0 | Medium: 1 | Low: 0


Pull Requests Author(s): Please update your Pull Request according to the report above.

Repository Maintainer(s): You can bypass diff analyzer by adding label skip-diff-analyzer after reviewing the changes carefully, then re-run failed actions. To re-enable the analyzer, remove the label, then re-run all actions.


⚠️ Note: The Code-Diff-Analyzer helps protect against potentially harmful code patterns. Please ensure you have thoroughly reviewed the changes beforehand.

Thanks.

@github-actions

Copy link
Copy Markdown
Contributor

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

🧪 No relevant tests
🔒 Security concerns

Expanded permissions:
The diff grants indices:data/read/search* on * to ml_full_access, which allows searching document data across all non-system indices. This is broader than the mappings-only permission described in the PR and should be verified as intentional, since it exposes document contents (subject to system index protections) rather than just field metadata.

✅ No TODO sections
🔀 No multiple PR themes
⚡ Recommended focus areas for review

Expanded Permission Scope

This PR adds two permissions rather than one as described. In addition to indices:admin/mappings/get, the change also grants indices:data/read/search* to ml_full_access with index_patterns: ['*']. The PR description and title only mention the mappings permission. Granting broad search access across all indices to ml_full_access is a materially different security change than adding read-only metadata access, and it is not justified in the description. Confirm whether the search permission is intentional; if so, the description and security-implications section should be updated to cover it, otherwise it should be removed.

- 'indices:admin/mappings/get'
- 'indices:data/read/search*'

@DarshitChanpura

Copy link
Copy Markdown
Member

@owaiskazi19 Is this PR ready for review? If not, this will be marked as stale and closed during next cleanup.

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.

4 participants