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

[Fix-12916] Add permission check when query or download log #12917

Merged
merged 1 commit into from
Nov 25, 2022

Conversation

rickchengx
Copy link
Contributor

@rickchengx rickchengx commented Nov 16, 2022

Purpose of the pull request

Currently, there is no permission check when user query or download log by task instance id.

截屏2022-11-16 09 55 30

Brief change log

Add permission check when query or download log

Who can query or download log ?

All users who have the permission of the project to which the task instance belongs can query or download the log.

  1. Query the project to which the task instance belongs from the database.

  2. Check the permission of project by projectService.checkProjectAndAuth()

Verify this pull request

covered by UT and manually tested as below

Note that the task instance id 1 is not created by current login user.

截屏2022-11-16 14 11 12

截屏2022-11-16 14 10 21

@codecov-commenter
Copy link

codecov-commenter commented Nov 16, 2022

Codecov Report

Merging #12917 (54014d2) into dev (38b8767) will increase coverage by 0.01%.
The diff coverage is 62.50%.

@@             Coverage Diff              @@
##                dev   #12917      +/-   ##
============================================
+ Coverage     39.35%   39.36%   +0.01%     
  Complexity     4271     4271              
============================================
  Files          1067     1067              
  Lines         40121    40125       +4     
  Branches       4601     4605       +4     
============================================
+ Hits          15791    15797       +6     
  Misses        22551    22551              
+ Partials       1779     1777       -2     
Impacted Files Coverage Δ
...phinscheduler/api/controller/LoggerController.java 6.66% <0.00%> (ø)
...r/api/service/impl/ProcessInstanceServiceImpl.java 70.37% <50.00%> (ø)
...nscheduler/api/service/impl/LoggerServiceImpl.java 72.30% <100.00%> (+1.81%) ⬆️
...e/dolphinscheduler/remote/NettyRemotingClient.java 52.77% <0.00%> (+0.69%) ⬆️
...er/master/dispatch/host/assign/RandomSelector.java 83.33% <0.00%> (+5.55%) ⬆️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Copy link
Member

@SbloodyS SbloodyS left a comment

Choose a reason for hiding this comment

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

I dont't think it's a bug. It need to be disscussed. cc @ruanwenjun @caishunfeng @EricGao888 @zhongjiajie

@rickchengx
Copy link
Contributor Author

rickchengx commented Nov 17, 2022

I dont't think it's a bug. It need to be disscussed. cc @ruanwenjun @caishunfeng @EricGao888 @zhongjiajie

Hi, @SbloodyS , thanks for your comment.

Here is an example to illustrate why I think this is a bug:

  • User 1 has a project project-1, and an task-instance-1 (suppose taskInstanceId=1)
  • User 2 has no permission on project-1 , and he cannot see the project-1 and the task-instance-1 on the UI. But he can easily query the log of task-instance-1 by sending a GET http /dolphinscheduler/log/detail?taskInstanceId=1&skipLineNum=0&limit=1000. He only needs to set an taskInstanceId, which is not randomly generated.

In more serious cases, the logs may contain sensitive information

@EricGao888 EricGao888 added the discussion discussion label Nov 19, 2022
@Radeity
Copy link
Member

Radeity commented Nov 20, 2022

I dont't think it's a bug. It need to be disscussed. cc @ruanwenjun @caishunfeng @EricGao888 @zhongjiajie

I agree with @rickchengx, users may make bad log decisions which will lead to security issue, so there's a strong need to for this permission check. In addition, i suggest to add request to apply for temporary permission to query and download logs for users who don't have permission, and this application can be approved by administrator.

@rickchengx
Copy link
Contributor Author

rickchengx commented Nov 21, 2022

I dont't think it's a bug. It need to be disscussed. cc @ruanwenjun @caishunfeng @EricGao888 @zhongjiajie

I agree with @rickchengx, users may make bad log decisions which will lead to security issue, so there's a strong need to for this permission check. In addition, i suggest to add request to apply for temporary permission to query and download logs for users who don't have permission, and this application can be approved by administrator.

Hi, @Radeity Thanks for your comment.

I agree that permission check is required when user query or download task logs.

Can admin authorize the log permission to the user in this PR?

Currently, admin can authorize users for the following resources: (E.g., project / resource / ....)

截屏2022-11-21 10 08 43

And in the design of this PR:
Only users with project permissions to which the task instance belongs can query or download the logs of that task instance.

Because I think the log of the task can be viewed only if the user can view the task.

So in this PR, admin can authorize the log permission to the user by authorize users for the project resource.

As for what you said, whether the administrator can individually add the log permission of a certain task instance to the user, I think it can be discussed and done after solving this security problem.

WDYT

cc @SbloodyS @EricGao888 @ruanwenjun @caishunfeng @zhongjiajie

@zhongjiajie
Copy link
Member

I dont't think it's a bug. It need to be disscussed. cc @ruanwenjun @caishunfeng @EricGao888 @zhongjiajie

I agree with @rickchengx, users may make bad log decisions which will lead to security issue, so there's a strong need to for this permission check. In addition, i suggest to add request to apply for temporary permission to query and download logs for users who don't have permission, and this application can be approved by administrator.

Hi, @Radeity Thanks for your comment.

I agree that permission check is required when user query or download task logs.

Can admin authorize the log permission to the user in this PR?

Currently, admin can authorize users for the following resources: (E.g., project / resource / ....)

截屏2022-11-21 10 08 43

And in the design of this PR: Only users with project permissions to which the task instance belongs can query or download the logs of that task instance.

Because I think the log of the task can be viewed only if the user can view the task.

So in this PR, admin can authorize the log permission to the user by authorize users for the project resource.

As for what you said, whether the administrator can individually add the log permission of a certain task instance to the user, I think it can be discussed and done after solving this security problem.

WDYT

cc @SbloodyS @EricGao888 @ruanwenjun @caishunfeng @zhongjiajie

I think we keep permission within the project level is acceptable. we already supported it and it is simple enough

Copy link
Member

@zhongjiajie zhongjiajie left a comment

Choose a reason for hiding this comment

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

Ohters LGTM

return false;
}
Map<String, Object> result =
projectService.checkProjectAndAuth(loginUser, project, project.getCode(), permissionKey);
Copy link
Member

Choose a reason for hiding this comment

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

could you use checkProjectAndAuthThrowException instead of checkProjectAndAuth to make our code more clear? It is may ask to change our UT as well

Copy link
Contributor Author

@rickchengx rickchengx Nov 24, 2022

Choose a reason for hiding this comment

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

Hi, @zhongjiajie Thanks for your suggestion. I've changed to checkProjectAndAuthThrowException.

@rickchengx rickchengx force-pushed the Fix-12916 branch 2 times, most recently from 047ee37 to 2e2844d Compare November 24, 2022 05:16
@EricGao888 EricGao888 added improvement make more easy to user or prompt friendly and removed discussion discussion labels Nov 24, 2022
@EricGao888 EricGao888 added this to the 3.2.0 milestone Nov 24, 2022
@EricGao888 EricGao888 added the 3.2.0 for 3.2.0 version label Nov 24, 2022
EricGao888
EricGao888 previously approved these changes Nov 24, 2022
@sonarcloud
Copy link

sonarcloud bot commented Nov 24, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 1 Code Smell

62.5% 62.5% Coverage
0.0% 0.0% Duplication

@EricGao888
Copy link
Member

PTAL when available, if no more comments, will proceed to merge.

@EricGao888 EricGao888 merged commit 7336afa into apache:dev Nov 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.2.0 for 3.2.0 version backend improvement make more easy to user or prompt friendly
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug] [Log] User can query or download other user's log
6 participants