Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix starlette vulnerability #487

Merged
merged 12 commits into from
Feb 4, 2025
Merged

Fix starlette vulnerability #487

merged 12 commits into from
Feb 4, 2025

Conversation

six5532one
Copy link
Contributor

@six5532one six5532one commented Jan 28, 2025

Starlette v0.38.6 has a Denial of Service (DoS) vulnerability, which is fixed in Starlette 0.40.0. This PR bumps Starlette to a version without the vulnerability.

From a grype scan today:

{
  "vulnerability": {
    "id": "GHSA-f96h-pmfr-66vw",
    "dataSource": "https://github.com/advisories/GHSA-f96h-pmfr-66vw",
    "namespace": "github:language:python",
    "severity": "High",
    "urls": [
      "https://github.com/advisories/GHSA-f96h-pmfr-66vw"
    ],
    "description": "Starlette Denial of service (DoS) via multipart/form-data",
    "cvss": [
      {
        "version": "3.1",
        "vector": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:N",
        "metrics": {
          "baseScore": 0,
          "exploitabilityScore": 3.9,
          "impactScore": 0
        },
        "vendorMetadata": {
          "base_severity": "None",
          "status": "N/A"
        }
      }
    ],
    "fix": {
      "versions": [
        "0.40.0"
      ],
      "state": "fixed"
    },
    "advisories": []
  },
  "relatedVulnerabilities": [
    {
      "id": "CVE-2024-47874",
      "dataSource": "https://nvd.nist.gov/vuln/detail/CVE-2024-47874",
      "namespace": "nvd:cpe",
      "severity": "Unknown",
      "urls": [
        "https://github.com/encode/starlette/commit/fd038f3070c302bff17ef7d173dbb0b007617733",
        "https://github.com/encode/starlette/security/advisories/GHSA-f96h-pmfr-66vw"
      ],
      "description": "Starlette is an Asynchronous Server Gateway Interface (ASGI) framework/toolkit. Prior to version 0.40.0, Starlette treats `multipart/form-data` parts without a `filename` as text form fields and buffers those in byte strings with no size limit. This allows an attacker to upload arbitrary large form fields and cause Starlette to both slow down significantly due to excessive memory allocations and copy operations, and also consume more and more memory until the server starts swapping and grinds to a halt, or the OS terminates the server process with an OOM error. Uploading multiple such requests in parallel may be enough to render a service practically unusable, even if reasonable request size limits are enforced by a reverse proxy in front of Starlette. This Denial of service (DoS) vulnerability affects all applications built with Starlette (or FastAPI) accepting form requests. Verison 0.40.0 fixes this issue.",
      "cvss": []
    }
  ],
  "matchDetails": [
    {
      "type": "exact-direct-match",
      "matcher": "python-matcher",
      "searchedBy": {
        "language": "python",
        "namespace": "github:language:python",
        "package": {
          "name": "starlette",
          "version": "0.38.6"
        }
      },
      "found": {
        "versionConstraint": "<0.40.0 (python)",
        "vulnerabilityID": "GHSA-f96h-pmfr-66vw"
      }
    }
  ],
  "artifact": {
    "id": "1d7d075e0c1f6a8e",
    "name": "starlette",
    "version": "0.38.6",
    "type": "python",
    "locations": [
      {
        "path": "/home/notebook-user/.local/lib/python3.11/site-packages/starlette-0.38.6.dist-info/METADATA",
        "layerID": "sha256:fe25e383965257a8c296faf3194fc68bd7e91731ba22a8a6a319b4b5316108d2"
      },
      {
        "path": "/home/notebook-user/.local/lib/python3.11/site-packages/starlette-0.38.6.dist-info/RECORD",
        "layerID": "sha256:fe25e383965257a8c296faf3194fc68bd7e91731ba22a8a6a319b4b5316108d2"
      }
    ],
    "language": "python",
    "licenses": [
      "BSD-3-Clause"
    ],
    "cpes": [
      "cpe:2.3:a:encode:starlette:0.38.6:*:*:*:*:python:*:*"
    ],
    "purl": "pkg:pypi/[email protected]",
    "upstreams": []
  }
}

Fixes https://unstructured-ai.atlassian.net/browse/PRANCER-625

@awalker4
Copy link
Collaborator

awalker4 commented Jan 29, 2025

It seems that later starlette versions are breaking something in our middleware. I tracked it down to starlette==0.44.0. While we figure that out, would it work to pin starlette at 0.43.0? cc @badGarnet who ran into this as well. That should get CI to pass and then this LGTM.

@six5532one six5532one requested a review from awalker4 February 3, 2025 22:05
Copy link
Collaborator

@awalker4 awalker4 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@awalker4 awalker4 merged commit da9807d into main Feb 4, 2025
6 checks passed
@awalker4 awalker4 deleted the fix_starlette_vulnerability branch February 4, 2025 14:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants