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

Flyte-core define pod and container securityContext #4809

Merged

Conversation

ddl-ebrown
Copy link
Contributor

@ddl-ebrown ddl-ebrown commented Jan 31, 2024

Like #4785 does for the agent, this defines the security context for flyte-core pods / containers.

  • Define secure defaults for all pod / container specs:

    • runAsNonRoot: true
    • capabilities: drop: ['ALL']
    • allowPrivilegeEscalation: false
    • seLinuxOptions: type: spc_t

    This is required in many locations where policy enforcement agents
    may be installed (like OPA Gatekeeper) which may otherwise prevent
    deployments from launching.

    The hard work of making sure the containers run as non-0 uids seems
    to have already been done given all containers are already specifying
    a runAsUser value of 1000 or 1001, so this should hopefully just be a
    little more hardening around restricting kernel permissions /
    enforcement within the container runtime.

    These are generally considered standard / secure default settings and
    are not currently made configurable given these services are all
    owned by Flyte

Tracking issue

https://github.com/flyteorg/flyte/issues/

Why are the changes needed?

What changes were proposed in this pull request?

How was this patch tested?

In local testing, all pods seem to be behaving correctly with these additional restrictions

Setup process

Screenshots

Check all the applicable boxes

  • I updated the documentation accordingly.
  • All new and existing tests passed.
  • All commits are signed-off.

Related PRs

Docs link

@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. security Issues related to Security improvements labels Jan 31, 2024
Copy link

codecov bot commented Feb 1, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (4223a83) 58.98% compared to head (a3ffa89) 59.73%.
Report is 8 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4809      +/-   ##
==========================================
+ Coverage   58.98%   59.73%   +0.74%     
==========================================
  Files         644      644              
  Lines       55146    49161    -5985     
==========================================
- Hits        32529    29364    -3165     
+ Misses      20043    17223    -2820     
  Partials     2574     2574              
Flag Coverage Δ
unittests 59.58% <ø> (+0.60%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@davidmirror-ops davidmirror-ops left a comment

Choose a reason for hiding this comment

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

This one looks very interesting. @ddl-ebrown have you already deployed the chart with these settings?

@ddl-ebrown
Copy link
Contributor Author

We have and everything starts ok BUT we haven't yet validated everything works ok. We'll be doing that this week and I'll follow up.

Unlike the agent where you've got a general purpose chart capable of deploying a bunch of different agents, you control all of the code in all of these services so I thought for now there's less of a need for these settings to be configurable.

I'm not sure what your integration test suites do, but if they exercise the majority of the Flyte features then that should be some signal that these changes are compatible

 - Define secure defaults for all pod / container specs:

   * runAsNonRoot: true
   * capabilities:
       drop: ['ALL']
   * allowPrivilegeEscalation: false
   * seLinuxOptions:
       type: spc_t

   This is required in many locations where policy enforcement agents
   may be installed (like OPA Gatekeeper) which may otherwise prevent
   deployments from launching.

   The hard work of making sure the containers run as non-0 uids seems
   to have already been done given all containers are already specifying
   a runAsUser value of 1000 or 1001, so this should hopefully just be a
   little more hardening around restricting kernel permissions /
   enforcement within the container runtime.

   These are generally considered standard / secure default settings and
   are not currently made configurable given these services are all
   owned by Flyte

Signed-off-by: ddl-ebrown <[email protected]>
@ddl-ebrown ddl-ebrown force-pushed the improve-flytecore-securitycontext branch from 1610086 to a3ffa89 Compare February 6, 2024 03:38
Copy link
Contributor

@davidmirror-ops davidmirror-ops left a comment

Choose a reason for hiding this comment

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

Thank you!

@davidmirror-ops davidmirror-ops merged commit fe1204c into flyteorg:master Feb 13, 2024
51 checks passed
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Feb 13, 2024
@ddl-ebrown ddl-ebrown deleted the improve-flytecore-securitycontext branch February 14, 2024 06:33
katrogan pushed a commit that referenced this pull request Feb 20, 2024
- Define secure defaults for all pod / container specs:

   * runAsNonRoot: true
   * capabilities:
       drop: ['ALL']
   * allowPrivilegeEscalation: false
   * seLinuxOptions:
       type: spc_t

   This is required in many locations where policy enforcement agents
   may be installed (like OPA Gatekeeper) which may otherwise prevent
   deployments from launching.

   The hard work of making sure the containers run as non-0 uids seems
   to have already been done given all containers are already specifying
   a runAsUser value of 1000 or 1001, so this should hopefully just be a
   little more hardening around restricting kernel permissions /
   enforcement within the container runtime.

   These are generally considered standard / secure default settings and
   are not currently made configurable given these services are all
   owned by Flyte

Signed-off-by: ddl-ebrown <[email protected]>
Signed-off-by: Katrina Rogan <[email protected]>
yubofredwang pushed a commit to yubofredwang/flyte that referenced this pull request Mar 26, 2024
- Define secure defaults for all pod / container specs:

   * runAsNonRoot: true
   * capabilities:
       drop: ['ALL']
   * allowPrivilegeEscalation: false
   * seLinuxOptions:
       type: spc_t

   This is required in many locations where policy enforcement agents
   may be installed (like OPA Gatekeeper) which may otherwise prevent
   deployments from launching.

   The hard work of making sure the containers run as non-0 uids seems
   to have already been done given all containers are already specifying
   a runAsUser value of 1000 or 1001, so this should hopefully just be a
   little more hardening around restricting kernel permissions /
   enforcement within the container runtime.

   These are generally considered standard / secure default settings and
   are not currently made configurable given these services are all
   owned by Flyte

Signed-off-by: ddl-ebrown <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm This PR has been approved by a maintainer security Issues related to Security improvements size:L This PR changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants