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

shell: make registered services secure by default #2877

Merged
merged 3 commits into from
Mar 29, 2020

Conversation

grondo
Copy link
Contributor

@grondo grondo commented Mar 29, 2020

Wrap all message handlers registered with flux_shell_service_register(3) and check shell_svc_allowed before calling the real msg handler. This makes shell services accessible only to the shell user (and instance owner) by default, instead of having services "open to all" when first registered. This should greatly reduce the potential for accidental security vulnerabilities introduced by shell plugins.

If ever there is a need for a shell service that is open to all users, we can add a new shell.h API call which explicitly registers a multiuser accessible service.

grondo added 3 commits March 29, 2020 15:41
Problem: Shell services registered by flux_shell_service_register()
are "open to all" by default, and require a call to shell_svc_allowed()
in each msg handler in order to secure the service against multi-user
access. However, this design requires repetitive calls in every service
message handler, and makes it more likely that plugins install insecure
services when this call is forgotten. Furthermore, shell_svc_allowed()
is not even exported publicly in the shell.h API, so it is impossible
to create secure services via external shell plugins.

Internally wrap all message handlers installed by shell_svc_register()
and call shell_svc_allowed() so that all services are secure by default.

If a use case ever arises that requires multiuser access to a shell
service, then a separate api call can be created to export an
insecure service, so that the security of the service is explicit.

Fixes flux-framework#2876
Since shell services registered by flux_shell_service_register()
are now secure by default, remove redundant calls to shell_svc_allowed()
in message handlers in the input and output services.
Add test to ensure proctable shell service is not accessible to
all users in t2610-job-shell-mpir.t.
@codecov-io
Copy link

Codecov Report

Merging #2877 into master will increase coverage by 0.05%.
The diff coverage is 84.21%.

@@            Coverage Diff             @@
##           master    #2877      +/-   ##
==========================================
+ Coverage   80.98%   81.04%   +0.05%     
==========================================
  Files         250      250              
  Lines       39352    39368      +16     
==========================================
+ Hits        31871    31905      +34     
+ Misses       7481     7463      -18     
Impacted Files Coverage Δ
src/shell/input.c 84.46% <ø> (-0.07%) ⬇️
src/shell/output.c 78.58% <ø> (-0.06%) ⬇️
src/shell/shell.c 84.57% <84.21%> (-0.05%) ⬇️
src/cmd/flux-job.c 85.85% <0.00%> (+0.25%) ⬆️
src/common/libsubprocess/local.c 79.93% <0.00%> (+0.34%) ⬆️
src/modules/job-info/job_state.c 70.52% <0.00%> (+0.46%) ⬆️
src/modules/job-info/watch.c 72.53% <0.00%> (+1.55%) ⬆️
src/common/libflux/handle.c 85.61% <0.00%> (+2.05%) ⬆️
src/shell/svc.c 77.94% <0.00%> (+2.94%) ⬆️

Copy link
Member

@garlick garlick left a comment

Choose a reason for hiding this comment

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

Looks like a good fix to me - feel free to set MWP.

@grondo
Copy link
Contributor Author

grondo commented Mar 29, 2020

Thanks!

@mergify mergify bot merged commit 8ee9021 into flux-framework:master Mar 29, 2020
@grondo grondo deleted the issue#2876 branch July 25, 2020 04:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants