Container Hardening logo

Container Hardening

Organization
RedHatProductSecurity
container-hardening

Harden container images and runtime configuration. Use when building, reviewing, or auditing Containerfiles, Dockerfiles, container compose files, or Kubernetes pod security settings.

Overview

PublisherRedHatProductSecurity
Repositoryprodsec-skills
Skill namecontainer-hardening
Stars
56
Forks
9
Bundled files
Instructions only
LicenseApache-2.0
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • Self-contained

    Everything the model needs lives in the instructions — no extra files to sync.

  • Open source

    Published by RedHatProductSecurity on GitHub. Read the source before you install it.

Installation

Install the Container Hardening AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/RedHatProductSecurity/prodsec-skills/tree/main/ge-core/container-hardening
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/RedHatProductSecurity/prodsec-skills.git /tmp/prodsec-skills
mkdir -p .claude/skills
cp -r /tmp/prodsec-skills/ge-core/container-hardening .claude/skills/container-hardening
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Container Hardening in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Container Hardening on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Container Hardening is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

Container Hardening

Secure container images and runtime configuration to reduce attack surface, prevent privilege escalation, and ensure compliance with Kubernetes security best practices.

Base Image Selection

  • Use a Universal Base Image (UBI) from the official Red Hat Container Registry
  • Prefer ubi-minimal (ubi8/ubi-minimal or ubi9/ubi-minimal) to reduce attack surface
  • Use the most up-to-date image available

Required for: all profiles (mandatory)

Image Tagging Strategy

SourceStrategy
Red Hat CatalogOmit floating tags to get the latest image; exception: Konflux project uses digest-based pinning with automated updates
Non-Red Hat registriesPin the version or digest to ensure you use the intended image and not a tampered one

Minimize Installed Software

Remove non-essential packages and clean up package manager caches:

dockerfile
RUN microdnf upgrade -y && \
    microdnf install -y <required-packages> && \
    microdnf remove -y <unnecessary-packages> && \
    microdnf clean all

Use microdnf on ubi-minimal images; dnf on full UBI images.

Runtime Security

Non-Root Execution

Containers must not run as root. Set runAsNonRoot: true and provide a numeric non-root USER in the Containerfile.

Required for: all profiles (mandatory)

dockerfile
USER 1000
yaml
securityContext:
  runAsNonRoot: true
  runAsUser: 1000

Either the pod-level or container-level securityContext can set these fields. Do not use UID 0 (root) or UID 1337 (reserved for Istio sidecar proxies).

Required for: Extended (mandatory), all others (optional) — UID 1337 restriction

Privilege Restrictions

Set allowPrivilegeEscalation: false to prevent privilege escalation during container execution:

Required for: all profiles (mandatory)

yaml
securityContext:
  allowPrivilegeEscalation: false

Or in a compose file:

yaml
security_opt:
  - no-new-privileges: true

Read-Only Filesystem

Use read-only root filesystems wherever possible:

Required for: all profiles (optional, recommended best practice)

yaml
securityContext:
  readOnlyRootFilesystem: true

Mount writable tmpfs volumes only where the application requires write access (e.g., /tmp, /var/run).

Read-Only Volumes

Mount volumes as read-only unless the container must write to them:

yaml
volumeMounts:
  - name: config
    mountPath: /etc/app
    readOnly: true

Service Account Token

Disable automatic mounting of the Kubernetes API service account token unless the pod needs API access:

Required for: Telco (mandatory), Far-Edge (mandatory), Extended (mandatory), Non-Telco (optional)

yaml
spec:
  automountServiceAccountToken: false

Pods that require API access (e.g., operators, controllers) should use a dedicated service account with minimal RBAC permissions and explicitly set automountServiceAccountToken: true.

One Process Per Container

Each container should run a single process. This simplifies monitoring, log collection, debugging, and security assessment. Use sidecar containers for auxiliary tasks (log shipping, proxy, etc.) rather than running multiple daemons in one container.

Required for: all profiles (optional, recommended best practice)

No SSH Daemons

Containers must not run SSH daemons. SSH in containers creates additional attack surfaces and violates immutable infrastructure principles. Use kubectl exec or oc debug for troubleshooting instead.

Required for: Telco (mandatory), Far-Edge (mandatory), Extended (mandatory), Non-Telco (optional)

Security Context Categories

The certsuite defines 4 approved security context categories based on required Linux capabilities. Target Category 1 (most restrictive) unless the workload requires advanced networking or DPDK.

Required for: Extended (mandatory), all others (optional)

CategoryDescriptionAdded Capabilities
Category 1Limited access (default)None
Category 1 (no UID 0)Basic rights with mesh networksNone (runAsNonRoot: true)
Category 2Advanced networking (VLAN tag, DSCP, priority)NET_ADMIN, NET_RAW
Category 3SR-IOV and DPDKNET_ADMIN, NET_RAW, IPC_LOCK

