DirectorySecurity AdvisoriesPricing
Sign in
Directory
python-fips logoFIPS

python-fips

packaged by Chainguard

Last changed
Request a free trial

Contact our team to test out this image for free. Please also indicate any other images you would like to evaluate.

Tags
Overview
Comparison
Provenance
Specifications
SBOM
Vulnerabilities
Advisories

Chainguard Container for python-fips

Chainguard Containers are regularly-updated, secure-by-default container images.

Download this Container Image

For those with access, this container image is available on cgr.dev:

docker pull cgr.dev/ORGANIZATION/python-fips:latest

Be sure to replace the ORGANIZATION placeholder with the name used for your organization's private repository within the Chainguard Registry.

Description

The python-fips Chainguard Image provides a FIPS-enabled Python runtime suitable for workloads such as web applications, CLI utilities, interfacing with APIs, or other tasks.

Compatibility Notes

Where possible, the python-fips Chainguard Image is built for compatibility with the Docker official image for Python.

The python-fips Chainguard Image ships with a validated redistribution of the OpenSSL's FIPS provider module. For more on FIPS support in Chainguard Images, consult the guide on FIPS-enabled Chainguard Images on Chainguard Academy

By default, the python-fips Chainguard Image runs as a non-root user. You may need to use USER root to perform tasks requiring elevated privileges.

The entrypoint for the python Chainguard Image is /usr/bin/python. Commands run as part of docker run or a CMD statement in a Dockerfile will be passed as arguments to python.

Variants

We have two image variants available:

  • A python-fips:latest-dev variant that contains the pip and apk package managers and the bash, ash, and sh shells.
  • A minimal runtime variant that does not contain shells and package managers for additional security.

To pull the minimal runtime variant from cgr.dev:

docker pull cgr.dev/ORGANIZATION/python-fips:latest

To pull the dev variant:

docker pull cgr.dev/ORGANIZATION/python-fips:latest-dev

Getting Started

Example: Check that Python SSL module is in FIPS mode

Internal _hashlib module exposes the result of EVP_default_properties_is_fips_enabled

>>> import _hashlib
>>> _hashlib.get_fips_mode()
1

Example: Check that HMAC-SHA256 works with long keys

>>> import hmac
>>> hmac.digest(b'14charslongkey', b'', "SHA256").hex()
'0db994567d50545ac5a44823f82aae06b1a21b99f8dd0a42b3d572b1af62f182'

Example: Check that HMAC-SHA245 blocked with short keys

>>> import hmac
>>> hmac.digest(b'shortkey', b'', "SHA256").hex()
Traceback (most recent call last):
  File "<python-input-14>", line 1, in <module>
    hmac.digest(b'shortkey', b'', "SHA256").hex()
    ~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.14/hmac.py", line 241, in digest
    return _hashopenssl.hmac_digest(key, msg, digest)
           ~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^
ValueError: [Provider routines] invalid key length

Example: Check that HMAC-MD5 is blocked

>>> import hmac
>>> hmac.digest(b'14charslongkey', b'', "MD5").hex()
Traceback (most recent call last):
  File "<python-input-15>", line 1, in <module>
    hmac.digest(b'14charslongkey', b'', "MD5").hex()
    ~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.14/hmac.py", line 241, in digest
    return _hashopenssl.hmac_digest(key, msg, digest)
           ~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^
ValueError: [digital envelope routines] unsupported

Example: Check that HMAC-SHA1 is blocked (starting v3.6 provider)

With Chainguard FIPS Provider for OpenSSL 3.4 and earlier, HMAC-SHA1 is allowed:

>>> import hmac
>>> hmac.digest(b'14charslongkey', b'', "SHA1").hex()
'208fed94a3b6c7d76b9c583fc62fa257c97efbee'

Starting with Chainguard FIPS Provider for OpenSSL 3.6, HMAC-SHA1 will be blocked:

>>> import hmac
>>> hmac.digest(b'14charslongkey', b'', "SHA1").hex()
Traceback (most recent call last):
  File "<python-input-1>", line 1, in <module>
    hmac.digest(b'14charslongkey', b'', "SHA1").hex()
    ~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.14/hmac.py", line 241, in digest
    return _hashopenssl.hmac_digest(key, msg, digest)
           ~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^
ValueError: [digital envelope routines] unsupported

Example: Check that MD5 digest is allowed for non-security purposes

MD5 digest is available for non-security purposes such as non-cryptographically secure CRC checks. This enables using Chainguard Python FIPS images to process PDF files; compute document identifiers in the US Justice system; enables multi-part uploads to all public cloud storage bucket providers such as AWS S3, Azure, Cloudflare R2, Google Cloud Storage and similar.

>>> hashlib.md5(b"").digest().hex()
'd41d8cd98f00b204e9800998ecf8427e'

Example: Minimal CLI Application

The following provides an example of a CLI application that does not require additional Python dependencies.

First, create a project folder for the example and change the working directory to that folder:

mkdir -p ~/python-cli && cd $_

Next, create the Python script:

cat << 'EOF' > app.py
from sys import argv

if len(argv) < 2:
    print("Hello, Linky! 🐙")
else:
    print(f"Hello, {argv[1]}!")
EOF

Create a Dockerfile for our image build:

cat << EOF > Dockerfile
FROM cgr.dev/ORGANIZATION/python-fips:latest

WORKDIR /cli-app

COPY app.py .

ENTRYPOINT [ "python", "app.py"]
EOF

Make sure to replace the value of the ORGANIZATION placeholder with the name of your organization.

Build the image:

docker build . -t python-cli

Run the container with the following:

docker run python-cli

You should see the following output:

Hello, Linky! 🐙

You can also run the CLI application with an argument:

docker run python-cli "FIPS-Compliant Chainguard User"

Example: Web Application with Multi-Stage Build

If you require additional packages that can be installed with the pip package manager, we recommend using a multistage build. This process involves installing packages in a virtual environment using the latest-dev variant, then copying this environment over to the minimal runtime image. The following example uses a multi-stage build to install packages necessary to run a Flask web application.

First, create a project folder for the example:

mkdir -p ~/python-web-app && cd $_

Next, create the script for our Flask web application:

cat << 'EOF' > app.py
from flask import Flask

app = Flask(__name__)

@app.route('/')
def index():
    """Example index page."""
    octopuses = '🐙' * 10
    return f'<h1>Linky Is Best</h1><p>{octopuses}</p>'


if __name__ == "__main__":
    app.run(debug=True)
EOF

Next, create a requirements.txt file listing dependencies:

cat << 'EOF' > requirements.txt
Flask
gunicorn
EOF

Finally, let's create a Dockerfile for our image build:

cat << EOF > Dockerfile
FROM cgr.dev/ORGANIZATION/python-fips:latest-dev AS dev

WORKDIR /flask-app

RUN python -m venv venv
ENV PATH="/flask-app/venv/bin":$PATH
COPY requirements.txt requirements.txt
RUN pip install -r requirements.txt

FROM cgr.dev/ORGANIZATION/python-fips:latest

WORKDIR /flask-app

COPY app.py app.py
COPY --from=dev /flask-app/venv /flask-app/venv
ENV PATH="/flask-app/venv/bin:$PATH"

EXPOSE 8000

ENTRYPOINT ["python", "-m", "gunicorn", "-b", "0.0.0.0:8000", "app:app"]
EOF

Again, make sure to replace the value of the ORGANIZATION placeholder variable with the name of your organization.

Build the image:

docker build . -t python-web-app

Run a container to serve the web application:

docker run -p 8000:8000 python-web-app

The application should now be accessible at http://localhost:8000/.

Chainguard Python Hardened

Chainguard's Python builds deviate from upstream Python in their TLS and hashlib defaults.

TLS

Chainguard OS doesn't support the deprecated TLS 1.1 and earlier protocol versions. However, a lot of Python software still uses the ssl.PROTOCOL_TLSv1, ssl.PROTOCOL_TLSv1_1, and ssl.PROTOCOL_TLSv1_2 constants, which at one time were the way to opt in to a secure protocol version. Stock Python compiled against Chainguard Hardened OpenSSL doesn't provide these constants, so code that references them fails with an AttributeError.

To preserve source compatibility, Chainguard patches Python to always provide the legacy constants. They're aliases of ssl.PROTOCOL_TLS, so rather than pinning an old protocol version, connections negotiate TLS 1.3, or TLS 1.2 with peers that don't support TLS 1.3:

>>> import ssl
>>> ssl.PROTOCOL_TLSv1_1 is ssl.PROTOCOL_TLS
True
>>> ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1_1)
>>> ctx.minimum_version, ctx.maximum_version
(<TLSVersion.TLSv1_2: 771>, <TLSVersion.TLSv1_3: 772>)

