learn how you can [configure the action](/manuals/build/ci/github-actions/attestations.md)
to apply SBOM and provenance attestations.
### Default Non-Root User
By default, containers run as the `root` superuser with full system
administration privileges inside the container, unless the Dockerfile specifies
a different default user. Running containers as a privileged user weakens their
runtime security, as it means any code that runs in the container can perform
administrative actions.
The **Default Non-Root User** policy type detects images that are set to run as
the default `root` user. To comply with this policy, images must specify a
non-root user in the image configuration. Images are non-compliant with this
policy if they don't specify a non-root default user for the runtime stage.
For non-compliant images, evaluation results show whether or not the `root`
user was set explicitly for the image. This helps you distinguish between
policy violations caused by images where the `root` user is implicit, and
images where `root` is set on purpose.
The following Dockerfile runs as `root` by default despite not being explicitly set:
```Dockerfile
FROM alpine
RUN echo "Hi"
```
Whereas in the following case, the `root` user is explicitly set:
```Dockerfile
FROM alpine
USER root
RUN echo "Hi"
```
> [!NOTE]
>
> This policy only checks for the default user of the image, as set in the
> image configuration blob. Even if you do specify a non-root default user,
> it's still possible to override the default user at runtime, for example by
> using the `--user` flag for the `docker run` command.
To make your images compliant with this policy, use the
[`USER`](/reference/dockerfile.md#user) Dockerfile instruction to set
a default user that doesn't have root privileges for the runtime stage.
The following Dockerfile snippets shows the difference between a compliant and
non-compliant image.
{{< tabs >}}
{{< tab name="Non-compliant" >}}
```dockerfile
FROM alpine AS builder
COPY Makefile ./src /
RUN make build
FROM alpine AS runtime
COPY --from=builder bin/production /app
ENTRYPOINT ["/app/production"]
```
{{< /tab >}}
{{< tab name="Compliant" >}}
```dockerfile {hl_lines=7}
FROM alpine AS builder
COPY Makefile ./src /
RUN make build
FROM alpine AS runtime
COPY --from=builder bin/production /app
USER nonroot
ENTRYPOINT ["/app/production"]
```
{{< /tab >}}
{{< /tabs >}}
### Approved Base Images
The **Approved Base Images** policy type ensures that the base images you use
in your builds are maintained and secure.
This policy checks whether the base images used in your builds match any of the
patterns specified in the policy configuration. The following table shows a few
example patterns for this policy.
| Use case | Pattern |
| --------------------------------------------------------------- | -------------------------------- |
| Allow all images from Docker Hub | `docker.io/*` |
| Allow all Docker Official Images | `docker.io/library/*` |
| Allow images from a specific organization | `docker.io/orgname/*` |
| Allow tags of a specific repository | `docker.io/orgname/repository:*` |
| Allow images on a registry with hostname `registry.example.com` | `registry.example.com/*` |
| Allow slim tags of NodeJS images | `docker.io/library/node:*-slim` |
An asterisk (`*`) matches up until the character that follows, or until the end
of the image reference. Note that the `docker.io` prefix is required in order
to match Docker Hub images. This is the registry hostname of Docker Hub.
This policy is configurable with the following options:
- **Approved base image sources**
Specify the image reference patterns that you want to allow. The policy
evaluates the base image references against these patterns.