azure-sdk-for-python: Cryptography module released 44.0.0 update on 11/27 causing issues in the use of azure-identity with error listed "GLIBC_2.33" not found in azure functions

  • Azure-identity:

Describe the bug https://github.com/pyca/cryptography/issues/12064 https://github.com/Azure/azure-sdk-for-python/issues/38721 https://pypi.org/project/cryptography/#history

Cryptography module is a subdependency of azure-identity package : identity/azure-identity/setup.py This is seeing as a failure on azure function apps due to this whenever a function app deployment is made by the user and the project for python is made using azure-identity or possibly only cryptography module with latest release version set in the requirements.txt or a subdependency. This aligns with the release update in the cryptography model above. This will be directly from the user application dependencies from the requirements.txt or subdependencies.

To Reproduce Steps to reproduce the behavior:

  1. Create and deploy python function with azure-identity as a dependency or have an existing one and redeploy code to pull latest package versions. This will lead to an exception being thrown stating: Exception: Full Exception : Exception while executing function /Functions.api —> Microsoft.Azure.WebJobs.Script.Workers.Rpc.RpcException /Result /Failure Exception /ImportError //lib/x86_64-linux-gnu/libc.so.6 /version `GLIBC_2.33’ not found (required by /home/site/wwwroot/.python_packages/lib/site-packages/cryptography/hazmat/bindings/_rust.abi3.so). Cannot find module. Please check the requirements.txt file for the missing module. For more info, please refer the troubleshooting guide /https://aka.ms/functions-modulenotfound.........................continued

Expected behavior Run without any issues using this azure-identity package

Screenshots If applicable, add screenshots to help explain your problem.

Additional context There is short term mitigation, please pin the cryptography module in your requirements.txt to the previous version 43.03 and this should resolve the issue after redeploying and rebuilding the packages. Please see the above github discussions, and please note this will be short term!!!

Updated to more accurately represent issue after more discussions have occurred!! Thank you to the below for the hard work and details!!

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 23
  • Comments: 33 (4 by maintainers)

Most upvoted comments

Hi folks, I’m one of the pyca/cryptography developers 😄

This isn’t a bug in the pyca/cryptography project. Instead it’s a confluence of several factors in the Python and Azure Functions ecosystem interacting in unfortunate ways.

I’m not an Azure user, but Azure Functions appears to have two ways of building Python environments for deployment: local and remote. Remote is recommended for deploying Linux functions because any packages containing native code need to be compatible with the deployment environment and the local host may be a different operating system or even CPU architecture.

However, when you construct an environment on a Linux host and install packages that contain native code and offer precompiled wheels pip will prioritize the highest libc version that’s compatible with the underlying distribution of the host. Previously, for glibc-based distributions pyca/cryptography shipped 2.17 (aka manylinux2014) and 2.28 compatible wheels, but with 44 we now ship 2.34 as well.

If the host running the build process (Azure Functions remote build, a GitHub Actions runner, etc) possesses a glibc 2.34 or newer then pip will download the 2.34+ compatible wheel where previously it would have fetched the 2.28+ compatible wheel. This works fine on that host, but when deployed subsequently to Azure Functions the glibc version is older (this comment suggests 2.31), which causes it to fail.

While pinning to 43.0.x is a short term workaround, it is not the correct solution. pyca/cryptography is one of the earlier projects to ship a 2.34 wheel, but usage will only expand in the next year.

Azure has a few possible improvement paths here:

  • Improved build process tooling that allows more useful specification of glibc version requirements that can be mapped to manylinux tags. (e.g., I will be deploying in a 2.31 environment so only download wheels compatible with that).
    • This is the best long term path as it can prevent future recurrence of this problem, although it will also require users have some reasonable mechanism to determine what the runtime environment requirements are.
  • Updating the Azure Functions runtime environment more often to ensure newer glibc versions are available.
    • This is a good idea anyway, but will only reliably prevent the problem if you ensure you never fall behind the highest version shipped by manylinux. (Side note, these docker images are a convenience function and not required to produce wheels for newer glibc versions, but in practice the entire community uses the manylinux project’s images).
  • Changing documentation to require passing --platform manylinux_2_17_x86_64 as part of pip invocations.
    • This is a short term fix as all specific glibc manylinux versions are eventually deprecated and removed. If you choose to do this you’ll need to both consistently update the documentation and also deal with users reporting failures as older manylinux versions are retired by various projects.

This issue needs to be reopened, as the underlying issue still has not been resolved.

I jumped on the bridge with the App Services team to discuss what’s going on. A new version of the Python cryptography library, which is a floated dependency of the azure-identity python library has introduced a bug that breaks DefaultAzureCredential. The break is broader than that though. It seems to break many imports from the azure-identity module.

from azure.identity import ClientSecretCredential from azure.identity import ManagedIdentityCredential

They reached out to the Azure SDK team to consider re-releasing an update to the azure-identity library where it pins to version 43.0.3 of the cryptography library dependency.

Open questions to help guide the severity of this situation:

  • Is this only reproducible inside Azure Functions?
  • What other environments is this failing in (so far only reported in Functions production environment)?
    • They do not yet have a local repro
  • How many customers are affected? Or reporting the problem?

