Repository navigation
Description
Are you using paramiko as a client or server?
Exception handling
What feature(s) aren't working right?
Something else
What version(s) of paramiko are you using?
5.0.1; 5.1.0 is where the issue arises and only in FIPS mode.
What version(s) of Python are you using?
3.13.17
What operating system and version are you using?
Wolfi Linux in a Docker container (linux/arm64), based on cgr.dev/chainguard/wolfi-base.
If you're connecting as a client, which SSH server are you connecting to?
No response
If you're using paramiko as part of another tool, which tool/version?
No response
Expected/desired behavior
Import should succeed when an optional key-exchange algorithm is unavailable in the configured provider. The unavailable algorithm should be excluded from supported/preferred key exchanges.
Environment
- Python: 3.13.17
- Paramiko: 5.1.0
- cryptography: 50.0.2
- OpenSSL used by cryptography: 4.0.3
- FIPS provider: OpenSSL 3.4.0, built from source
- Platform: Chainguard/Wolfi Linux container, arm64
- Active providers: base and fips
- Default properties: fips=yes
- backend._fips_enabled: True
Actual behavior
Paramiko 5.1.0 fails on import paramiko when the configured FIPS provider does not implement ML-KEM. This happens before any SSH connection is attempted.
KexMLKEM768X25519.is_available() attempts ML-KEM key generation and catches UnsupportedAlgorithm. In this environment, the unsupported algorithm instead produces cryptography.exceptions.InternalError, which escapes and aborts the import.
The import fails through this call chain:
Transport class initialization
-> KexMLKEM768X25519.is_available()
-> mlkem.MLKEM768PrivateKey.generate()
-> cryptography.exceptions.InternalError
The OpenSSL error identifies the unsupported algorithm:
error:0308010C:digital envelope routines:inner_evp_generic_fetch:unsupported:
crypto/evp/evp_fetch.c:376:Global default library context,
Algorithm (ML-KEM-768 : 0), Properties (<null>)
How to reproduce
Using this Dockerfile
FROM cgr.dev/chainguard/wolfi-base:latest@sha256:88a20e2d017bd20cdc0cb3910de603e7bea9512a6c351a8dd3c9df212ab03d73
RUN apk add --no-cache \
openssl-4.0=4.0.3-r8 py3.13-cryptography=50.0.2-r4 py3.13-pip \
curl gcc glibc-dev make perl
RUN python3.13 -m pip install --break-system-packages --no-cache-dir paramiko==5.1.0
WORKDIR /repro
RUN curl --proto '=https' --tlsv1.2 -fsSL \
https://github.com/openssl/openssl/releases/download/openssl-3.4.0/openssl-3.4.0.tar.gz \
-o openssl.tar.gz \
&& echo 'e15dda82fe2fe8139dc2ac21a36d4ca01d5313c75f99f46c4e8a27709b7294bf openssl.tar.gz' | sha256sum -c - \
&& tar -xf openssl.tar.gz \
&& cd openssl-3.4.0 \
&& ./Configure enable-fips \
&& make -s -j4 build_generated \
&& make -s -j4 providers/fips.so \
&& cp providers/fips.so /repro/fips.so \
&& openssl fipsinstall -module /repro/fips.so -out /repro/fipsmodule.cnf
COPY <<EOF /repro/openssl.cnf
config_diagnostics = 1
openssl_conf = openssl_init
.include /repro/fipsmodule.cnf
[openssl_init]
providers = providers
alg_section = algorithms
[providers]
base = base
fips = fips_sect
[base]
activate = 1
[fips_sect]
module = /repro/fips.so
[algorithms]
default_properties = fips=yes
EOF
ENV OPENSSL_CONF=/repro/openssl.cnf CRYPTOGRAPHY_OPENSSL_NO_LEGACY=1
CMD ["python3.13", "-c", "import paramiko"]
Run:
docker build -t paramiko-fips-repro .
docker run --rm --network none paramiko-fips-reproWhen tested with the same cryptography and OpenSSL versions here are the results:
| Paramiko | FIPS active | Import result |
|---|---|---|
| 4.0.0 | Yes | Succeeds |
| 5.0.0 | Yes | Succeeds |
| 5.0.1 | Yes | Succeeds |
| 5.1.0 | Yes | Fails |
| 5.1.0 | No | Succeeds |
Anything else?
#2442 and #2443 describe a similar FIPS import failure in the X25519 availability check. This report concerns the ML-KEM check introduced by #2668.
Activity
hamarshehmhmd commentedon Oct 30, 2026
(Drafted with an AI assistant, reviewed by me.)
I could reproduce the same failure without a FIPS module build. With cryptography 50.0.2 (OpenSSL 4.0.3) I used an
OPENSSL_CONFthat loads only the default provider and setsdefault_properties = fips=yes, so every fetch fails inside OpenSSL. Under that config,X25519PrivateKey.generate()raisesUnsupportedAlgorithm, whichKexCurve25519.is_available()already catches.MLKEM768PrivateKey.generate()raisescryptography.exceptions.InternalErrorinstead, andKexMLKEM768X25519.is_available()only catchesUnsupportedAlgorithm. BecauseTransportcallsis_available()in its class body, the error is raised whileimport paramikois still running.My config isn't your exact setup. In mine the fetch that fails is the DRBG, not ML-KEM-768. But the exception type and the path through paramiko are the same.
Treating
InternalErroras "not available" in that check fixes it:Output from paramiko 5.1.0 with that config, before and after the patch, and then with the patch under the normal config:
So with the patch, ML-KEM is simply dropped when the provider can't do it, and nothing changes when it can. I don't know of a user-side monkeypatch here, because the check runs while
paramikoitself is being imported. Until this is fixed, pinningparamiko<5.1(5.0.1 in your table) is the simplest workaround.seth-tines commentedon Oct 30, 2026
ah, thanks for looking into this - will be following along for the patch to land.