All categories require:

  • Drop capabilities: ALL (or at minimum MKNOD, SETUID, SETGID, KILL)
  • No host access: hostIPC: false, hostNetwork: false, hostPID: false, no hostPort
  • No privileged containers: privileged: false
  • User identity: runAsUser and fsGroup set, SELinux context present
  • Allowed volume types only: ConfigMap, DownwardAPI, EmptyDir, PersistentVolumeClaim, Projected, Secret

Example: Category 1 Security Context (Preferred)

yaml
spec:
  securityContext:
    runAsNonRoot: true
    runAsUser: 1000
    fsGroup: 1000
    seLinuxOptions:
      type: container_t
  containers:
    - name: app
      image: registry.example.com/app:v1.2.3
      securityContext:
        allowPrivilegeEscalation: false
        readOnlyRootFilesystem: true
        capabilities:
          drop: ["ALL"]

Base Image Integrity

Container base images must not be modified after startup. All required binaries and dependencies must be built into the image at build time.

Required for: all profiles (mandatory)

Protected directories that must remain unchanged at runtime: /bin, /sbin, /lib, /lib64, /usr/bin, /usr/sbin, /usr/lib, /usr/lib64, /var/lib/rpm, /var/lib/dpkg

OpenShift Note: SELinux must be in Enforcing mode on all cluster nodes (mandatory across all profiles). Base images must be Red Hat UBI (mandatory across all profiles).

Containerfile Linting

Use Hadolint to lint Containerfiles for best-practice violations and inline bash issues:

bash
hadolint Containerfile

Hadolint catches common issues (running as root, missing version pins, unnecessary sudo) but should not be trusted without additional verification.

Implementation Checklist

  • Base image is a Red Hat UBI from the official catalog
  • ubi-minimal is used unless a full UBI is justified
  • Non-Red Hat base images are pinned by version or digest
  • Non-essential packages are removed and caches cleaned
  • runAsNonRoot: true is set at pod or container level
  • A numeric non-root USER is set in the Containerfile
  • Container UID is not 0 or 1337
  • allowPrivilegeEscalation: false is set
  • readOnlyRootFilesystem: true is set
  • Volumes are mounted read-only unless writes are required
  • automountServiceAccountToken: false unless API access is required
  • Each container runs a single process
  • No SSH daemons are running in containers
  • Security context matches an approved category (Category 1-3)
  • Required capabilities are dropped (ALL, or at minimum MKNOD, SETUID, SETGID, KILL)
  • Container base image is not modified post-startup
  • SELinux is in Enforcing mode on all cluster nodes
  • Hadolint runs in CI on all Containerfiles
  • Container images are rebuilt regularly to pick up base image updates

Certsuite Test Mapping

GuidanceCertsuite Test IDProfiles
Privilege escalation disabledaccess-control-security-context-privilege-escalationAll profiles: mandatory
Run as non-rootaccess-control-security-context-non-root-user-id-checkAll profiles: mandatory
Read-only root filesystemaccess-control-security-context-read-only-file-systemAll profiles: optional
Security context categoryaccess-control-security-contextExtended: mandatory, all others: optional
UID not 1337access-control-no-1337-uidExtended: mandatory, all others: optional
One process per containeraccess-control-one-process-per-containerAll profiles: optional
Service account tokenaccess-control-pod-automount-service-account-tokenTelco/Far-Edge/Extended: mandatory, Non-Telco: optional
No SSH daemonsaccess-control-ssh-daemonsTelco/Far-Edge/Extended: mandatory, Non-Telco: optional
Base image not modifiedplatform-alteration-base-imageAll profiles: mandatory
SELinux enforcingplatform-alteration-is-selinux-enforcingAll profiles: mandatory
Red Hat base imageplatform-alteration-isredhat-releaseAll profiles: mandatory

References

Frequently asked questions

What does the Container Hardening AI skill do?

Harden container images and runtime configuration. Use when building, reviewing, or auditing Containerfiles, Dockerfiles, container compose files, or Kubernetes pod security settings.

Why use Container Hardening on TypingMind?

Because you install it once and use it with any model. Container Hardening is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Container Hardening in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/RedHatProductSecurity/prodsec-skills/tree/main/ge-core/container-hardening. TypingMind reads its SKILL.md and installs it as a skill you can enable per chat.

Which AI models can use Container Hardening?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Container Hardening?

As many as you like. As long as a model supports skills, you can use Container Hardening with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Container Hardening AI skill free?

Yes. It is published on GitHub by RedHatProductSecurity under the Apache-2.0 license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