> ## Documentation Index
> Fetch the complete documentation index at: https://docs.minimus.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Security Technical Implementation Guides (STIG)

> About STIG guidelines for enhanced security and how to verify them in Minimus images using the Minimus OpenSCAP image

Minimus offers hardened images following STIG guidelines for enhanced security. STIGs are Security Technical Implementation Guides published by the Defense Information Systems Agency (DISA).

You can filter for STIG compliant containers in the Minimus gallery.

## Verify Security Content Automation Protocol (SCAP)

[OpenSCAP tools](https://www.open-scap.org/tools/) are the recommended toolset for validating the configuration of container images and reviewing the configuration of an image file system. For ease of use, Minimus provides a hardened [OpenSCAP image](https://images.minimus.io/gallery/images/openscap/quick-start) that always includes the most up-to-date package version for all of the included packages and dependencies.

Use the Minimus OpenSCAP image to scan your Docker images and containers without the need to install OpenSCAP locally. This image comes preloaded with a Minimus STIG file for security and compliance assessments.

## How to verify STIG compliance for Minimus images

To test the Minimus OpenSCAP image, follow the steps below to scan an image using its file system.

<Warning>
  Docker runtime is required as a pre-requisite for running the Minimus OpenSCAP docker image.
</Warning>

<Steps>
  <Step title="Download OpenSCAP from Minimus">
    Authenticate to the Minimus registry with your token. [Visit the token page](https://images.minimus.io/manage/tokens) in your Minimus console to copy the command with your embedded token:

    ```bash example of docker login command theme={null}
    docker login reg.mini.dev -u minimus -p mini_***
    ```

    Pull the OpenSCAP latest image from the Minimus registry:

    ```bash theme={null}
    docker pull reg.mini.dev/openscap:latest
    ```
  </Step>

  <Step title="Download the Data Stream file">
    The data stream module (ds) is provided by Minimus and used to automatically validate the image or container. Download the file [ssg-minimus-gpos-ds.xml](https://raw.githubusercontent.com/minimusio/examples/main/STIG/ssg-minimus-gpos-ds.xml) from the Minimus public GitHub repo.

    To pull the file locally:

    <CodeGroup>
      ```bash curl example theme={null}
      curl -O https://raw.githubusercontent.com/minimusio/examples/main/STIG/ssg-minimus-gpos-ds.xml
      ```

      ```bash wget example theme={null}
      wget -O ssg-minimus-gpos-ds.xml https://raw.githubusercontent.com/minimusio/examples/main/STIG/ssg-minimus-gpos-ds.xml
      ```
    </CodeGroup>

    For good measure, verify the file:

    ```bash theme={null}
    docker run --user root \
      -v /var/run/docker.sock:/var/run/docker.sock \
      -v "$PWD/ssg-minimus-gpos-ds.xml:/ssg-minimus-gpos-ds.xml:ro" \
      --entrypoint "" \
      reg.mini.dev/openscap \
      /usr/bin/oscap info ssg-minimus-gpos-ds.xml
    ```

    You should see a printout of file details, beginning with `Document type: Source Data Stream` and version information.
  </Step>

  <Step title="Create a directory for the scan results">
    ```bash theme={null}
    mkdir -p "$PWD/openscap_results"
    ```

    Change the directory ownership to match the container's UID to grant the OpenSCAP container write access:

    ```bash theme={null}
    sudo chown 1000:1000 "$PWD/openscap_results"
    ```
  </Step>

  <Step title="Pull the image to be scanned">
    Pull the image you plan to scan from the Minimus registry, for example:

    ```bash theme={null}
    docker pull reg.mini.dev/nginx-fips:latest
    ```
  </Step>

  <Step title="Run the OpenSCAP scan">
    Use the oscap-docker tool to perform offline scanning from the Minimus provided image:

    <CodeGroup>
      ```bash Specific example theme={null}
      docker run --user root \
        -v "$PWD/ssg-minimus-gpos-ds.xml:/ssg-minimus-gpos-ds.xml:ro" \
        -v /var/run/docker.sock:/var/run/docker.sock \
        -v "$PWD/openscap_results:/output" \
        --entrypoint "" \
        reg.mini.dev/openscap \
        /usr/bin/oscap-docker image reg.mini.dev/nginx-fips:latest -- \
          xccdf eval \
          --profile "xccdf_basic_profile_.check" \
          --results /output/scan-results.xml \
          --report  /output/report.html \
          /ssg-minimus-gpos-ds.xml
      ```

      ```bash General command theme={null}
      docker run --user root \
        -v "$PWD/ssg-minimus-gpos-ds.xml:/ssg-minimus-gpos-ds.xml:ro" \
        -v /var/run/docker.sock:/var/run/docker.sock \
        -v "$PWD/openscap_results:/output" \
        --entrypoint "" \
        reg.mini.dev/openscap \
        /usr/bin/oscap-docker image {IMAGE_TO_SCAN} -- \
          xccdf eval \
          --profile "xccdf_basic_profile_.check" \
          --results {path to scan results in XML} \
          --report {path to scan results in HTML} \
      {path to data stream file}
      ```
    </CodeGroup>

    * `--results` indicates where to place the XML formatted report
    * `--report` indicates where to place the HTML report
    * The data stream location points to the location of the SCAP source data stream file
  </Step>

  <Step title="Interpret your results">
    The test outputs two files: An XML report and an HTML page. You can use either to review your results.
  </Step>
</Steps>

### XCCDF Format

The eXtensible Configuration Checklist Description Format is part of the SCAP standard. OpenSCAP tooling uses XCCDF to automate compliance and configuration remediation.

XCCDF STIG reports can be viewed in dedicated viewing tools endorsed by the DoD. Currently, STIG Viewer 3 is the most up to date. The relevant style sheet is bundled with the STIG. ([Link to download the STIG Viewer](https://public.cyber.mil/stigs/srg-stig-tools/).)

## Convert DISA STIG XML to other formats

You can convert DISA STIG XML reports into other formats, as required, using a popular open-source tool from MITRE. This tutorial showcases examples using the [heimdall-lite](https://saf.mitre.org/docs) utility made available by the MITRE [**<u>Security Automation Framework (SAF)</u>**](https://saf.mitre.org/). This guide explains how to run the utility as a container in order to convert a DISA STIG XML report provided by Minimus into other common formats, including JSON, CSV, HTML, DISA Checklist, etc.

MITRE Heimdall ([https://github.com/mitre/heimdall2](https://github.com/mitre/heimdall2)) is a suite of tools that provide a centralized visualization and reporting solution for automated security scan results.

### Pre-requisites

1. Scan results obtained in XML format by running the Minimus OpenSCAP image. See the [quick start guide](https://images.minimus.io/gallery/images/openscap/quick-start)
2. Container runtime environment (such as Podman or Docker)
3. Ability to pull in the heimdall-lite docker image to its execution location
4. The heimdall-lite docker image currently ships for amd64 images only. If needed, you can use emulation as a workaround for other architectures such as macOS Darwin.

### Run Heimdall Lite locally on macOS

<Steps>
  <Step title="Install Heimdall-Lite prerequisites">
    Since Heimdall Lite only ships in amd64 formats, the container image will either need to run on an x86 architecture or be passed through an emulator.

    This can be achieved on macOS Darwin by installing an emulator to pass through this image with an option such as `qemu`. `qemu` may be installed locally with Homebrew:

    ```shellscript theme={null}
    brew install qemu
    ```
  </Step>

  <Step title="Pull the container image locally">
    ```shellscript wrap theme={null}
    docker pull docker.io/mitre/heimdall-lite:release-latest --platform linux/amd64
    ```

    <Note>
      Note - this pull will fail locally on Darwin if the platform flag is not included.
    </Note>
  </Step>

  <Step title="Run the image locally">
    ```shellscript wrap theme={null}
    docker run --platform=linux/amd64 -d -p 8080:80 mitre/heimdall-lite:release-latest
    ```
  </Step>

  <Step title="Connect to the running heimdall application">
    Open your local web browser to point at `localhost:8080` (This example assumes you bound port 8080 but you should use the port you bound in the run command).

    <Frame>
      <img src="https://mintcdn.com/gutsy-6162adbc/TVk0odGyXfi5jQAc/images/heimdall-macos-connect1.png?fit=max&auto=format&n=TVk0odGyXfi5jQAc&q=85&s=00f218c0bdfb680fa6ee1b423d5e2c30" alt="Heimdall Macos Connect" width="512" height="307" data-path="images/heimdall-macos-connect1.png" />
    </Frame>
  </Step>

  <Step title="Upload XML file from OpenSCAP">
    Select **Choose files to upload** and select your XML file (that is the report generated using OpenSCAP).

    <Frame>
      <img src="https://mintcdn.com/gutsy-6162adbc/TVk0odGyXfi5jQAc/images/heimdall-local-step6-checks2.png?fit=max&auto=format&n=TVk0odGyXfi5jQAc&q=85&s=3ece37131727b28ecb04e9cbb3d9dc62" alt="Heimdall Local Step6 Checks2" width="512" height="276" data-path="images/heimdall-local-step6-checks2.png" />
    </Frame>

    <Note>
      You will see the same matching checks previously noted from running OpenSCAP.
    </Note>
  </Step>

  <Step title="Select an export format">
    You will now be able to export the report into various formats as desired by selecting the **Export** button at the top right.

    <Frame>
      <img src="https://mintcdn.com/gutsy-6162adbc/kwV4kDBOO990GKpQ/images/heimdall-local-export-darwin3.png?fit=max&auto=format&n=kwV4kDBOO990GKpQ&q=85&s=393bb90a0c3774feaf3244cd309641c5" alt="Heimdall Local Export Darwin3" width="512" height="275" data-path="images/heimdall-local-export-darwin3.png" />
    </Frame>
  </Step>
</Steps>

You can use the above process to export the report as a DISA checklist and download it locally. To do so, select the option **Export as a DISA Checklist**. You can download the resulting file when prompted.

<Frame caption="Export as a DISA checklist using Heimdall Lite">
  <img src="https://mintcdn.com/gutsy-6162adbc/TVk0odGyXfi5jQAc/images/heimdall-local-export-darwinchecks4.png?fit=max&auto=format&n=TVk0odGyXfi5jQAc&q=85&s=1ac7e457e4ca94049d9373b202c6111c" alt="Heimdall Local Export Darwinchecks4" width="972" height="721" data-path="images/heimdall-local-export-darwinchecks4.png" />
</Frame>

### Run Heimdall Lite on a Cloud VM

This example showcases running Heimdall Lite on a GCP VM but the concept is the same for other cloud providers.

<Steps>
  <Step title="Create a VM in your target cloud environment">
    Create a VM with Docker or Podman installed to execute the runtime of a container image that is x86-64 or amd64 based.
  </Step>

  <Step title="Pull the Heimdall Lite image">
    ```shellscript theme={null}
    docker pull docker.io/mitre/heimdall-lite:release-latest
    ```
  </Step>

  <Step title="Run the container image">
    ```shellscript theme={null}
    docker run -d -p 8080:80 mitre/heimdall-lite:release-latest
    ```
  </Step>

  <Step title="Create an SSH tunnel to the VM">
    To run the browser locally, you must now create an SSH tunnel to the instance and map it to the respective port the container is listening on. This can be done by using the Google Cloud CLI (`gcloud` CLI) and then authenticating to your respective project where the VM is running.

    1. Authenticate to your GCP project via CLI:

       ```shellscript theme={null}
       gcloud auth login
       ```

           <Frame>
             <img src="https://mintcdn.com/gutsy-6162adbc/kwV4kDBOO990GKpQ/images/heimdall-gcp-vm-auth-gcloud3-1.png?fit=max&auto=format&n=kwV4kDBOO990GKpQ&q=85&s=e2d7e0daf8064c36f6e6b68aa64000d0" alt="Heimdall Gcp Vm Auth Gcloud3" width="512" height="104" data-path="images/heimdall-gcp-vm-auth-gcloud3-1.png" />
           </Frame>
    2. Authenticate via web browser:

       You may need to allow permissions from GCP. If successful, you will see the same success message in your local terminal: `Your browser has been opened to visit`.

           <Frame>
             <img src="https://mintcdn.com/gutsy-6162adbc/kwV4kDBOO990GKpQ/images/heimdall-gcp-vm-allowgcppermissions4.png?fit=max&auto=format&n=kwV4kDBOO990GKpQ&q=85&s=951ba1e70baa50eb4be70c576138e788" alt="Heimdall Gcp Vm Allowgcppermissions4" width="1461" height="669" data-path="images/heimdall-gcp-vm-allowgcppermissions4.png" />
           </Frame>
    3. Create your SSH tunnel using gcloud: 

       ```shellscript wrap theme={null}
       gcloud compute ssh [VM_NAME] --project=[PROJECT_ID] --zone=[ZONE] -- -N -L [LOCAL_PORT]:localhost:[REMOTE_PORT]
       ```

       You will need to update the command with the following:

       * LOCAL\_PORT - Use the port you enter in your local browser on your machine
       * REMOTE\_PORT - Use the port the Heimdall Lite container is bound to listen on in the cloud VM.
    4. If run for the first time, you may be prompted to generate SSH keys locally. When successful, you will have an active process with this open tunnel and the cursor will be active.

           <Frame caption="Example showing SSH keys that were generated locally">
             <img src="https://mintcdn.com/gutsy-6162adbc/kwV4kDBOO990GKpQ/images/heimdall-gcp-vm-opentunnel6.png?fit=max&auto=format&n=kwV4kDBOO990GKpQ&q=85&s=2b0819810eae625acd41df0aaeee9814" alt="Heimdall Gcp Vm Opentunnel6" width="850" height="165" data-path="images/heimdall-gcp-vm-opentunnel6.png" />
           </Frame>
  </Step>

  <Step title="Access the Heimdall Lite container from your local browser">
    Access the Heimdall Lite container from your local browser by typing in `localhost:LOCAL_PORT`, for example, `localhost:9080`.

    <Frame>
      <img src="https://mintcdn.com/gutsy-6162adbc/kwV4kDBOO990GKpQ/images/heimdall-gcp-vm-connecttoheimdall7.png?fit=max&auto=format&n=kwV4kDBOO990GKpQ&q=85&s=7273ba23667033f52542e9f4890e38bd" alt="Heimdall Gcp Vm Connecttoheimdall7" width="1494" height="882" data-path="images/heimdall-gcp-vm-connecttoheimdall7.png" />
    </Frame>
  </Step>

  <Step title="Upload your XML report into Heimdall">
    <Frame>
      <img src="https://mintcdn.com/gutsy-6162adbc/kwV4kDBOO990GKpQ/images/heimdall-gcp-vm-checks8.png?fit=max&auto=format&n=kwV4kDBOO990GKpQ&q=85&s=afee7d18060d71fd6026706adb3c0579" alt="Heimdall Gcp Vm Checks8" width="1492" height="880" data-path="images/heimdall-gcp-vm-checks8.png" />
    </Frame>
  </Step>

  <Step title="Export your report to another format">
    Use the **Export** button on the top right to export your report to your format of choice.

    <Frame>
      <img src="https://mintcdn.com/gutsy-6162adbc/kwV4kDBOO990GKpQ/images/heimdall-gcp-vm-exportchecks9.png?fit=max&auto=format&n=kwV4kDBOO990GKpQ&q=85&s=99ee22cbc59d6adb9b78f30b2fefd2f8" alt="Heimdall Gcp Vm Exportchecks9" width="1499" height="804" data-path="images/heimdall-gcp-vm-exportchecks9.png" />
    </Frame>
  </Step>
</Steps>
