Skip to content

Conversation

@Ankita13-code
Copy link

@Ankita13-code Ankita13-code commented Mar 27, 2025

Merge Checklist
  • Followed patch format from upstream recommendation: https://github.com/kata-containers/community/blob/main/CONTRIBUTING.md#patch-format
    • Included a single commit in a given PR - at least unless there are related commits and each makes sense as a change on its own.
  • Aware about the PR to be merged using "create a merge commit" rather than "squash and merge" (or similar)
  • The upstream/missing label (or upstream/not-needed) has been set on the PR.
Summary

This PR introduces validation for additional input fields in ExecProcessRequest. It follows an approach similar to CreateContainerRequest to enforce null values for string_user and disallow selinuxLabel in ExecProcessRequest.
The field ApparmorProfile is disallowed for both ExecProcessRequest and CreateContainerRequest.

Test Methodology

manuelh-dev and others added 30 commits July 12, 2024 16:48
samples: introduce incomplete_init category
Cherry-pick upstream PR kata-containers#9825: osbuilder: allow rootfs builds w/o git or version file deps
- Support for Mariner 3 builds using OS_VERSION variable
- Improvements to IGVM build process and flow as described in README
- Adoption of using only cloud-hypervisor-cvm on CBL-Mariner

Signed-off-by: Manuel Huber <[email protected]>
tools: Improve igvm-builder and node-builder/azure-linux scripting
At the moment, we have circular dependencies between
tardev-snapshotter.service and containerd.service. Specifically,
containerd.service needs tardev-snapshotter.service to run any CC pods,
while tardev-snapshotter.service needs containerd.service to download
image layers. This dependency will be eliminated once we switch to
using remote-snapshotter. Currently, tardev-snapshotter.service's
binding to containerd.service gets delayed, and we won't be able to
run any CC pods until the boot process is completed. It doesn't matter
which service starts first. Based on the current logic, it makes more
sense to use WantedBy=kubelet.service in tardev-snapshotter.service, as
we won't be able to start any CC pods without kubelet. In the future,
once tardev-snapshotter becomes a remote snapshotter again, it will
make more sense to use WantedBy=containerd.service.

Signed-off-by: Mitch Zhu <[email protected]>
tardev: update tardev-snapshotter.service
Use container image sources from ACR/MCR.

Signed-off-by: Manuel Huber <[email protected]>
samples: reduce dependencies to docker hub
1. Use the new value of AllowRequestsFailingPolicy after setting up a
   new Policy. Before this change, the only way to enable
   AllowRequestsFailingPolicy was to change the default Policy file,
   built into the Guest rootfs image.

2. Ignore errors returned by regorus while evaluating Policy rules, if
   AllowRequestsFailingPolicy was enabled. For example, trying to
   evaluate the UpdateInterfaceRequest rules using a policy that didn't
   define any UpdateInterfaceRequest rules results in a "not found"
   error from regorus. Allow AllowRequestsFailingPolicy := true to
   bypass that error.

3. Add simple CI test for AllowRequestsFailingPolicy.

These changes are restoring functionality that was broken recently by
commmit 11f78ae.

Signed-off-by: Dan Mihai <[email protected]>
agent: fix the AllowRequestsFailingPolicy functionality
This adds a public guide on how to install and test the new storage CSI
drivers for AKS confidential pods.

Signed-off-by: Aurélien Bombo <[email protected]>
docs: add guide to install new CSI drivers
Add support for cron jobs

Signed-off-by: Saul Paredes <[email protected]>
Use up-to-date AzL references

Signed-off-by: Manuel Huber <[email protected]>
Reject CreateContainerRequest field values that are not tested by
Kata CI and that might impact the confidentiality of CoCo Guests.

This change uses a "better safe than sorry" approach to untested
fields. It is very possible that in the future we'll encounter
reasonable use cases that will either:

- Show that some of these fields are benign and don't have to be
  verified by Policy, or
- Show that Policy should verify legitimate values of these fields

These are the new CreateContainerRequest Policy rules:

    count(input.shared_mounts) == 0
    is_null(input.string_user)

    i_oci := input.OCI
    is_null(i_oci.Hooks)
    is_null(i_oci.Linux.Seccomp)
    is_null(i_oci.Solaris)
    is_null(i_oci.Windows)

    i_linux := i_oci.Linux
    count(i_linux.GIDMappings) == 0
    count(i_linux.MountLabel) == 0
    count(i_linux.Resources.Devices) == 0
    count(i_linux.RootfsPropagation) == 0
    count(i_linux.UIDMappings) == 0
    is_null(i_linux.IntelRdt)
    is_null(i_linux.Resources.BlockIO)
    is_null(i_linux.Resources.Network)
    is_null(i_linux.Resources.Pids)
    is_null(i_linux.Seccomp)
    i_linux.Sysctl == {}

    i_process := i_oci.Process
    count(i_process.SelinuxLabel) == 0
    count(i_process.User.Username) == 0

Signed-off-by: Dan Mihai <[email protected]>
Update annotations after reject untested CreateContainer field values

Signed-off-by: Saul Paredes <[email protected]>
genpolicy: reject untested CreateContainer field values
This is a more stable tag. Previous tag got updated yesterday and
requires to update the annotation.

Signed-off-by: Saul Paredes <[email protected]>
Bump release version to 3.2.0-azl1.genpolicy1

