Container Content

You are viewing documentation for a release that is no longer supported. The latest supported version of version 3 is [3.11]. For the most recent version 4, see [4]

You are viewing documentation for a release that is no longer supported. The latest supported version of version 3 is [3.11]. For the most recent version 4, see [4]

Security Inside the Container

Applications and infrastructures are composed of readily available components, many of which are open source packages such as, the Linux operating system, JBoss Web Server, PostgreSQL, and Node.js.

Containerized versions of these packages are also available. However, you need to know where the packages originally came from, who built them, and whether there is any malicious code inside them.

Some questions to answer include:

  • Will what is inside the containers compromise your infrastructure?

  • Are there known vulnerabilities in the application layer?

  • Are the runtime and OS layers current?

Further Reading

  • OKD Using Images

    • Reference documentation on framework, database, and service container images provided by Red Hat for use on OKD

Container Content Scanning

Container scanning tools can leverage continuously updated vulnerability databases to ensure that you always have the latest information on known vulnerabilities for your container content. The list of known vulnerabilities constantly evolves; you must check the contents of your container images when you first download them and continue to track vulnerability status over time for all of your approved and deployed images.

RHEL provides a pluggable API to support multiple scanners. You can also use Red Hat CloudForms with OpenSCAP to scan container images for security issues. See the Red Hat Enterprise Linux Security Guide for general information on OpenSCAP in RHEL, and the Red Hat CloudForms Policies and Profiles Guide for specifics on OpenSCAP integration.

OKD enables you to leverage such scanners with your CI/CD process. For example, you can integrate static code analysis tools that test for security flaws in your source code and software composition analysis tools that identify open source libraries in order to provide metadata on those libraries such as known vulnerabilities. This is covered in more detail in Build Process.

Integrating External Scanning Tools with OpenShift

OKD makes use of object annotations to extend functionality. External tools, such as vulnerability scanners, may annotate image objects with metadata to summarize results and control pod execution. This section describes the recognized format of this annotation so it may be reliably used in consoles to display useful data to users.

Image Metadata

There are different types of image quality data, including package vulnerabilities and open source software (OSS) license compliance. Additionally, there may be more than one provider of this metadata. To that end, the following annotation format has been reserved:

  1. quality.images.openshift.io/<qualityType>.<providerId>: {}
Table 1. Annotation Key Format
ComponentDescriptionAcceptable Values

qualityType

Metadata type

vulnerability
license
operations
policy

providerId

Provider ID string

openscap
redhatcatalog
redhatinsights
blackduck
jfrog

Example Annotation Keys

  1. quality.images.openshift.io/vulnerability.blackduck: {}
  2. quality.images.openshift.io/vulnerability.jfrog: {}
  3. quality.images.openshift.io/license.blackduck: {}
  4. quality.images.openshift.io/vulnerability.openscap: {}

The value of the image quality annotation is structured data that must adhere to the following format:

Table 2. Annotation Value Format
FieldRequired?DescriptionType

name

Yes

Provider display name

String

timestamp

Yes

Scan timestamp

String

description

No

Short description

String

reference

Yes

URL of information source and/or more details. Required so user may validate the data.

String

scannerVersion

No

Scanner version

String

compliant

No

Compliance pass/fail

Boolean

summary

No

Summary of issues found

List (see table below)

The summary field must adhere to the following format:

Table 3. Summary Field Value Format
FieldDescriptionType

label

Display label for component (for example, “critical,” “important,” “moderate,” “low,” or “health”)

String

data

Data for this component (for example, count of vulnerabilities found or score)

String

severityIndex

Component index allowing for ordering and assigning graphical representation. The value is range 0..3 where 0 = low.

Integer

reference

URL of information source and/or more details. Optional.

String

Example Annotation Values

This example shows an OpenSCAP annotation for an image with vulnerability summary data and a compliance boolean:

