Advisory

GHSA-83pv-qr33-2vcf

Details, part 2 of 2. The advisory

Details

  1. Path Normalization:
  • Normalize file paths before using them in file operations. Functions such as os.path.normpath() in Python can be used to normalize paths. This method resolves redundant separators and up-level references (../) to prevent directory traversal.
  • As a reference, consider the approach taken by the Starlette framework in their static file serving feature, where path validation is performed to ensure the requested path remains within the intended directory. For example, see how Starlette handles this with a security check: python if os.path.commonpath([full_path, directory]) != directory: # Don't allow misbehaving clients to break out of the static files # directory. continue This snippet from Starlette's implementation ensures that the constructed file path does not traverse out of the specified directory.

Comments
Naming Convention:

  • From versions 0.X.X through 1.X.X, the package was released under the name "starlite."
  • Starting with version 2.0.0 and for all subsequent versions, the package has been rebranded and released under the name "litestar."

Feature Additions and Changes:

  • Static Files Support: Introduced in version 0.6.0, adding the capability to serve static files directly from the package.
  • Path Validation Update: In version 1.37.0, Starlite modified its approach to validating paths within the static directory. Prior to this version, path validation was managed using the Starlette framework.

Sources & licences