Python 3.12 runtime is supposed to be shipped soon, maybe still in 2024; https://github.com/Azure/azure-functions-python-worker/issues/1397#issuecomment-2489460326. 🤞

Add us to the list of customers also having this issue.

(I’m one of the pyca/cryptography devs)

Yes, 44.0.1 ships the newer manylinux wheel again, which is what triggers this issue (see my earlier comment for details). We pulled the wheel on 44.0.0 for an unrelated issue, but we’ll be shipping it on everything going forward.

Seeing as there is a vulnerability in cryptography < 44.0.1, pinning the cryptography package version to 43.0.3 does not seem like a good option anymore. Is there any progress on this issue? Due to dependabot our package version of cryptography was bumped to 44.0.1 which causes the function app to break again.

I think that vulnerability was resolved in 44.0.1, so the vulnerability won’t be present in 44.0.3.

Yes the issue is indeed resolved in 44.0.1, and the general consensus to fix the issue in this thread is to pin to 43.0.3 (not 44.0.3). This means you pin cryptography to a vulnerable version.

Seeing as there is a vulnerability in cryptography < 44.0.1, pinning the cryptography package version to 43.0.3 does not seem like a good option anymore. Is there any progress on this issue? Due to dependabot our package version of cryptography was bumped to 44.0.1 which causes the function app to break again.

I believe longer term solutions are still being investigated by the App Service/Functions team. The cryptography dependency won’t be pinned in the azure-identity package, since this is an issue specific to App Service/Functions. In the meantime, some of the mitigation options covered are:

  1. Try Remote Build for Azure Functions
  2. If using Local Build, can try using Ubuntu 20.04 or any Debian 11 based image when doing a zip-deploy.
  3. For those using Azure Pipelines or GitHub Actions for building, can use an older action image:
    • For Azure Pipelines, can change the vmImage tag from ubuntu-latest to ubuntu-20.04 in your yaml file. See here.
    • For GH Actions, can change the runs-on tag from ubuntu-latest to ubuntu-20.04 in your yaml file. See here.
  4. In your app requirements.txt file, pin the cryptography dependency by adding a line like: cryptography==43.0.3.

And, as suggested in previous comments, changing pip commands to include something like --platform manylinux_2_17_x86_64/--platform manylinux_2_28_x86_64 is also an option to ensure that the wheel downloaded on the build machine is compatible with the runtime machine.

If anyone has an idea why pinning cryptography 43.0.3 doesn’t work for me or what I might be doing wrong, I’m all ears.

Not sure why pinning cryptography isn’t working for you since 43.0.3 would have downloaded the version compatible with glibc 2.28+. Are your seeing the exact same issue as described in the original post where cryptography is the originator of the error? /ImportError //lib/x86_64-linux-gnu/libc.so.6 /version 'GLIBC_2.33' not found (required by /home/site/wwwroot/.python_packages/lib/site-packages/cryptography/hazmat/bindings/_rust.abi3.so). Cannot find module. If so, seems like 44.0.0 might still be getting downloaded and used on the runtime environment somehow?

I ran into this as well, and for some reason, pinning cryptography to 43.0.3 didn’t work for me, it still tries to find use GLIBC_2.33 and raises an import error.

Build machine: ubuntu 22.04, which as indicated by this comment comes with libc 2.35 Azure Function on Debian 11 (bullseye), which comes with libc 2.31 according to https://packages.debian.org/bullseye/libc6 and checked on the host machine with ldd --version

I don’t know the specifics, and in my previous builds 43.0.3 worked fine, but this time it didn’t anymore. I could understand that pinning cryptography 43.0.3 doesn’t work, since the build and host machines still have different libc versions, but why it does in fact work for others and not for me, or why it used to work for me in the past as well, I don’t understand.

I tried seeing if Azure Functions already supports Debian 12 with libc 2.35, but If I read this correctly, that comes with Python 3.12, which in the comment that @chopeen mentions comes in January 2025.

In the end, I figured I’d downgrade the build machine to ubuntu 20.04, which also has libc 2.31, so that the build and host machines have a matching libc version. This seems to have worked for me as a workaround.

If anyone has an idea why pinning cryptography 43.0.3 doesn’t work for me or what I might be doing wrong, I’m all ears.

We had the same issue with GLIBC_2.33 silent error with python 3.11, and pinned the version of cryptography to 43.0.3

I think it strikes back now with

ModuleNotFoundError: No module named '_cffi_backend'
from cryptography.hazmat.bindings._rust import openssl as rust_openssl
File "/home/site/wwwroot/cryptography/hazmat/primitives/ciphers/base.py", line 10, in <module>
from cryptography.hazmat.primitives.ciphers.base import (
File "/home/site/wwwroot/cryptography/hazmat/primitives/ciphers/__init__.py", line 11, in <module>
from cryptography.hazmat.primitives.ciphers import Cipher
File "/home/site/wwwroot/azure/storage/queue/_encryption.py", line 23, in <module>
from ._encryption import modify_user_agent_for_encryption, StorageEncryptionMixin
File "/home/site/wwwroot/azure/storage/queue/_queue_client.py", line 21, in <module>
from ._queue_client import QueueClient
from azure.storage.queue import QueueClient, QueueServiceClient

Did a quick test by deploying our application ubuntu-latest and upgraded to function app to python 3.12 and it seems to be working fine so far.