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

[TEP-0091] Update trusted resources feature flag and add condition #949

Merged
merged 1 commit into from
Mar 14, 2023

Conversation

Yongxuanzhang
Copy link
Member

@Yongxuanzhang Yongxuanzhang commented Jan 31, 2023

This commit proposes to

  1. add mode field intoVerificationPolicy, update the feature flag to verification-no-match-policy with allow / warn / deny
  2. add condition into taskrun and pipelinerun to indicate the verification passes or not.

@tekton-robot tekton-robot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Jan 31, 2023
@Yongxuanzhang
Copy link
Member Author

Hi @afrittoli @wlynch @bobcatfish @jagathprakash
This is a proposal to update the trusted resources tep, plz take a look and share your comments.
Thanks!

@jerop
Copy link
Member

jerop commented Feb 7, 2023

/kind tep

@tekton-robot tekton-robot added the kind/tep Categorizes issue or PR as related to a TEP (or needs a TEP). label Feb 7, 2023
teps/0091-trusted-resources.md Outdated Show resolved Hide resolved
teps/0091-trusted-resources.md Outdated Show resolved Hide resolved
@pritidesai
Copy link
Member

API WG - waiting for the review

/assign @jagathprakash
/assign @afrittoli

@tekton-robot
Copy link
Contributor

@pritidesai: GitHub didn't allow me to assign the following users: jagathprakash.

Note that only tektoncd members, repo collaborators and people who have commented on this issue/PR can be assigned. Additionally, issues/PRs can only have 10 assignees at the same time.
For more information please see the contributor guide

In response to this:

API WG - waiting for the review

/assign @jagathprakash
/assign @afrittoli

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/test-infra repository.

@jagathprakash
Copy link
Member

/lgtm

@tekton-robot
Copy link
Contributor

@jagathprakash: changing LGTM is restricted to collaborators

In response to this:

/lgtm

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/test-infra repository.

* `skip`: Directly skip the verification.
`resource-verification-mode`. (Optional, `verify_all`, `verify_match` or `no_verification`, default `no_verification`):
* `verify_all`: Failing verification will mark the taskruns/pipelineruns as failed.
* `verify_match`: Fetch VerificationPolicy from the namespace, and if policies matched then verify, otherwise skip the verification. Details explained in [ Verify the Resources](#verify-the-resources)
Copy link
Member

Choose a reason for hiding this comment

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

I don't think this is a good idea to support globally, though I get why we'd want something like this for incremental adoption. It would be generally be bad if Tasks could circumvent verification just by renaming to something that's not covered by policy, and new Tasks that are probably riskier would be exempted by default since they're unlikely to match existing policies.

Instead of making verification opt-in, it would probably be safer to make the mode opt-out on a per-policy basis (see ClusterImagePolicySpec.mode for an example). This way things are directed to the more secure way by default, forcing users to either configure the matching policy or explicitly opt out the Tasks.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks! That makes sense. By looking at the ClusterImagePolicySpec.mode. How about changing the verify_match to:

  1. If found matched polices then verify and fail
  2. If no matched policies then warn

Copy link
Member

Choose a reason for hiding this comment

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

Preferring warn over skip generally sounds good, but that doesn't address the larger problem of opt-in enforcement and the ability to evade enforcement by crafting a non-matching artifact. 😢

Having policies that opt-out matching patterns seems like a better global policy - this way new artifacts that we haven't encountered before (whether they are malicious or not) can't bypass enforcement.

@wlynch
Copy link
Member

wlynch commented Feb 17, 2023

Followed up with @Yongxuanzhang off thread -

We're leaning towards modifying this slightly by:

  1. adding a mode field to VerificationPolicy to control allow/warn behavior rather than having a global config map value.
  2. Modifying resources-verification-mode to specify the action to take if no policy matches (we may rename this to make the behavior clearer).

If you want to have the same affect as what is proposed for verify-match, you can achieve this in one of 2 ways:

  1. Set ConfigMap resources-verification-mode: enforce, then define a policy like:

    apiVersion: tekton.dev/v1alpha1
    kind: VerificationPolicy
    metadata:
      name: foo
    spec:
      resources:
        - pattern: ".*"
      mode: warn

    Ideally this should be scoped to only a few sets of resources, and acts as an allowlist. Ideally for cases like "we want to enforce everything, but we know a set of resources isn't signed yet so we will allow those". Enforce mode policies would take precedence over warn.

  2. Set ConfigMap resources-verification-mode: warn, then define a policy like:

    apiVersion: tekton.dev/v1alpha1
    kind: VerificationPolicy
    metadata:
      name: foo
    spec:
      resources:
        - pattern: "https://github.com/tektoncd/catalog.git"
      mode: enforce  # this would be the default so could also be omitted.

    This would be closer to what was originally proposed for resources-verification-mode: verify_match - i.e. only enforce matching policies without an explicit opt-out policy.

Much of this was inspired by https://github.com/sigstore/policy-controller so, feel free to take a look there to read up on additional background.

We'll plan to discuss this more in next week's s3c working group, so please join if you have thoughts / opinions! 🙏

@tekton-robot tekton-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Feb 23, 2023
@Yongxuanzhang Yongxuanzhang requested review from wlynch and jagathprakash and removed request for pritidesai, piyush-garg and wlynch February 23, 2023 04:42
@Yongxuanzhang Yongxuanzhang force-pushed the more-updates-91 branch 3 times, most recently from 782f142 to 828e730 Compare February 23, 2023 05:24
@Yongxuanzhang
Copy link
Member Author

/assign @bobcatfish

@Yongxuanzhang
Copy link
Member Author

/assign @jagathprakash

jerop

This comment was marked as duplicate.

@Yongxuanzhang Yongxuanzhang force-pushed the more-updates-91 branch 6 times, most recently from eab08cc to f883bbb Compare March 10, 2023 17:17
teps/0091-trusted-resources.md Outdated Show resolved Hide resolved
teps/0091-trusted-resources.md Outdated Show resolved Hide resolved
teps/0091-trusted-resources.md Outdated Show resolved Hide resolved
teps/0091-trusted-resources.md Outdated Show resolved Hide resolved
teps/0091-trusted-resources.md Outdated Show resolved Hide resolved
teps/0091-trusted-resources.md Outdated Show resolved Hide resolved
Copy link
Member

@jerop jerop left a comment

Choose a reason for hiding this comment

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

Thanks for the addressing my feedback, the conditions are much clearer now 🎉

status: "False"
type: TrustedResourcesVerified
- lastTransitionTime: "2023-03-01T18:17:10Z"
message: resource verification failed
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
message: resource verification failed
message: Trusted resource verification failed

teps/0091-trusted-resources.md Outdated Show resolved Hide resolved
teps/0091-trusted-resources.md Outdated Show resolved Hide resolved
@tekton-robot tekton-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 10, 2023
@jerop
Copy link
Member

jerop commented Mar 10, 2023

@afrittoli @bobcatfish @jagathprakash @wlynch please take another look 🙏🏾

@jerop
Copy link
Member

jerop commented Mar 10, 2023

once all assignees have approved, feel free to unhold (just don't want it to merge accidentally)

Copy link
Member

@wlynch wlynch left a comment

Choose a reason for hiding this comment

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

/lgtm

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Mar 13, 2023
Copy link
Contributor

@bobcatfish bobcatfish left a comment

Choose a reason for hiding this comment

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

Thanks for all the updates @Yongxuanzhang ! There's one last nit from me about referring to the "knative API" but nothing blocking

/approve

* `warn`: Don't fail the taskrun/pipelinerun and log a warning if no matching policies are found.
* `fail`: Fail the taskrun/pipelinerun if no matching policies are found.

**Note:** The current proposed `trusted-resources-verification-no-match-policy` will be added to replace the old `resource-verification-mode` in one release and this is not a backwards compatible change.
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is already on your radar, but please send a notification to tekton-dev@ and tekton-users@ to warn folks this is going to happen within one release, with some warning (at least a week I'm thinking?) before the release goes out 🙏

teps/0091-trusted-resources.md Outdated Show resolved Hide resolved
teps/0091-trusted-resources.md Show resolved Hide resolved
@tekton-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: bobcatfish, jerop

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

This commit proposes to add mode field into VerificationPolicy, update the feature flag trusted-resources-verification-no-match-policy to control the behaviour of no matching policies for a resource. Besides this commit proposes to add condition into taskrun and pipelinerun to indicate the verification passes or not.
@tekton-robot tekton-robot removed the lgtm Indicates that a PR is ready to be merged. label Mar 14, 2023
@Yongxuanzhang
Copy link
Member Author

/hold cancel

@tekton-robot tekton-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Mar 14, 2023
Copy link
Member

@wlynch wlynch left a comment

Choose a reason for hiding this comment

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

/lgtm

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Mar 14, 2023
@tekton-robot tekton-robot merged commit dbbe9e8 into tektoncd:main Mar 14, 2023
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. kind/tep Categorizes issue or PR as related to a TEP (or needs a TEP). lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants