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:
- 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)
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
pipwill 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
pipwill 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:
manylinuxproject’s images).--platform manylinux_2_17_x86_64as part ofpipinvocations.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.
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.3of the cryptography library dependency.Open questions to help guide the severity of this situation:
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.
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
cryptographydependency won’t be pinned in theazure-identitypackage, since this is an issue specific to App Service/Functions. In the meantime, some of the mitigation options covered are:vmImagetag fromubuntu-latesttoubuntu-20.04in your yaml file. See here.runs-ontag fromubuntu-latesttoubuntu-20.04in your yaml file. See here.requirements.txtfile, pin thecryptographydependency by adding a line like:cryptography==43.0.3.And, as suggested in previous comments, changing
pipcommands to include something like--platform manylinux_2_17_x86_64/--platform manylinux_2_28_x86_64is also an option to ensure that the wheel downloaded on the build machine is compatible with the runtime machine.Not sure why pinning
cryptographyisn’t working for you since43.0.3would have downloaded the version compatible with glibc 2.28+. Are your seeing the exact same issue as described in the original post wherecryptographyis 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 like44.0.0might 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 --versionI 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
Did a quick test by deploying our application
ubuntu-latestand upgraded to function app topython 3.12and it seems to be working fine so far.