OpenSCAP Annotation

  1. {
  2. "name": "OpenSCAP",
  3. "description": "OpenSCAP vulnerability score",
  4. "timestamp": "2016-09-08T05:04:46Z",
  5. "reference": "https://www.open-scap.org/930492",
  6. "compliant": true,
  7. "scannerVersion": "1.2",
  8. "summary": [
  9. { "label": "critical", "data": "4", "severityIndex": 3, "reference": null },
  10. { "label": "important", "data": "12", "severityIndex": 2, "reference": null },
  11. { "label": "moderate", "data": "8", "severityIndex": 1, "reference": null },
  12. { "label": "low", "data": "26", "severityIndex": 0, "reference": null }
  13. ]
  14. }

This example shows a Red Hat Container Catalog annotation for an image with health index data with an external URL for additional details:

Red Hat Container Catalog Annotation

  1. {
  2. "name": "Red Hat Container Catalog",
  3. "description": "Container health index",
  4. "timestamp": "2016-09-08T05:04:46Z",
  5. "reference": "https://access.redhat.com/errata/RHBA-2016:1566",
  6. "compliant": null,
  7. "scannerVersion": "1.2",
  8. "summary": [
  9. { "label": "Health index", "data": "B", "severityIndex": 1, "reference": null }
  10. ]
  11. }

Annotating Image Objects

While image stream objects are what an end-user of OKD operates against, image objects are annotated with security metadata. Image objects are cluster-scoped, pointing to a single image that may be referenced by many image streams and tags.

Example Annotate CLI Command

Replace <image> with an image digest, for example sha256:fec8a395afe3e804b3db5cb277869142d2b5c561ebb517585566e160ff321988:

  1. $ oc annotate image <image> \
  2. quality.images.openshift.io/vulnerability.redhatcatalog='{ \
  3. "name": "Red Hat Container Catalog", \
  4. "description": "Container health index", \
  5. "timestamp": "2016-09-08T05:04:46Z", \
  6. "compliant": null, \
  7. "scannerVersion": "1.2", \
  8. "reference": "https://access.redhat.com/errata/RHBA-2016:1566", \
  9. "summary": "[ \
  10. { "label": "Health index", "data": "B", "severityIndex": 1, "reference": null } ]" }'

Controlling Pod Execution

To programmatically control if an image may be run, the images.openshift.io/deny-execution image policy may be used. See Image Policy for more information.

Example Annotation

  1. annotations:
  2. images.openshift.io/deny-execution: true

Integration Reference

In most cases, external tools such as vulnerability scanners will develop a script or plug-in that watches for image updates, performs scanning, and annotates the associated image object with the results. Typically this automation calls the OKD REST API to write the annotation. See REST API Reference for general information on the REST API and PATCH call to update images.

Example REST API Call

The following example call using curl overrides the value of the annotation. Be sure to replace the values for <token>, <openshift_server>, <image_id>, and <image_annotation>.

Patch API Call

  1. $ curl -X PATCH \
  2. -H "Authorization: Bearer <token>" \
  3. -H "Content-Type: application/merge-patch+json" \
  4. https://<openshift_server>:8443/oapi/v1/images/<image_id> \
  5. --data '{ <image_annotation> }'

The following is an example of PATCH payload data:

Patch Call Data

  1. {
  2. "metadata": {
  3. "annotations": {
  4. "quality.images.openshift.io/vulnerability.redhatcatalog":
  5. "{ 'name': 'Red Hat Container Catalog', 'description': 'Container health index', 'timestamp': '2016-09-08T05:04:46Z', 'compliant': null, 'reference': 'https://access.redhat.com/errata/RHBA-2016:1566', 'summary': [{'label': 'Health index', 'data': '4', 'severityIndex': 1, 'reference': null}] }"
  6. }
  7. }
  8. }

Due to the complexity of this API call and challenges with escaping characters, an API developer tool such as Postman may assist in creating API calls.