Skip to content

Conversation

ibihim
Copy link
Contributor

@ibihim ibihim commented Jul 30, 2025

What

This change help us to collect metrics for violations that are based upon SCCs that are user-based.

Why

When a workload has a SCC that are based upon the privileges of the user, the PSA label syncer doesn't honor this and potentially assigns the wrong PSS.

Dependency

openshift/origin#30159

@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Jul 30, 2025
@openshift-ci-robot
Copy link

openshift-ci-robot commented Jul 30, 2025

@ibihim: This pull request references CNTRLPLANE-180 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the feature to target the "4.20.0" version, but no target version was set.

In response to this:

What

This change help us to collect metrics for violations that are based upon SCCs that are user-based.

Why

When a workload has a SCC that are based upon the privileges of the user, the PSA label syncer doesn't honor this and potentially assigns the wrong PSS.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci openshift-ci bot requested review from dgrisonnet and p0lyn0mial July 30, 2025 18:49
@openshift-merge-robot openshift-merge-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 30, 2025
ibihim added 5 commits July 30, 2025 21:36
The refactoring is necessary to split the condition into condition and
classification as the classification is quite tricky.
If we can't determine the PSS, we shouldn' error out, but default to
global config.
@ibihim ibihim force-pushed the ibihim/2025-07-30_check-for-user-scc-violation-git-commit-history branch from 29b3dfa to 465832d Compare July 30, 2025 19:37
@openshift-merge-robot openshift-merge-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 30, 2025
@ibihim
Copy link
Contributor Author

ibihim commented Jul 30, 2025

/retest-required

@ibihim ibihim force-pushed the ibihim/2025-07-30_check-for-user-scc-violation-git-commit-history branch from 5d7b236 to ca7b9ab Compare July 31, 2025 14:19
@ibihim
Copy link
Contributor Author

ibihim commented Aug 1, 2025

/retest-required

@dgrisonnet
Copy link
Member

Assigning myself for approval

/assign

Comment on lines +31 to +42
if runLevelZeroNamespaces.Has(ns.Name) {
conditions.addViolatingRunLevelZero(ns)
return nil
}
if strings.HasPrefix(ns.Name, "openshift") {
conditions.addViolatingOpenShift(ns)
return nil
}
if ns.Labels[labelSyncControlLabel] == "false" {
conditions.addViolatingDisabledSyncer(ns)
return nil
}

Choose a reason for hiding this comment

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

Is it possible that any of these can be true and the evalutions further below also apply?

I.e is it possible to have a user-created Pod running in a violating run-level zero namespace, openshift namespace, or namespace where the syncer is disabled?

Would it be valuable to still continue classification even if one of these is true?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The issues above are very profound. It is in the place of "someone consciously" did something, while below we are in the space of exploration / figuring out what the root cause is.

Runlevel Zero is mostly excluded a layer above, so this actually doesn't happen anymore. It occurred up until 4.14 or so.
If OpenShift is triggered a team needs to evaluate what they did and set their PSA level for their namespace accordingly.
If a customer disables we simply don't care and assume they take ownership.

Choose a reason for hiding this comment

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

If OpenShift is triggered a team needs to evaluate what they did and set their PSA level for their namespace accordingly.

Do we prevent users from creating workloads in these namespaces somehow?

If not, I could imagine getting reports from a cluster where an openshift-* namespace has violations from a user created workload, but because we don't root cause these violations we are oblivious to that fact.

If this is something we consider extremely rare and unlikely to affect our metrics in any significant way, I'm fine with this as-is but is something that I think is worth noting.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We don't prevent users from creating openshift- namespaces. Some Red Hat department even suggest to create openshfit--pre-fixed-namespaces when backing up etcd 😄

In most cases openshift- namespaces were teams that didn't adjust yet to the PSA enforcement.

)

const (
PodSecurityCustomerType = "PodSecurityCustomerEvaluationConditionsDetected"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@dgrisonnet, there is no harm (except the need to adjust our evaluation of the metrics), if we "rename" it, right?

Copy link
Member

Choose a reason for hiding this comment

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

Yes this is not what we would treat as a breaking change for a metric as it only modifies a label value. But you are correct that evaluation rules will need to be updated accordingly.

@ibihim ibihim changed the title CNTRLPLANE-180: check for user scc violation git commit history CNTRLPLANE-180: check for user-based SCCs causing PSA violations Aug 2, 2025
@ibihim
Copy link
Contributor Author

ibihim commented Aug 2, 2025

/retest-required

2 similar comments
@ibihim
Copy link
Contributor Author

ibihim commented Aug 11, 2025

/retest-required

@ibihim
Copy link
Contributor Author

ibihim commented Aug 15, 2025

/retest-required

Copy link
Member

@dgrisonnet dgrisonnet left a comment

Choose a reason for hiding this comment

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

/lgtm
/approve

)

