fastapi-code-generator@0.8.0

Generate a FastAPI app from an OpenAPI file.

  • latest version

    0.8.1

  • latest non vulnerable version

  • first published

    6 years ago

  • latest version published

    5 months ago

  • licenses detected

  • Direct Vulnerabilities

    Known vulnerabilities in the fastapi-code-generator package. This does not include vulnerabilities belonging to this package’s dependencies.

    Fix vulnerabilities automatically

    Snyk's AI Trust Platform automatically finds the best upgrade path and integrates with your development workflows. Secure your code at zero cost.

    Fix for free
    VulnerabilityVulnerable Version
    • C
    Improper Encoding or Escaping of Output

    fastapi-code-generator is a Generate a FastAPI app from an OpenAPI file.

    Affected versions of this package are vulnerable to Improper Encoding or Escaping of Output via the response status-code key in the additional_responses dict, which is emitted into the generated route decorator as an unescaped single-quoted Python string literal. An attacker who controls or influences the OpenAPI spec can supply a status-code key containing a single quote, closing the string literal and injecting an arbitrary Python expression that executes when the generated main.py is imported at ASGI server startup - requiring no HTTP request. A syntax-valid payload using string concatenation (e.g. '+expr+') passes the black/isort post-processing step and is written directly into the decorator argument.

    Note: This is only exploitable when the operation includes at least one additional (non-primary) response, causing the responses={...} dict to be emitted.

    How to fix Improper Encoding or Escaping of Output?

    Upgrade fastapi-code-generator to version 0.8.1 or higher.

    [,0.8.1)
    • C
    Improper Encoding or Escaping of Output

    fastapi-code-generator is a Generate a FastAPI app from an OpenAPI file.

    Affected versions of this package are vulnerable to Improper Encoding or Escaping of Output via the summary field of an OpenAPI operation being emitted as an unescaped triple-double-quoted docstring in the generated route handler. Because """ sequences in the summary value are not escaped before being written into the handler body, an attacker who controls or influences the OpenAPI spec can inject a valid Python expression that closes the docstring and is evaluated as a live expression statement. This injected code executes on the server each time the affected endpoint is called.

    How to fix Improper Encoding or Escaping of Output?

    Upgrade fastapi-code-generator to version 0.8.1 or higher.

    [,0.8.1)
    • C
    Improper Encoding or Escaping of Output

    fastapi-code-generator is a Generate a FastAPI app from an OpenAPI file.

    Affected versions of this package are vulnerable to Improper Encoding or Escaping of Output via the OpenAPI path field, which is emitted unescaped into the generated main.py route decorator as a single-quoted string literal (@app.get('...')). A single quote in the path closes the string, allowing an attacker to inject arbitrary Python expressions that are evaluated when main.py is imported by the ASGI server at startup - no HTTP request is required. A syntax-breaking payload aborts code generation entirely (denial of service), while a valid-Python concatenation payload (e.g. '+expr+') is written to the output file and executes at import time.

    How to fix Improper Encoding or Escaping of Output?

    Upgrade fastapi-code-generator to version 0.8.1 or higher.

    [,0.8.1)