GHSA-9JJR-QQFP-PPWX
Vulnerability from github – Published: 2021-08-30 16:16 – Updated: 2024-09-13 18:05Impact
A remote code execution vulnerability has been identified in BinderHub, where providing BinderHub with maliciously crafted input could execute code in the BinderHub context, with the potential to egress credentials of the BinderHub deployment, including JupyterHub API tokens, kubernetes service accounts, and docker registry credentials. This may provide the ability to manipulate images and other user created pods in the deployment, with the potential to escalate to the host depending on the underlying kubernetes configuration.
Patches
Patch below, or on GitHub
From 9f4043d9dddc1174920e687773f27b7933f48ab6 Mon Sep 17 00:00:00 2001
From: Riccardo Castellotti <rcastell@cern.ch>
Date: Thu, 19 Aug 2021 15:49:43 +0200
Subject: [PATCH] Explicitly separate git-ls-remote options from positional
arguments
---
binderhub/repoproviders.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/binderhub/repoproviders.py b/binderhub/repoproviders.py
index f33347b..5d4b87c 100755
--- a/binderhub/repoproviders.py
+++ b/binderhub/repoproviders.py
@@ -484,7 +484,7 @@ class GitRepoProvider(RepoProvider):
self.sha1_validate(self.unresolved_ref)
except ValueError:
# The ref is a head/tag and we resolve it using `git ls-remote`
- command = ["git", "ls-remote", self.repo, self.unresolved_ref]
+ command = ["git", "ls-remote", "--", self.repo, self.unresolved_ref]
result = subprocess.run(command, universal_newlines=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
if result.returncode:
raise RuntimeError("Unable to run git ls-remote to get the `resolved_ref`: {}".format(result.stderr))
--
2.25.1
Workarounds
Disable the git repo provider by specifying the BinderHub.repo_providers config, e.g.:
from binderhub.repoproviders import (GitHubRepoProvider,
GitLabRepoProvider, GistRepoProvider,
ZenodoProvider, FigshareProvider, HydroshareProvider,
DataverseProvider)
c.BinderHub.repo_providers = {
'gh': GitHubRepoProvider,
'gist': GistRepoProvider,
'gl': GitLabRepoProvider,
'zenodo': ZenodoProvider,
'figshare': FigshareProvider,
'hydroshare': HydroshareProvider,
'dataverse': DataverseProvider,
}
References
Credit: Jose Carlos Luna Duran (CERN) and Riccardo Castellotti (CERN).
For more information
If you have any questions or comments about this advisory:
- Email us at security@ipython.org
{
"affected": [
{
"package": {
"ecosystem": "PyPI",
"name": "binderhub"
},
"ranges": [
{
"events": [
{
"introduced": "0"
},
{
"fixed": "0.2.0"
}
],
"type": "ECOSYSTEM"
}
]
}
],
"aliases": [
"CVE-2021-39159"
],
"database_specific": {
"cwe_ids": [
"CWE-78",
"CWE-94"
],
"github_reviewed": true,
"github_reviewed_at": "2021-08-25T15:20:56Z",
"nvd_published_at": "2021-08-25T19:15:00Z",
"severity": "CRITICAL"
},
"details": "### Impact\n\nA remote code execution vulnerability has been identified in BinderHub, where providing BinderHub with maliciously crafted input could execute code in the BinderHub context, with the potential to egress credentials of the BinderHub deployment, including JupyterHub API tokens, kubernetes service accounts, and docker registry credentials. This may provide the ability to manipulate images and other user created pods in the deployment, with the potential to escalate to the host depending on the underlying kubernetes configuration.\n\n### Patches\n\nPatch below, or [on GitHub](https://github.com/jupyterhub/binderhub/commit/195caac172690456dcdc8cc7a6ca50e05abf8182.patch)\n\n```diff\nFrom 9f4043d9dddc1174920e687773f27b7933f48ab6 Mon Sep 17 00:00:00 2001\nFrom: Riccardo Castellotti \u003crcastell@cern.ch\u003e\nDate: Thu, 19 Aug 2021 15:49:43 +0200\nSubject: [PATCH] Explicitly separate git-ls-remote options from positional\n arguments\n\n---\n binderhub/repoproviders.py | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/binderhub/repoproviders.py b/binderhub/repoproviders.py\nindex f33347b..5d4b87c 100755\n--- a/binderhub/repoproviders.py\n+++ b/binderhub/repoproviders.py\n@@ -484,7 +484,7 @@ class GitRepoProvider(RepoProvider):\n self.sha1_validate(self.unresolved_ref)\n except ValueError:\n # The ref is a head/tag and we resolve it using `git ls-remote`\n- command = [\"git\", \"ls-remote\", self.repo, self.unresolved_ref]\n+ command = [\"git\", \"ls-remote\", \"--\", self.repo, self.unresolved_ref]\n result = subprocess.run(command, universal_newlines=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)\n if result.returncode:\n raise RuntimeError(\"Unable to run git ls-remote to get the `resolved_ref`: {}\".format(result.stderr))\n-- \n2.25.1\n\n```\n\n### Workarounds\n\nDisable the git repo provider by specifying the `BinderHub.repo_providers` config, e.g.:\n\n```python\nfrom binderhub.repoproviders import (GitHubRepoProvider,\n GitLabRepoProvider, GistRepoProvider,\n ZenodoProvider, FigshareProvider, HydroshareProvider,\n DataverseProvider)\n\nc.BinderHub.repo_providers = {\n \u0027gh\u0027: GitHubRepoProvider,\n \u0027gist\u0027: GistRepoProvider,\n \u0027gl\u0027: GitLabRepoProvider,\n \u0027zenodo\u0027: ZenodoProvider,\n \u0027figshare\u0027: FigshareProvider,\n \u0027hydroshare\u0027: HydroshareProvider,\n \u0027dataverse\u0027: DataverseProvider,\n }\n```\n\n### References\n\nCredit: Jose Carlos Luna Duran (CERN) and Riccardo Castellotti (CERN).\n\n### For more information\n\nIf you have any questions or comments about this advisory:\n\n* Email us at [security@ipython.org](mailto:security@ipython.org)\n",
"id": "GHSA-9jjr-qqfp-ppwx",
"modified": "2024-09-13T18:05:58Z",
"published": "2021-08-30T16:16:58Z",
"references": [
{
"type": "WEB",
"url": "https://github.com/jupyterhub/binderhub/security/advisories/GHSA-9jjr-qqfp-ppwx"
},
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2021-39159"
},
{
"type": "WEB",
"url": "https://github.com/jupyterhub/binderhub/commit/195caac172690456dcdc8cc7a6ca50e05abf8182"
},
{
"type": "WEB",
"url": "https://github.com/jupyterhub/binderhub/commit/195caac172690456dcdc8cc7a6ca50e05abf8182.patch"
},
{
"type": "PACKAGE",
"url": "https://github.com/jupyterhub/binderhub"
},
{
"type": "WEB",
"url": "https://github.com/pypa/advisory-database/tree/main/vulns/binderhub/PYSEC-2021-371.yaml"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:H/I:H/A:H",
"type": "CVSS_V3"
},
{
"score": "CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:P/VC:H/VI:H/VA:H/SC:H/SI:H/SA:H",
"type": "CVSS_V4"
}
],
"summary": "remote code execution via git repo provider"
}
Sightings
| Author | Source | Type | Date |
|---|
Nomenclature
- Seen: The vulnerability was mentioned, discussed, or observed by the user.
- Confirmed: The vulnerability has been validated from an analyst's perspective.
- Published Proof of Concept: A public proof of concept is available for this vulnerability.
- Exploited: The vulnerability was observed as exploited by the user who reported the sighting.
- Patched: The vulnerability was observed as successfully patched by the user who reported the sighting.
- Not exploited: The vulnerability was not observed as exploited by the user who reported the sighting.
- Not confirmed: The user expressed doubt about the validity of the vulnerability.
- Not patched: The vulnerability was not observed as successfully patched by the user who reported the sighting.