const (
PodSecurityCustomerType = "PodSecurityCustomerEvaluationConditionsDetected"
Copy link
Member

Choose a reason for hiding this comment

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

Yes this is not what we would treat as a breaking change for a metric as it only modifies a label value. But you are correct that evaluation rules will need to be updated accordingly.

// isNamespaceViolating checks if a namespace is ready for Pod Security Admission enforcement.
// It returns true if the namespace is violating the Pod Security Admission policy, along with
// the enforce label it was tested against.
func (c *PodSecurityReadinessController) isNamespaceViolating(ctx context.Context, ns *corev1.Namespace) (bool, psapi.Level, error) {
Copy link
Member

Choose a reason for hiding this comment

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

I think decoupling the determineEnforceLabelForNamespace call from this function and taking the enforcement level as a parameter instead of a returned value would be cleaner.

From what I can tell, you could also change determineEnforceLabelForNamespace to take a Namespace instead of an ApplyConfig

@dgrisonnet
Copy link
Member

/retest-required

Copy link
Contributor

openshift-ci bot commented Aug 18, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: dgrisonnet, everettraven, ibihim

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 18, 2025
@openshift-ci-robot
Copy link

/retest-required

Remaining retests: 0 against base HEAD 36917f5 and 2 for PR HEAD 6c0f461 in total

2 similar comments
@openshift-ci-robot
Copy link

/retest-required

Remaining retests: 0 against base HEAD 36917f5 and 2 for PR HEAD 6c0f461 in total

@openshift-ci-robot
Copy link

/retest-required

Remaining retests: 0 against base HEAD 36917f5 and 2 for PR HEAD 6c0f461 in total

@openshift-ci-robot
Copy link

/retest-required

Remaining retests: 0 against base HEAD 0c2dfc0 and 1 for PR HEAD 6c0f461 in total

@openshift-ci-robot
Copy link

/retest-required

Remaining retests: 0 against base HEAD 0c2dfc0 and 2 for PR HEAD 6c0f461 in total

@ibihim
Copy link
Contributor Author

ibihim commented Aug 19, 2025

/retest-required

@openshift-ci-robot
Copy link

/retest-required

Remaining retests: 0 against base HEAD 0c2dfc0 and 2 for PR HEAD 6c0f461 in total

1 similar comment
@openshift-ci-robot
Copy link

/retest-required

Remaining retests: 0 against base HEAD 0c2dfc0 and 2 for PR HEAD 6c0f461 in total

@openshift-ci-robot
Copy link

/retest-required

Remaining retests: 0 against base HEAD 134fe2d and 1 for PR HEAD 6c0f461 in total

@openshift-ci-robot
Copy link

/retest-required

Remaining retests: 0 against base HEAD 134fe2d and 2 for PR HEAD 6c0f461 in total

2 similar comments
@openshift-ci-robot
Copy link

/retest-required

Remaining retests: 0 against base HEAD 134fe2d and 2 for PR HEAD 6c0f461 in total

@openshift-ci-robot
Copy link

/retest-required

Remaining retests: 0 against base HEAD 134fe2d and 2 for PR HEAD 6c0f461 in total

@openshift-ci-robot
Copy link

/retest-required

Remaining retests: 0 against base HEAD 94cb40f and 1 for PR HEAD 6c0f461 in total

@openshift-ci-robot
Copy link

/retest-required

Remaining retests: 0 against base HEAD 94cb40f and 2 for PR HEAD 6c0f461 in total

2 similar comments
@openshift-ci-robot
Copy link

/retest-required

Remaining retests: 0 against base HEAD 94cb40f and 2 for PR HEAD 6c0f461 in total

@openshift-ci-robot
Copy link

/retest-required

Remaining retests: 0 against base HEAD 94cb40f and 2 for PR HEAD 6c0f461 in total

@ibihim
Copy link
Contributor Author

ibihim commented Aug 25, 2025

/retest-required

@ibihim
Copy link
Contributor Author

ibihim commented Aug 25, 2025

Dependencies upon: openshift/origin#30159.

@openshift-ci-robot
Copy link

openshift-ci-robot commented Aug 25, 2025

@ibihim: This pull request references CNTRLPLANE-180 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the feature to target the "4.20.0" version, but no target version was set.

In response to this:

What

This change help us to collect metrics for violations that are based upon SCCs that are user-based.

Why

When a workload has a SCC that are based upon the privileges of the user, the PSA label syncer doesn't honor this and potentially assigns the wrong PSS.

Dependency

openshift/origin#30159

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci-robot
Copy link

/retest-required

Remaining retests: 0 against base HEAD 9649be0 and 1 for PR HEAD 6c0f461 in total

Copy link
Contributor

openshift-ci bot commented Aug 25, 2025

@ibihim: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/e2e-aws-ovn-single-node 6c0f461 link false /test e2e-aws-ovn-single-node
ci/prow/e2e-gcp-operator-single-node 6c0f461 link false /test e2e-gcp-operator-single-node
ci/prow/okd-scos-e2e-aws-ovn 6c0f461 link false /test okd-scos-e2e-aws-ovn
ci/prow/e2e-azure-ovn 6c0f461 link false /test e2e-azure-ovn
ci/prow/e2e-aws-ovn-serial-2of2 6c0f461 link true /test e2e-aws-ovn-serial-2of2
ci/prow/e2e-aws-ovn 6c0f461 link true /test e2e-aws-ovn
ci/prow/e2e-aws-ovn-serial-1of2 6c0f461 link true /test e2e-aws-ovn-serial-1of2

Full PR test history. Your PR dashboard.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants