Skip to content

fix-18269 Users without access are able perform bulk Add/Remove team Assets using API#20150

Closed
sonika-shah wants to merge 3 commits intomainfrom
fix-18269
Closed

fix-18269 Users without access are able perform bulk Add/Remove team Assets using API#20150
sonika-shah wants to merge 3 commits intomainfrom
fix-18269

Conversation

@sonika-shah
Copy link
Copy Markdown
Collaborator

@sonika-shah sonika-shah commented Mar 8, 2025

Describe your changes:

Fixes #18269
image

Type of change:

  • Bug fix
  • Improvement
  • New feature
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation

Checklist:

  • I have read the CONTRIBUTING document.
  • My PR title is Fixes <issue-number>: <short explanation>
  • I have commented on my code, particularly in hard-to-understand areas.
  • For JSON Schema changes: I updated the migration scripts or explained why it is not needed.

@sonika-shah sonika-shah added backend safe to test Add this label to run secure Github workflows on PRs labels Mar 8, 2025
@sonika-shah sonika-shah requested a review from a team as a code owner March 8, 2025 05:39
@sonika-shah sonika-shah changed the title fix-18269 Users without access are able perform bulk Add/Remove Asset… fix-18269 Users without access are able perform bulk Add/Remove team Assets using API Mar 8, 2025
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 8, 2025

🛡️ TRIVY SCAN RESULT 🛡️

Target: openmetadata-server:trivy (alpine 3.21.3)

No Vulnerabilities Found

🛡️ TRIVY SCAN RESULT 🛡️

Target: Java

No Vulnerabilities Found

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Mar 8, 2025

return importCsvInternalAsync(securityContext, name, csv, dryRun);
}

public final void verifyUserPermission(SecurityContext securityContext) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

hi @sonika-shah can we add it as a different operation itself ADD_ASSETS?
this seems like to much to handle single permission of Adding assets!

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

don't want to build if else, we have flexible roles and policies which can be used to associate operation to different resource

Copy link
Copy Markdown
Collaborator Author

@sonika-shah sonika-shah Mar 12, 2025

Choose a reason for hiding this comment

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

hi @mohityadav766 , will check
with the current implementations, when we add multiple operations to the operation_context, it treats them as an AND condition—all permissions must be present to authorize.

that’s why I implemented it with if else so that if any of the listed operations is present, the user is authorized.

Copy link
Copy Markdown
Member

@mohityadav766 mohityadav766 left a comment

Choose a reason for hiding this comment

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

needs some work

@harshach harshach removed the backend label May 24, 2025
@ayush-shah ayush-shah requested a review from Copilot August 12, 2025 05:23
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This pull request addresses a security vulnerability where users without proper access permissions could perform bulk add/remove operations on team assets through the API. The fix introduces permission verification to ensure only authorized users can perform these operations.

  • Adds permission verification for bulk add/remove team asset operations
  • Implements a new verifyUserPermission method to check user authorization
  • Ensures only users with appropriate metadata operations permissions can access these endpoints

return importCsvInternalAsync(securityContext, name, csv, dryRun);
}

public final void verifyUserPermission(SecurityContext securityContext) {
Copy link

Copilot AI Aug 12, 2025

Choose a reason for hiding this comment

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

The method should be private instead of public since it's only used internally within this class and doesn't need to be exposed as part of the public API.

Suggested change
public final void verifyUserPermission(SecurityContext securityContext) {
private final void verifyUserPermission(SecurityContext securityContext) {

Copilot uses AI. Check for mistakes.
perm.getOperation())
|| MetadataOperation.EDIT_OWNERS.equals(
perm.getOperation()))
&& Permission.Access.ALLOW.equals(perm.getAccess())));
Copy link

Copilot AI Aug 12, 2025

Choose a reason for hiding this comment

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

The permission check retrieves all permissions for the user and then filters them. This could be inefficient for users with many permissions. Consider using a more targeted permission check if the authorizer supports it.

Suggested change
&& Permission.Access.ALLOW.equals(perm.getAccess())));
// Check for required permissions using targeted authorizer checks
boolean hasPermission =
authorizer.hasPermission(securityContext, user, Entity.ALL_RESOURCES, MetadataOperation.ALL) ||
authorizer.hasPermission(securityContext, user, Entity.ALL_RESOURCES, MetadataOperation.EDIT_ALL) ||
authorizer.hasPermission(securityContext, user, Entity.TEAM, MetadataOperation.ALL) ||
authorizer.hasPermission(securityContext, user, Entity.TEAM, MetadataOperation.EDIT_ALL) ||
authorizer.hasPermission(securityContext, user, Entity.TEAM, MetadataOperation.EDIT_TEAMS) ||
authorizer.hasPermission(securityContext, user, Entity.TEAM, MetadataOperation.EDIT_OWNERS) ||
authorizer.hasPermission(securityContext, user, Entity.USER, MetadataOperation.ALL) ||
authorizer.hasPermission(securityContext, user, Entity.USER, MetadataOperation.EDIT_ALL) ||
authorizer.hasPermission(securityContext, user, Entity.USER, MetadataOperation.EDIT_TEAMS) ||
authorizer.hasPermission(securityContext, user, Entity.USER, MetadataOperation.EDIT_OWNERS);

Copilot uses AI. Check for mistakes.

boolean isAdminOrBot = subjectContext.isAdmin() || subjectContext.isBot();

if (!hasPermission && !isAdminOrBot) {
Copy link

Copilot AI Aug 12, 2025

Choose a reason for hiding this comment

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

The admin/bot check should be performed before the expensive permission lookup to short-circuit the authorization check for privileged users and improve performance.

Suggested change
if (!hasPermission && !isAdminOrBot) {
if (!hasPermission) {

Copilot uses AI. Check for mistakes.
String csv) {
return importCsvInternalAsync(securityContext, name, csv, dryRun);
}

Copy link

Copilot AI Aug 12, 2025

Choose a reason for hiding this comment

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

The method lacks JavaDoc documentation explaining its purpose, parameters, and the conditions under which it throws an AuthorizationException.

Suggested change
/**
* Verifies that the user associated with the provided {@link SecurityContext} has permission to perform
* operations on Team and User entities. The user must have one of the required metadata operations
* (ALL, EDIT_ALL, EDIT_TEAMS, EDIT_OWNERS) on the resources (USER, TEAM), or be an admin or bot.
*
* @param securityContext the security context containing user authentication information
* @throws AuthorizationException if the user does not have the required permissions
*/

Copilot uses AI. Check for mistakes.
@harshach harshach removed this from August - 2025 Oct 1, 2025
@harshach harshach moved this to Platform in November - 2025 Oct 1, 2025
@TeddyCr TeddyCr removed the status in November - 2025 Oct 8, 2025
@github-project-automation github-project-automation bot moved this to In Review / QA 👀 in Jan - 2026 Dec 10, 2025
@harshach harshach removed this from Jan - 2026 Jan 6, 2026
@sonika-shah
Copy link
Copy Markdown
Collaborator Author

this is already fixed with pr : Missing Permission on Adding Users to team (#20768)

@sonika-shah sonika-shah closed this Jan 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

safe to test Add this label to run secure Github workflows on PRs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Users without access are able perform bulk Add/Remove Assets using API

6 participants