For the full list of protocol versions and ciphers available by default and as opt-ins, see OpenSSL 4.0 in Chainguard OS.

hashlib

The Python hashlib module offers many digests. Some of them, such as MD5 and SHA-1, are considered weak, but all of them are available by default. Each digest constructor accepts an optional usedforsecurity keyword argument, which defaults to True.

Chainguard provides a set of python-hardened packages that block weak digests at different levels when they're used for security purposes. Add one of these packages to the image with Custom Assembly to enforce the hash digest policy appropriate for your organization. The packages conflict with each other, so install only one.

Package to addmd5sha1sha224sha256sha384

None (default)

✅

✅

✅

✅

✅

python-hardened-md5

🚫

✅

✅

✅

✅

python-hardened-sha1

🚫

🚫

✅

✅

✅

python-hardened-sha224

🚫

🚫

🚫

✅

✅

python-hardened-sha256

🚫

🚫

🚫

🚫

✅

✅ allowed, 🚫 blocked unless called with usedforsecurity=False.

Blocked digests are also refused by hashlib.new(), including OpenSSL aliases such as SHA-1 and SHA2-256. HMAC (hmac.new(), hmac.HMAC, and hmac.digest()) and hashlib.pbkdf2_hmac() take no usedforsecurity argument, because any use of them is for security, so they always refuse blocked digests.

When planning for post-quantum cryptography (PQC) safety, note that quantum algorithms in theory significantly reduce the effort of attacks on hash functions. Grover's algorithm reduces the effort of a preimage attack on an n-bit digest from 2<sup>n</sup> to 2<sup>n/2</sup> operations, and the Brassard, Høyer, and Tapp (BHT) algorithm reduces the effort of a collision attack from 2<sup>n/2</sup> to 2<sup>n/3</sup> operations. Carefully evaluate the security considerations of existing digest usage in your applications.

A blocked digest raises a ValueError:

>>> import hashlib
>>> hashlib.md5(b"").hexdigest()
Traceback (most recent call last):
  ...
ValueError: Chainguard python-hardened: md5 blocked. Use `usedforsecurity=False` to access
>>> hashlib.md5(b"", usedforsecurity=False).hexdigest()
'd41d8cd98f00b204e9800998ecf8427e'

A significant portion of the Python ecosystem uses these digests for non-security purposes without declaring usedforsecurity=False. For this reason, no hardened hashlib configuration can support all Python applications. For example:

  • Cloud storage SDKs often use MD5 and SHA-1 to verify the integrity of multipart uploads.
  • pip uses SHA-224 to name the files in its cache.

Test your application with the chosen python-hardened package before deploying it to production.

FIPS digest restrictions

FIPS requires the use of approved algorithms from a validated implementation. The Chainguard FIPS Provider for OpenSSL v3.6 has removed all use of SHA-1 and SHA-224 for security purposes, and so no longer provides them at all. These restrictions apply in the python-fips image in addition to any python-hardened package.

By default, the Chainguard FIPS Allowed Provider keeps MD5, SHA-1, and SHA-224 digests available for non-security purposes. When the FIPS Allowed Provider is disabled with CHAINGUARD_LEGACY_ALLOWED=0, those digests are unavailable, including when called with usedforsecurity=False:

FIPS providerFIPS Allowed Providermd5sha1sha224sha256sha384

v3.4 (default)

Enabled (default)

✅

✅

✅

✅

✅

v3.4 (default)

Disabled

❌

✅

✅

✅

✅

v3.6

Enabled (default)

✅

✅

✅

✅

✅

v3.6

Disabled

❌

❌

❌

✅

✅

✅ available, ❌ unavailable, including with usedforsecurity=False.

With the v3.6 provider, pip isn't operational without the FIPS Allowed Provider, because it uses SHA-224 for its cache files. Passing --no-cache-dir doesn't avoid this, and python -m venv fails too, because it runs pip to install itself into the new environment.

HMAC and hashlib.pbkdf2_hmac() are always for security purposes, so the FIPS Allowed Provider doesn't affect them. HMAC-MD5 is always blocked, and with the v3.6 provider HMAC-SHA1 and HMAC-SHA224 are always blocked too:

FIPS providermd5sha1sha224sha256sha384

v3.4 (default)

❌

✅

✅

✅

✅

v3.6

❌

❌

❌

✅

✅

