-
Notifications
You must be signed in to change notification settings - Fork 117
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
Audit / Removal / Auth check of all dataSource related endpoint #9750
Conversation
PMRR (since it's all removing or making stricter so safe inherently) |
@devloai review this PR |
I encountered an error while processing the request. Please try again or contact support if the issue persists. |
1 similar comment
I encountered an error while processing the request. Please try again or contact support if the issue persists. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've reviewed the PR and the security audit looks thorough. The removal of unused endpoints reduces attack surface, and the addition of permission checks improves security. Two suggestions to further enhance security:
- Consider adding GET method permission checks in the tables endpoint for consistent auth across all operations
- For the connector endpoint, consider filtering sensitive configuration data for non-admin users
Overall, good work on improving the authorization model and cleaning up unused endpoints.
@@ -123,6 +123,16 @@ async function handler( | |||
return; | |||
|
|||
case "DELETE": | |||
if (!dataSource.canWrite(auth)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good addition of the canWrite
permission check. However, consider also adding a similar check for the GET method to ensure consistent permission enforcement across all operations.
@@ -29,8 +29,11 @@ async function handler( | |||
}); | |||
} | |||
|
|||
// This endpoint can be access by non admin to get the connector chip status. Ensure that no |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment about non-admin access is good, but consider adding a more explicit check to ensure no sensitive configuration data is returned in the response. You may want to filter the response object to only include connection state related fields.
@@ -75,6 +64,17 @@ async function handler( | |||
}); | |||
} | |||
|
|||
if (!dataSource.canAdministrate(auth) || !auth.isAdmin()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good addition of canAdministrate
check, but consider moving the auth check before fetching workspace and user data for better efficiency. This would prevent unnecessary database queries for unauthorized users.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for auth.isAdmin
here.
const dataSource = await DataSourceResource.fetchById(auth, dsId); | ||
if (!dataSource) { | ||
if (!dataSource || !auth.isUser()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The auth.isUser()
isn't required it's already covered by the withSessionAuthenticationForWorkspace
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have decided to lean in duplicating security mitigations. Rationale is that every system can fail and we should accept duplication for authentication (which saved us from catastrophic situations in the recent past already)
@@ -115,13 +115,14 @@ async function handler( | |||
return; | |||
|
|||
case "POST": | |||
if (!auth.isAdmin()) { | |||
if (!auth.isAdmin() || !dataSource.canAdministrate(auth)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can remove the auth.isAdmin
here as well since it's covered by dataSource.canAdministrate
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The two are slighly different. One tests the role directly the other tests the capability
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The role is used in auth
has well, see here:
Line 798 in 7104095
if (hasRolePermissions(resourcePermission)) { |
@@ -75,6 +64,17 @@ async function handler( | |||
}); | |||
} | |||
|
|||
if (!dataSource.canAdministrate(auth) || !auth.isAdmin()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for auth.isAdmin
here.
@@ -30,6 +30,16 @@ async function handler( | |||
) { | |||
const user = auth.getNonNullableUser(); | |||
|
|||
if (!auth.isUser()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not needed, this is covered by withSessionAuthenticationForWorkspace
.
Description
Post Spaces work, we left unused endpoints behind. Goal of this PR to remove all unused legacy data sources endpoint, audit the ones that are still in use and audit the permissioning of all legacy and new endpoints.
Full audit log here explaining the PR:
Risk
Low. All tested locally.
Deploy Plan
front