Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show an error message if permission names are not unique #17385

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

gvkries
Copy link
Contributor

@gvkries gvkries commented Jan 21, 2025

Currently, permission names are expected to be unique across all modules. This change displays an error message in the Role Editor when a permission name is reused. This alerts the administrator to possible security issues when a module redefines an existing permission.

Fixes #8469

@MikeAlhayek
Copy link
Member

@gvkries I don't think throwing an exception is the right approach here. Instead, I would recommend logging a warning and proceeding.

Imagine a scenario where a developer creates a module that exposes a permission named X. Later, in OC, we decide to also expose a permission named X. This would result in a naming conflict that breaks an application that was functioning perfectly fine before.

Since permissions are string-based, such naming conflicts are acceptable to some extent, but they should still trigger a warning to notify developers. However, I don’t think it’s appropriate to throw an exception that would stop the application from running entirely.

@gvkries
Copy link
Contributor Author

gvkries commented Jan 21, 2025

I understand the concern about breaking existing applications, but the security implications of reusing permission names are significant:

  1. Security Risk: Reusing permission names can lead to unauthorized access if existing roles already grant the reused permission. This creates a serious vulnerability.

  2. High Impact: The potential consequences of such conflicts are severe. Logging a warning might not be enough, as it could be overlooked, allowing the issue to persist.

  3. Immediate Action: Throwing an exception ensures the problem is addressed immediately, aligning with the fail-fast principle to catch and fix errors early.

While the current solution only causes the admin portal to fail, it highlights the issue and prompts immediate action. Given the high stakes, enforcing an exception is necessary to maintain application security.

@MikeAlhayek
Copy link
Member

I understand the concert. This is something I also mentioned few weeks back in the meeting. But I don't think its a justification for throwing a runtime exception. I think logging it as a warning is enough unless we need to try to use namespace to ensure uniqueness which is also bad since it would increase the cookie size.

@gvkries
Copy link
Contributor Author

gvkries commented Jan 22, 2025

Okay, instead of throwing an exception, I'm content to show an error in the admin portal. I think that the mere logging has too little visibility.

I also admit that the previous solution was not sufficient because throwing an exception in the DefaultPermissionsService and admin portal is not reliable enough. For the same reason, I think that logging there is not good enough as well and I have therefore refrained from doing so for the time being.

@gvkries gvkries changed the title Throw an exception if the permission names are not unique Show an error message if permission names are not unique Jan 22, 2025
@gvkries gvkries requested a review from MikeAlhayek January 22, 2025 10:30
@gvkries
Copy link
Contributor Author

gvkries commented Jan 22, 2025

Note: Changing the permission names to include the module name or namespace is not an easy solution. This would be a massive breaking change IMHO.

@MikeAlhayek
Copy link
Member

Note: Changing the permission names to include the module name or namespace is not an easy solution. This would be a massive breaking change IMHO.

Yes I agree. I am not suggesting that either. I think we should log warning and not throw an exception.

@gvkries
Copy link
Contributor Author

gvkries commented Jan 22, 2025

@MikeAlhayek Maybe we can briefly talk about this tomorrow.

@MikeAlhayek
Copy link
Member

Absolutely

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.

Roles with the variable name across modules conflict with each other
2 participants