Approved HMAC usage also requires keys of at least 112 bits (14 bytes, or 14 ASCII characters). HMAC with a shorter key is always blocked, regardless of the digest, so even HMAC-SHA384 fails with a short key:

>>> import hmac
>>> hmac.new(b"shortkey", b"msg", "sha384").hexdigest()
Traceback (most recent call last):
  ...
ValueError: [Provider routines] invalid key length
>>> hmac.new(b"14charslongkey", b"msg", "sha384").hexdigest()[:16]
'95cd324add1d55f2'

Installing a python-hardened package or disabling the FIPS Allowed Provider isn't required to comply with any framework. All insecure use of these digests and algorithms is blocked, and they're unavailable to the algorithms running inside the FIPS provider boundary. For more guidance, see FIPS and non-approved algorithms.

To opt in to the Chainguard FIPS Provider for OpenSSL v3.6, set OPENSSL_CONF_INCLUDE=/etc/ssl-3.6.0:

docker run --rm -e OPENSSL_CONF_INCLUDE=/etc/ssl-3.6.0 -e CHAINGUARD_LEGACY_ALLOWED=0 \
  cgr.dev/ORGANIZATION/python-fips:latest -c 'import hashlib; hashlib.sha1(usedforsecurity=False)'
...
ValueError: unsupported hash algorithm sha1

Documentation and Resources

What are Chainguard Containers?

Chainguard's free tier of Starter container images are built with Wolfi, our minimal Linux undistro.

All other Chainguard Containers are built with Chainguard OS, Chainguard's minimal Linux operating system designed to produce container images that meet the requirements of a more secure software supply chain.

The main features of Chainguard Containers include:

For cases where you need container images with shells and package managers to build or debug, most Chainguard Containers come paired with a development, or -dev, variant.

In all other cases, including Chainguard Containers tagged as :latest or with a specific version number, the container images include only an open-source application and its runtime dependencies. These minimal container images typically do not contain a shell or package manager.

Although the -dev container image variants have similar security features as their more minimal versions, they include additional software that is typically not necessary in production environments. We recommend using multi-stage builds to copy artifacts from the -dev variant into a more minimal production image.

Need additional packages?

To improve security, Chainguard Containers include only essential dependencies. Need more packages? Chainguard customers can use Custom Assembly to add packages, either through the Console, chainctl, or API.

To use Custom Assembly in the Chainguard Console: navigate to the image you'd like to customize in your Organization's list of images, and click on the Customize image button at the top of the page.

Learn More

Refer to our Chainguard Containers documentation on Chainguard Academy. Chainguard also offers VMs and Libraries — contact us for access.

Trademarks

This software listing is packaged by Chainguard. The trademarks set forth in this offering are owned by their respective companies, and use of them does not imply any affiliation, sponsorship, or endorsement by such companies.

Licenses

Chainguard's container images contain software packages that are direct or transitive dependencies. The following licenses were found in the "latest" tag of this image:

  • Apache-2.0

  • BSD-1-Clause

  • BSD-2-Clause

  • BSD-3-Clause

  • BSD-4-Clause-UC

  • CC-PDDC

  • GCC-exception-3.1

For a complete list of licenses, please refer to this Image's SBOM.

Software license agreement

Compliance

Chainguard Containers are SLSA Level 3 compliant with detailed metadata and documentation about how it was built. We generate build provenance and a Software Bill of Materials (SBOM) for each release, with complete visibility into the software supply chain.

SLSA compliance at Chainguard

This image helps reduce time and effort in establishing PCI DSS 4.0 compliance with low-to-no CVEs.

PCI DSS at Chainguard

This is a FIPS validated image for FedRAMP compliance.

This image is STIG hardened and scanned against the DISA General Purpose Operating System SRG with reports available.

Learn more about STIGsGet started with STIGs

Image contains multiple maintained release tracks and is eligible for end of life support.


Related images
python logo

python


Category
Featured
FIPS
STIG

The trusted source for open source

Talk to an expert
PrivacyTerms

Product

Chainguard ContainersChainguard LibrariesChainguard VMsChainguard OS PackagesChainguard ActionsChainguard Agent SkillsIntegrationsPricing
© 2026 Chainguard, Inc. All Rights Reserved.
Chainguard® and the Chainguard logo are registered trademarks of Chainguard, Inc. in the United States and/or other countries.
The other respective trademarks mentioned on this page are owned by the respective companies and use of them does not imply any affiliation or endorsement.