fix(ssl): use default SSL context for all httpx calls#11051
fix(ssl): use default SSL context for all httpx calls#11051phymbert wants to merge 3 commits intoOpenHands:mainfrom
Conversation
|
I dont think linter issues are related to the changes, tell me if you want me to fix them. |
|
Is there something missing to review this change ? I can not use openhands without these basic security fixes. Please tell me how I can help to merge it. Thanks |
# Conflicts: # openhands/utils/http_session.py
|
Hands up 🖐 |
tofarr
left a comment
There was a problem hiding this comment.
I find this a little worrisome - it essentially gives the ability to disable SSL for outbound requests, leaving the system vulnerable to a MITM attack. Have you tried adding the custom cert to certifi (Used by httpx) so that security is maintained?
I believe you must double read the code changes? |
I don't think supplying a custom cert which is checked is the same thing as allowing disabling of all checking.
I agree that the risk is opt-in, and the question is whether to include that option given there could be a more secure alternative, namely custom certs. |
|
The code adds the proper Regarding the second code changes: the option to fully disable ssl verify, all industry tools like curl, apache offer this alternative option which is of course not recommended for production. But if you feel it is so dangerous, we can add a warning message. I thought the documentation was clear enough, isn't? |
Thanks for expanding. I think we're all on board with that part of the change. Does your use case require the disable option in addition, or this is more about following the pattern of other tools? |
|
Thanks for your time on this, appreciated. I used it to debug at the beginning to be sure it was wrong httpx configuration, and I believe this is useful for other user to investigate in the future, but no, my use case is over secured, trust me ^) So if you want, we can simply get rid of this option, but I think it is worth keeping |
Summary
While testing OpenHands, I hit
SSL: CERTIFICATE_VERIFY_FAILED. Many orgs install a private root CA in the OS trust store; however, severalhttpxclients weren’t explicitly using a default SSL context.This PR ensures all
httpxcalls consistently use the expected system default SSL context. It also adds a debug-only escape hatch to disable verification via config/env vars when needed.What’s changed
Introduce
openhands.utils.http_session:httpx_verify_option()for consistentverify=acrosshttpxclients (async & sync).configure_http_session(verify=...).Introduce
insecure_skip_verifyinSecurityConfigWire default SSL behavior everywhere we create
httpxclients:Config & docs:
docs/usage/environment-variables.mdx: documentSECURITY_INSECURE_SKIP_VERIFY.Backwards compatible: by default we still verify certificates; behavior is unchanged for secure setups.
Motivation
insecure_skip_verify) helps debug TLS issues without blocking critical flows, which must not be used for production.Usage notes
SECURITY_INSECURE_SKIP_VERIFY=trueconfig.toml:Testing
SECURITY_INSECURE_SKIP_VERIFY.Security considerations
insecure_skip_verifyis explicitly documented as NOT recommended and intended for temporary debugging only.Thanks
Really happy to use OpenHands — huge thanks to the team and the community for the awesome project and support 🙏