Signed-off-by: Saul Paredes <[email protected]>
- Add script to install kata-containers(-cc)-tools bits
- Minor improvements in README.md
- Minor fix in package_install
- Remove echo outputs in package_build

Signed-off-by: Manuel Huber <[email protected]>
tools: Add package-tools-install functionality
- Allow setting SVN parameter for IGVM build scripting

Signed-off-by: Manuel Huber <[email protected]>
This lets developers build and deploy Kata in debug mode without having to make
manual edits to the build scripts.

With BUILD_TYPE=debug (default is release):

 * The agent is built in debug mode.
 * The agent is built with a permissive policy (using allow-all.rego).
 * The shim debug config file is used, ie. we create the symlink
   configuration-clh-snp-debug.toml <- configuration-clh-snp.toml.

For example, building and deploying Kata-CC in debug mode is now as simple as:

   make BUILD_TYPE=debug all-confpods deploy-confpods

Also do note that make still lets you override the other variables even after
setting BUILD_TYPE. For example, you can use the production shim config with
BUILD_TYPE=debug:

   make BUILD_TYPE=debug SHIM_USE_DEBUG_CONFIG=no all-confpods deploy-confpods

Signed-off-by: Aurélien Bombo <[email protected]>
node-builder: introduce BUILD_TYPE variable
Update samples that use
image: "mcr.microsoft.com/azurelinux/base/nginx:1.25". Looks like
this image tag was updated in mcr on 8/27/2024.

Signed-off-by: Saul Paredes <[email protected]>
Camelron and others added 9 commits March 14, 2025 17:13
Update samples

Signed-off-by: Cameron Baird <[email protected]>
…policy

genpolicy: Introduce UpdateRoutesRequest, UpdateInterfaceRequest rules in genpolicy-settings
Add test cases for basic and legacy requests to create pause container

Signed-off-by: Saul Paredes <[email protected]>
…er_tests

policy: add tests for createContainerRequest
Validate sandbox name using a regex. If the YAML specifies metadata.name, use a regex that exact matches.
If the YAML specifies metadata.generateName, use a regex that matches the prefix of the generated name.

Signed-off-by: Saul Paredes <[email protected]>
We only use protocols in the tests, so it should be a dev dependency.

Signed-off-by: Saul Paredes <[email protected]>
Update samples

Signed-off-by: Saul Paredes <[email protected]>
…_name

policy: validate pod generated name
Use "cargo build --release" when BUILD_TYPE was not specified, or when
BUILD_TYPE=release. The default "cargo build" behavior is to build in
debug mode.

Signed-off-by: Dan Mihai <[email protected]>
@Ankita13-code Ankita13-code added the upstream/missing PRs that are yet to be upstreamed label Mar 27, 2025
@Redent0r
Copy link

I'd vote to squash these 3 commits into a single one and summarize the fields that are being validated

@Redent0r
Copy link

todo: rebase against msft-main once #335 gets merged and add unit tests. If we pass all pipeline tests, I'd say we may move upstream without the unit tests here.

@Ankita13-code Ankita13-code force-pushed the ankitapareek/genpolicy-input-validation branch from f5369d0 to fc3e210 Compare March 28, 2025 08:56
@Ankita13-code
Copy link
Author

I'd vote to squash these 3 commits into a single one and summarize the fields that are being validated

Done!

@Ankita13-code Ankita13-code changed the title policy: Add validation for ExecProcessRequest input fields policy: Add missing validation for ExecProcessRequest input fields Mar 28, 2025
@danmihai1
Copy link

I'd vote to squash these 3 commits into a single one and summarize the fields that are being validated

@Redent0r @Ankita13-code , please use a separate commit for updating the YAML files.

# TODO: should other ExecProcessRequest input data fields be validated as well?
ExecProcessRequest {
print("ExecProcessRequest 1: input =", input)
allow_exec_process_input(input)

Choose a reason for hiding this comment

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

If I understand correctly, we can remove the input function parameter, and just use input from the allow_exec_process_input rules.

Copy link
Author

Choose a reason for hiding this comment

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

@danmihai1, updated the function to remove this parameter

@Ankita13-code
Copy link
Author

lease use a separate commit for updating the YAML files.

@danmihai1 we already have a separate commit for the samples. Saul was talking about some of the earlier commits that I had for validating each input field.

@Ankita13-code Ankita13-code force-pushed the ankitapareek/genpolicy-input-validation branch from 4994b72 to 7d08ebe Compare March 31, 2025 05:51
This commit introduces validation for input fields in ExecProcessRequest to
harden the security policy.

The changes include:
- update rules.rego to add null/empty field enforcements for String_user, SelinuxLabel and ApparmorProfile

Signed-off-by: Ankita Pareek <[email protected]>
@Ankita13-code Ankita13-code force-pushed the ankitapareek/genpolicy-input-validation branch from 7d08ebe to 2d2d59a Compare March 31, 2025 06:15
Update policy samples with new rules for ExecProcessRequest in policy

Signed-off-by: Ankita Pareek <[email protected]>
@Ankita13-code Ankita13-code force-pushed the ankitapareek/genpolicy-input-validation branch from 78c6500 to 189e903 Compare April 1, 2025 05:26
@Ankita13-code
Copy link
Author

Closing this PR since it was a placeholder and has been already merged upstream.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

upstream/missing PRs that are yet to be upstreamed

Projects

None yet

Development

Successfully merging this pull request may close these issues.