CVE-2024-32874: Frigate Denial of Service Vulnerability

CRITICAL
Advisory Identifier: GHSA-w4h6-9wrp-v5jq
CVSS 9.3
CWE-770
Published
Advisory Summary

CVE-2024-32874 is a CRITICAL (CVSS 9.3) denial of service vulnerability (CWE-770: Allocation of Resources Without Limits or Throttling) affecting Frigate libraries in the PyPI ecosystem. The issue involves malicious long unicode filenames may cause a multiple application-level denial of service. Remediation is available by upgrading affected packages to version 0.13.2.

CVE-2024-32874 at a Glance

CVE Identifier CVE-2024-32874
GHSA Identifier GHSA-w4h6-9wrp-v5jq
Severity CRITICAL
CVSS v3.1 Base Score 9.3
CWE Classification CWE-770: Allocation of Resources Without Limits or Throttling
Affected Product Frigate
Package Ecosystem PyPI
Published Date
Last Updated

Security Impact

CVSS: 9.3

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:N/I:L/A:H).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction None (UI:N)
Scope Changed (S:C)
Confidentiality None (C:N)
Integrity Low (I:L)
Availability High (A:H)

How to Fix CVE-2024-32874

To remediate this vulnerability, upgrade all affected Frigate dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

frigate fixed: 0.13.2
pip install frigate>=0.13.2
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

pip show frigate

How to Check if You Are Affected

To determine whether your Python environment is affected by CVE-2024-32874, inspect your installed packages using pip:

pip show frigate

Analyze the terminal output to locate any version of Frigate in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 0.13.2), your application is affected.

Note: The pip show frigate command checks currently installed packages in your active Python environment.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-770: Allocation of Resources Without Limits or Throttling, where the product allocates a reusable resource or group of resources on behalf of an actor without imposing any intended restrictions on the size or number of resources that can be allocated. In Frigate, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

**Important: Exploiting this vulnerability requires the attacker to have access to your Frigate instance, which means they could also just delete all of your recordings or perform any other action. If you have configured authentication in front of Frigate via a reverse proxy, then this vulnerability is not exploitable without first getting around your authentication method. For many obvious reasons in addition to this one, please don't expose your Frigate instance publicly without any kind of authentication.** ## Summary When uploading a file or retrieving the filename, a user may intentionally use a large Unicode filename which would lead to a application-level denial of service. This is due to no limitation set on the length of the filename and the costy use of the Unicode normalization with the form NFKD under the hood of `secure_filename()`. I idenfied multiple vulnerable paths on [blakeblackshear/frigate](https://www.github.com/blakeblackshear/frigate/) repository. In all of those paths, it was possible for a malicious user to send a filename equals to the output of : `python3 -c "print('℀' * 1_000_000)"` which would reach the werkzeug `secure_filename()` call , which in turn under the hood uses a compatibility Unicode normalization with NFKC/NFKD form. In sum, the latter call would be costly in matter of CPU resource and may lead to the application-level denial of service. ## Vulnerable Paths <details> <summary>Path with 2 steps</summary> 1. [frigate/api/media.py](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L379C20-L379C31) <pre><code class="python">@MediaBp.route("/&lt;camera_name&gt;/start/&lt;int:start_ts&gt;/end/&lt;int:end_ts&gt;/clip.mp4") @MediaBp.route("/&lt;camera_name&gt;/start/&lt;float:start_ts&gt;/end/&lt;float:end_ts&gt;/clip.mp4") def recording_clip(<strong>camera_name</strong>, start_ts, end_ts): download = request.args.get("download", type=bool) </code></pre> 2. [frigate/api/media.py](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L408C33-L408C78) <pre><code class="python"> playlist_lines.append(f"outpoint {int(end_ts - clip.start_time)}") file_name = secure_filename(<strong>f"clip_{camera_name}_{start_ts}-{end_ts}.mp4"</strong>) path = os.path.join(CACHE_DIR, file_name) </code></pre> </details> ---------------------------------------- [frigate/api/media.py](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L408C33-L408C78) <pre><code class="python"> playlist_lines.append(f"outpoint {int(end_ts - clip.start_time)}") file_name = secure_filename(<strong>f"clip_{camera_name}_{start_ts}-{end_ts}.mp4"</strong>) path = os.path.join(CACHE_DIR, file_name) </code></pre> *This [user-provided value](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L379C33-L379C41) can reach a [costly Unicode normalization operation](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L408C33-L408C78).* #### Paths <details> <summary>Path with 2 steps</summary> 1. [frigate/api/media.py](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L379C33-L379C41) <pre><code class="python">@MediaBp.route("/&lt;camera_name&gt;/start/&lt;int:start_ts&gt;/end/&lt;int:end_ts&gt;/clip.mp4") @MediaBp.route("/&lt;camera_name&gt;/start/&lt;float:start_ts&gt;/end/&lt;float:end_ts&gt;/clip.mp4") def recording_clip(camera_name, <strong>start_ts</strong>, end_ts): download = request.args.get("download", type=bool) </code></pre> 2. [frigate/api/media.py](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L408C33-L408C78) <pre><code class="python"> playlist_lines.append(f"outpoint {int(end_ts - clip.start_time)}") file_name = secure_filename(<strong>f"clip_{camera_name}_{start_ts}-{end_ts}.mp4"</strong>) path = os.path.join(CACHE_DIR, file_name) </code></pre> </details> ---------------------------------------- [frigate/api/media.py](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L408C33-L408C78) <pre><code class="python"> playlist_lines.append(f"outpoint {int(end_ts - clip.start_time)}") file_name = secure_filename(<strong>f"clip_{camera_name}_{start_ts}-{end_ts}.mp4"</strong>) path = os.path.join(CACHE_DIR, file_name) </code></pre> *This [user-provided value](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L379C43-L379C49) can reach a [costly Unicode normalization operation](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L408C33-L408C78).* #### Paths <details> <summary>Path with 2 steps</summary> 1. [frigate/api/media.py](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L379C43-L379C49) <pre><code class="python">@MediaBp.route("/&lt;camera_name&gt;/start/&lt;int:start_ts&gt;/end/&lt;int:end_ts&gt;/clip.mp4") @MediaBp.route("/&lt;camera_name&gt;/start/&lt;float:start_ts&gt;/end/&lt;float:end_ts&gt;/clip.mp4") def recording_clip(camera_name, start_ts, <strong>end_ts</strong>): download = request.args.get("download", type=bool) </code></pre> 2. [frigate/api/media.py](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L408C33-L408C78) <pre><code class="python"> playlist_lines.append(f"outpoint {int(end_ts - clip.start_time)}") file_name = secure_filename(<strong>f"clip_{camera_name}_{start_ts}-{end_ts}.mp4"</strong>) path = os.path.join(CACHE_DIR, file_name) </code></pre> </details> ---------------------------------------- [frigate/api/media.py](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L646C25-L646C47) <pre><code class="python"> current_app.frigate_config, camera_name, secure_filename(<strong>name.replace(" ", "_")</strong>) if name else None, int(start_time), int(end_time), </code></pre> *This [user-provided value](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L23C5-L23C12) can reach a [costly Unicode normalization operation](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L646C25-L646C47).* #### Paths <details> <summary>Path with 8 steps</summary> 1. [frigate/api/media.py](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L23C5-L23C12) <pre><code class="python"> jsonify, make_response, <strong>request</strong>, ) from peewee import DoesNotExist, fn </code></pre> 2. [frigate/api/media.py](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L23C5-L23C12) <pre><code class="python"> jsonify, make_response, <strong>request</strong>, ) from peewee import DoesNotExist, fn </code></pre> 3. [frigate/api/media.py](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L620C28-L620C35) <pre><code class="python"> ) json: dict[str, any] = <strong>request</strong>.get_json(silent=True) or {} playback_factor = json.get("playback", "realtime") name: Optional[str] = json.get("name") </code></pre> 4. [frigate/api/media.py](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L620C5-L620C9) <pre><code class="python"> ) <strong>json</strong>: dict[str, any] = request.get_json(silent=True) or {} playback_factor = json.get("playback", "realtime") name: Optional[str] = json.get("name") </code></pre> 5. [frigate/api/media.py](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L622C27-L622C31) <pre><code class="python"> json: dict[str, any] = request.get_json(silent=True) or {} playback_factor = json.get("playback", "realtime") name: Optional[str] = <strong>json</strong>.get("name") recordings_count = ( </code></pre> 6. [frigate/api/media.py](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L622C27-L622C43) <pre><code class="python"> json: dict[str, any] = request.get_json(silent=True) or {} playback_factor = json.get("playback", "realtime") name: Optional[str] = <strong>json.get("name")</strong> recordings_count = ( </code></pre> 7. [frigate/api/media.py](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L622C5-L622C9) <pre><code class="python"> json: dict[str, any] = request.get_json(silent=True) or {} playback_factor = json.get("playback", "realtime") <strong>name</strong>: Optional[str] = json.get("name") recordings_count = ( </code></pre> 8. [frigate/api/media.py](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L646C25-L646C47) <pre><code class="python"> current_app.frigate_config, camera_name, secure_filename(<strong>name.replace(" ", "_")</strong>) if name else None, int(start_time), int(end_time), </code></pre> </details> ---------------------------------------- [frigate/api/media.py](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L684C9-L684C59) <pre><code class="python">def export_rename(file_name_current, file_name_new: str): safe_file_name_current = secure_filename( <strong>export_filename_check_extension(file_name_current)</strong> ) file_current = os.path.join(EXPORT_DIR, safe_file_name_current) </code></pre> *This [user-provided value](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L682C19-L682C36) can reach a [costly Unicode normalization operation](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L684C9-L684C59).* #### Paths <details> <summary>Path with 5 steps</summary> 1. [frigate/api/media.py](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L682C19-L682C36) <pre><code class="python"> @MediaBp.route("/export/&lt;file_name_current&gt;/&lt;file_name_new&gt;", methods=["PATCH"]) def export_rename(<strong>file_name_current</strong>, file_name_new: str): safe_file_name_current = secure_filename( export_filename_check_extension(file_name_current) </code></pre> 2. [frigate/api/media.py](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L684C41-L684C58) <pre><code class="python">def export_rename(file_name_current, file_name_new: str): safe_file_name_current = secure_filename( export_filename_check_extension(<strong>file_name_current</strong>) ) file_current = os.path.join(EXPORT_DIR, safe_file_name_current) </code></pre> 3. [frigate/api/media.py](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L667C37-L667C45) <pre><code class="python"> def export_filename_check_extension(<strong>filename</strong>: str): if filename.endswith(".mp4"): return filename </code></pre> 4. [frigate/api/media.py](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L669C16-L669C24) <pre><code class="python">def export_filename_check_extension(filename: str): if filename.endswith(".mp4"): return <strong>filename</strong> else: return filename + ".mp4" </code></pre> 5. [frigate/api/media.py](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L684C9-L684C59) <pre><code class="python">def export_rename(file_name_current, file_name_new: str): safe_file_name_current = secure_filename( <strong>export_filename_check_extension(file_name_current)</strong> ) file_current = os.path.join(EXPORT_DIR, safe_file_name_current) </code></pre> </details> <details> <summary>Path with 5 steps</summary> 1. [frigate/api/media.py](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L682C19-L682C36) <pre><code class="python"> @MediaBp.route("/export/&lt;file_name_current&gt;/&lt;file_name_new&gt;", methods=["PATCH"]) def export_rename(<strong>file_name_current</strong>, file_name_new: str): safe_file_name_current = secure_filename( export_filename_check_extension(file_name_current) </code></pre> 2. [frigate/api/media.py](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L684C41-L684C58) <pre><code class="python">def export_rename(file_name_current, file_name_new: str): safe_file_name_current = secure_filename( export_filename_check_extension(<strong>file_name_current</strong>) ) file_current = os.path.join(EXPORT_DIR, safe_file_name_current) </code></pre> 3. [frigate/api/media.py](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L667C37-L667C45) <pre><code class="python"> def export_filename_check_extension(<strong>filename</strong>: str): if filename.endswith(".mp4"): return filename </code></pre> 4. [frigate/api/media.py](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L671C16-L671C33) <pre><code class="python"> return filename else: return <strong>filename + ".mp4"</strong> </code></pre> 5. [frigate/api/media.py](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L684C9-L684C59) <pre><code class="python">def export_rename(file_name_current, file_name_new: str): safe_file_name_current = secure_filename( <strong>export_filename_check_extension(file_name_current)</strong> ) file_current = os.path.join(EXPORT_DIR, safe_file_name_current) </code></pre> </details> ---------------------------------------- [frigate/api/media.py](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L705C42-L705C88) <pre><code class="python"> ) safe_file_name_new = secure_filename(<strong>export_filename_check_extension(file_name_new)</strong>) file_new = os.path.join(EXPORT_DIR, safe_file_name_new) </code></pre> *This [user-provided value](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L682C38-L682C51) can reach a [costly Unicode normalization operation](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L705C42-L705C88).* #### Paths <details> <summary>Path with 5 steps</summary> 1. [frigate/api/media.py](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L682C38-L682C51) <pre><code class="python"> @MediaBp.route("/export/&lt;file_name_current&gt;/&lt;file_name_new&gt;", methods=["PATCH"]) def export_rename(file_name_current, <strong>file_name_new</strong>: str): safe_file_name_current = secure_filename( export_filename_check_extension(file_name_current) </code></pre> 2. [frigate/api/media.py](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L705C74-L705C87) <pre><code class="python"> ) safe_file_name_new = secure_filename(export_filename_check_extension(<strong>file_name_new</strong>)) file_new = os.path.join(EXPORT_DIR, safe_file_name_new) </code></pre> 3. [frigate/api/media.py](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L667C37-L667C45) <pre><code class="python"> def export_filename_check_extension(<strong>filename</strong>: str): if filename.endswith(".mp4"): return filename </code></pre> 4. [frigate/api/media.py](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L669C16-L669C24) <pre><code class="python">def export_filename_check_extension(filename: str): if filename.endswith(".mp4"): return <strong>filename</strong> else: return filename + ".mp4" </code></pre> 5. [frigate/api/media.py](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L705C42-L705C88) <pre><code class="python"> ) safe_file_name_new = secure_filename(<strong>export_filename_check_extension(file_name_new)</strong>) file_new = os.path.join(EXPORT_DIR, safe_file_name_new) </code></pre> </details> <details> <summary>Path with 5 steps</summary> 1. [frigate/api/media.py](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L682C38-L682C51) <pre><code class="python"> @MediaBp.route("/export/&lt;file_name_current&gt;/&lt;file_name_new&gt;", methods=["PATCH"]) def export_rename(file_name_current, <strong>file_name_new</strong>: str): safe_file_name_current = secure_filename( export_filename_check_extension(file_name_current) </code></pre> 2. [frigate/api/media.py](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L705C74-L705C87) <pre><code class="python"> ) safe_file_name_new = secure_filename(export_filename_check_extension(<strong>file_name_new</strong>)) file_new = os.path.join(EXPORT_DIR, safe_file_name_new) </code></pre> 3. [frigate/api/media.py](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L667C37-L667C45) <pre><code class="python"> def export_filename_check_extension(<strong>filename</strong>: str): if filename.endswith(".mp4"): return filename </code></pre> 4. [frigate/api/media.py](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L671C16-L671C33) <pre><code class="python"> return filename else: return <strong>filename + ".mp4"</strong> </code></pre> 5. [frigate/api/media.py](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L705C42-L705C88) <pre><code class="python"> ) safe_file_name_new = secure_filename(<strong>export_filename_check_extension(file_name_new)</strong>) file_new = os.path.join(EXPORT_DIR, safe_file_name_new) </code></pre> </details> ---------------------------------------- [frigate/api/media.py](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L728C38-L728C80) <pre><code class="python">@MediaBp.route("/export/&lt;file_name&gt;", methods=["DELETE"]) def export_delete(file_name: str): safe_file_name = secure_filename(<strong>export_filename_check_extension(file_name)</strong>) file = os.path.join(EXPORT_DIR, safe_file_name) </code></pre> *This [user-provided value](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L727C19-L727C28) can reach a [costly Unicode normalization operation](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L728C38-L728C80).* #### Paths <details> <summary>Path with 5 steps</summary> 1. [frigate/api/media.py](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L727C19-L727C28) <pre><code class="python"> @MediaBp.route("/export/&lt;file_name&gt;", methods=["DELETE"]) def export_delete(<strong>file_name</strong>: str): safe_file_name = secure_filename(export_filename_check_extension(file_name)) file = os.path.join(EXPORT_DIR, safe_file_name) </code></pre> 2. [frigate/api/media.py](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L728C70-L728C79) <pre><code class="python">@MediaBp.route("/export/&lt;file_name&gt;", methods=["DELETE"]) def export_delete(file_name: str): safe_file_name = secure_filename(export_filename_check_extension(<strong>file_name</strong>)) file = os.path.join(EXPORT_DIR, safe_file_name) </code></pre> 3. [frigate/api/media.py](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L667C37-L667C45) <pre><code class="python"> def export_filename_check_extension(<strong>filename</strong>: str): if filename.endswith(".mp4"): return filename </code></pre> 4. [frigate/api/media.py](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L669C16-L669C24) <pre><code class="python">def export_filename_check_extension(filename: str): if filename.endswith(".mp4"): return <strong>filename</strong> else: return filename + ".mp4" </code></pre> 5. [frigate/api/media.py](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L728C38-L728C80) <pre><code class="python">@MediaBp.route("/export/&lt;file_name&gt;", methods=["DELETE"]) def export_delete(file_name: str): safe_file_name = secure_filename(<strong>export_filename_check_extension(file_name)</strong>) file = os.path.join(EXPORT_DIR, safe_file_name) </code></pre> </details> <details> <summary>Path with 5 steps</summary> 1. [frigate/api/media.py](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L727C19-L727C28) <pre><code class="python"> @MediaBp.route("/export/&lt;file_name&gt;", methods=["DELETE"]) def export_delete(<strong>file_name</strong>: str): safe_file_name = secure_filename(export_filename_check_extension(file_name)) file = os.path.join(EXPORT_DIR, safe_file_name) </code></pre> 2. [frigate/api/media.py](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L728C70-L728C79) <pre><code class="python">@MediaBp.route("/export/&lt;file_name&gt;", methods=["DELETE"]) def export_delete(file_name: str): safe_file_name = secure_filename(export_filename_check_extension(<strong>file_name</strong>)) file = os.path.join(EXPORT_DIR, safe_file_name) </code></pre> 3. [frigate/api/media.py](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L667C37-L667C45) <pre><code class="python"> def export_filename_check_extension(<strong>filename</strong>: str): if filename.endswith(".mp4"): return filename </code></pre> 4. [frigate/api/media.py](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L671C16-L671C33) <pre><code class="python"> return filename else: return <strong>filename + ".mp4"</strong> </code></pre> 5. [frigate/api/media.py](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L728C38-L728C80) <pre><code class="python">@MediaBp.route("/export/&lt;file_name&gt;", methods=["DELETE"]) def export_delete(file_name: str): safe_file_name = secure_filename(<strong>export_filename_check_extension(file_name)</strong>) file = os.path.join(EXPORT_DIR, safe_file_name) </code></pre> </details> ---------------------------------------- [frigate/api/media.py](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L1346C46-L1346C55) <pre><code class="python">def preview_thumbnail(file_name: str): """Get a thumbnail from the cached preview frames.""" safe_file_name_current = secure_filename(<strong>file_name</strong>) preview_dir = os.path.join(CACHE_DIR, "preview_frames") </code></pre> *This [user-provided value](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L1344C23-L1344C32) can reach a [costly Unicode normalization operation](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L1346C46-L1346C55).* #### Paths <details> <summary>Path with 2 steps</summary> 1. [frigate/api/media.py](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L1344C23-L1344C32) <pre><code class="python">@MediaBp.route("/preview/&lt;file_name&gt;/thumbnail.jpg") @MediaBp.route("/preview/&lt;file_name&gt;/thumbnail.webp") def preview_thumbnail(<strong>file_name</strong>: str): """Get a thumbnail from the cached preview frames.""" safe_file_name_current = secure_filename(file_name) </code></pre> 2. [frigate/api/media.py](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L1346C46-L1346C55) <pre><code class="python">def preview_thumbnail(file_name: str): """Get a thumbnail from the cached preview frames.""" safe_file_name_current = secure_filename(<strong>file_name</strong>) preview_dir = os.path.join(CACHE_DIR, "preview_frames") </code></pre> </details> ## Impact * Application-level Denial of Service, the web app would hung undefinetly and not process any further request due to the use of the malicious payload. ## Mitigation * Limiting the length of the incoming filename, similar to this commit [fix](https://github.com/django/django/commit/048a9ebb6ea468426cb4e57c71572cbbd975517f). ## References * Similar to [CVE-2023-46695](https://github.com/advisories/GHSA-qmf9-6jqf-j8fq "CVE-2023-46695")

CVE-2024-32874 Affected Frigate Versions

1 component(s)
Fixed Versions:
0.13.2
Product / Package Ecosystem Affected Versions Fixed Version
frigate
PyPI
< 0.13.2
0.13.2

References

Frequently Asked Questions

What is CVE-2024-32874?
CVE-2024-32874 is a security vulnerability in Frigate involving Malicious Long Unicode filenames may cause a Multiple Application-level Denial of Service under CWE-770: Allocation of Resources Without Limits or Throttling.
Which Frigate versions are affected?
Affected versions include releases prior to 0.13.2 across affected packages: frigate.
What version fixes CVE-2024-32874?
Upgrading to 0.13.2 (or the latest patched release for your respective branch) resolves the vulnerability.
Is frigate affected?
Yes, frigate is affected in releases prior to 0.13.2. Upgrade your dependency to 0.13.2 or later.
What is the CVSS score of CVE-2024-32874?
CVE-2024-32874 has a CVSS v3.1 base score of 9.3 (CRITICAL) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:N/I:L/A:H.
What CWE is associated with CVE-2024-32874?
CVE-2024-32874 is classified under CWE-770: Allocation of Resources Without Limits or Throttling (The product allocates a reusable resource or group of resources on behalf of an actor without imposing any intended restrictions on the size or number of resources that can be allocated.).
How can I check PyPI dependencies for CVE-2024-32874?
Run the dependency tree command: 'pip show frigate'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-w4h6-9wrp-v5jq",
  "modified" : "2024-05-14T20:00:47Z",
  "published" : "2024-05-09T15:13:49Z",
  "aliases" : [ "CVE-2024-32874" ],
  "summary" : "Malicious Long Unicode filenames may cause a Multiple Application-level Denial of Service",
  "details" : "**Important: Exploiting this vulnerability requires the attacker to have access to your Frigate instance, which means they could also just delete all of your recordings or perform any other action. If you have configured authentication in front of Frigate via a reverse proxy, then this vulnerability is not exploitable without first getting around your authentication method. For many obvious reasons in addition to this one, please don't expose your Frigate instance publicly without any kind of authentication.**\n\n## Summary\n\nWhen uploading a file or retrieving the filename, a user may intentionally use a large Unicode filename which would lead to a application-level denial of service. This is due to no limitation set on the length of the filename and the costy use of the Unicode normalization with the form NFKD under the hood of `secure_filename()`.\n\nI idenfied multiple vulnerable paths on [blakeblackshear/frigate](https://www.github.com/blakeblackshear/frigate/) repository. In all of those paths, it was possible for a malicious user to send a filename equals to the output of : `python3 -c \"print('℀' * 1_000_000)\"` which would reach the werkzeug `secure_filename()` call , which in turn under the hood uses a compatibility Unicode normalization with NFKC/NFKD form. In sum, the latter call would be costly in matter of CPU resource and may lead to the application-level denial of service. \n\n## Vulnerable Paths\n\n<details>\n<summary>Path with 2 steps</summary>\n\n1. [frigate/api/media.py](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L379C20-L379C31)\n   <pre><code class=\"python\">@MediaBp.route(\"/&lt;camera_name&gt;/start/&lt;int:start_ts&gt;/end/&lt;int:end_ts&gt;/clip.mp4\")\n   @MediaBp.route(\"/&lt;camera_name&gt;/start/&lt;float:start_ts&gt;/end/&lt;float:end_ts&gt;/clip.mp4\")\n   def recording_clip(<strong>camera_name</strong>, start_ts, end_ts):\n       download = request.args.get(\"download\", type=bool)\n\n   </code></pre>\n\n2. [frigate/api/media.py](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L408C33-L408C78)\n   <pre><code class=\"python\">            playlist_lines.append(f\"outpoint {int(end_ts - clip.start_time)}\")\n\n       file_name = secure_filename(<strong>f\"clip_{camera_name}_{start_ts}-{end_ts}.mp4\"</strong>)\n       path = os.path.join(CACHE_DIR, file_name)\n\n   </code></pre>\n\n</details>\n\n----------------------------------------\n\n[frigate/api/media.py](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L408C33-L408C78)\n\n<pre><code class=\"python\">            playlist_lines.append(f\"outpoint {int(end_ts - clip.start_time)}\")\n\n    file_name = secure_filename(<strong>f\"clip_{camera_name}_{start_ts}-{end_ts}.mp4\"</strong>)\n    path = os.path.join(CACHE_DIR, file_name)\n\n</code></pre>\n\n*This [user-provided value](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L379C33-L379C41) can reach a [costly Unicode normalization operation](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L408C33-L408C78).*\n\n#### Paths\n\n<details>\n<summary>Path with 2 steps</summary>\n\n1. [frigate/api/media.py](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L379C33-L379C41)\n   <pre><code class=\"python\">@MediaBp.route(\"/&lt;camera_name&gt;/start/&lt;int:start_ts&gt;/end/&lt;int:end_ts&gt;/clip.mp4\")\n   @MediaBp.route(\"/&lt;camera_name&gt;/start/&lt;float:start_ts&gt;/end/&lt;float:end_ts&gt;/clip.mp4\")\n   def recording_clip(camera_name, <strong>start_ts</strong>, end_ts):\n       download = request.args.get(\"download\", type=bool)\n\n   </code></pre>\n\n2. [frigate/api/media.py](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L408C33-L408C78)\n   <pre><code class=\"python\">            playlist_lines.append(f\"outpoint {int(end_ts - clip.start_time)}\")\n\n       file_name = secure_filename(<strong>f\"clip_{camera_name}_{start_ts}-{end_ts}.mp4\"</strong>)\n       path = os.path.join(CACHE_DIR, file_name)\n\n   </code></pre>\n\n</details>\n\n----------------------------------------\n\n[frigate/api/media.py](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L408C33-L408C78)\n\n<pre><code class=\"python\">            playlist_lines.append(f\"outpoint {int(end_ts - clip.start_time)}\")\n\n    file_name = secure_filename(<strong>f\"clip_{camera_name}_{start_ts}-{end_ts}.mp4\"</strong>)\n    path = os.path.join(CACHE_DIR, file_name)\n\n</code></pre>\n\n*This [user-provided value](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L379C43-L379C49) can reach a [costly Unicode normalization operation](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L408C33-L408C78).*\n\n#### Paths\n\n<details>\n<summary>Path with 2 steps</summary>\n\n1. [frigate/api/media.py](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L379C43-L379C49)\n   <pre><code class=\"python\">@MediaBp.route(\"/&lt;camera_name&gt;/start/&lt;int:start_ts&gt;/end/&lt;int:end_ts&gt;/clip.mp4\")\n   @MediaBp.route(\"/&lt;camera_name&gt;/start/&lt;float:start_ts&gt;/end/&lt;float:end_ts&gt;/clip.mp4\")\n   def recording_clip(camera_name, start_ts, <strong>end_ts</strong>):\n       download = request.args.get(\"download\", type=bool)\n\n   </code></pre>\n\n2. [frigate/api/media.py](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L408C33-L408C78)\n   <pre><code class=\"python\">            playlist_lines.append(f\"outpoint {int(end_ts - clip.start_time)}\")\n\n       file_name = secure_filename(<strong>f\"clip_{camera_name}_{start_ts}-{end_ts}.mp4\"</strong>)\n       path = os.path.join(CACHE_DIR, file_name)\n\n   </code></pre>\n\n</details>\n\n----------------------------------------\n\n[frigate/api/media.py](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L646C25-L646C47)\n\n<pre><code class=\"python\">        current_app.frigate_config,\n        camera_name,\n        secure_filename(<strong>name.replace(\" \", \"_\")</strong>) if name else None,\n        int(start_time),\n        int(end_time),\n</code></pre>\n\n*This [user-provided value](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L23C5-L23C12) can reach a [costly Unicode normalization operation](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L646C25-L646C47).*\n\n#### Paths\n\n<details>\n<summary>Path with 8 steps</summary>\n\n1. [frigate/api/media.py](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L23C5-L23C12)\n   <pre><code class=\"python\">    jsonify,\n       make_response,\n       <strong>request</strong>,\n   )\n   from peewee import DoesNotExist, fn\n   </code></pre>\n\n2. [frigate/api/media.py](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L23C5-L23C12)\n   <pre><code class=\"python\">    jsonify,\n       make_response,\n       <strong>request</strong>,\n   )\n   from peewee import DoesNotExist, fn\n   </code></pre>\n\n3. [frigate/api/media.py](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L620C28-L620C35)\n   <pre><code class=\"python\">        )\n\n       json: dict[str, any] = <strong>request</strong>.get_json(silent=True) or {}\n       playback_factor = json.get(\"playback\", \"realtime\")\n       name: Optional[str] = json.get(\"name\")\n   </code></pre>\n\n4. [frigate/api/media.py](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L620C5-L620C9)\n   <pre><code class=\"python\">        )\n\n       <strong>json</strong>: dict[str, any] = request.get_json(silent=True) or {}\n       playback_factor = json.get(\"playback\", \"realtime\")\n       name: Optional[str] = json.get(\"name\")\n   </code></pre>\n\n5. [frigate/api/media.py](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L622C27-L622C31)\n   <pre><code class=\"python\">    json: dict[str, any] = request.get_json(silent=True) or {}\n       playback_factor = json.get(\"playback\", \"realtime\")\n       name: Optional[str] = <strong>json</strong>.get(\"name\")\n\n       recordings_count = (\n   </code></pre>\n\n6. [frigate/api/media.py](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L622C27-L622C43)\n   <pre><code class=\"python\">    json: dict[str, any] = request.get_json(silent=True) or {}\n       playback_factor = json.get(\"playback\", \"realtime\")\n       name: Optional[str] = <strong>json.get(\"name\")</strong>\n\n       recordings_count = (\n   </code></pre>\n\n7. [frigate/api/media.py](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L622C5-L622C9)\n   <pre><code class=\"python\">    json: dict[str, any] = request.get_json(silent=True) or {}\n       playback_factor = json.get(\"playback\", \"realtime\")\n       <strong>name</strong>: Optional[str] = json.get(\"name\")\n\n       recordings_count = (\n   </code></pre>\n\n8. [frigate/api/media.py](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L646C25-L646C47)\n   <pre><code class=\"python\">        current_app.frigate_config,\n           camera_name,\n           secure_filename(<strong>name.replace(\" \", \"_\")</strong>) if name else None,\n           int(start_time),\n           int(end_time),\n   </code></pre>\n\n</details>\n\n----------------------------------------\n\n[frigate/api/media.py](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L684C9-L684C59)\n\n<pre><code class=\"python\">def export_rename(file_name_current, file_name_new: str):\n    safe_file_name_current = secure_filename(\n        <strong>export_filename_check_extension(file_name_current)</strong>\n    )\n    file_current = os.path.join(EXPORT_DIR, safe_file_name_current)\n</code></pre>\n\n*This [user-provided value](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L682C19-L682C36) can reach a [costly Unicode normalization operation](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L684C9-L684C59).*\n\n#### Paths\n\n<details>\n<summary>Path with 5 steps</summary>\n\n1. [frigate/api/media.py](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L682C19-L682C36)\n   <pre><code class=\"python\">\n   @MediaBp.route(\"/export/&lt;file_name_current&gt;/&lt;file_name_new&gt;\", methods=[\"PATCH\"])\n   def export_rename(<strong>file_name_current</strong>, file_name_new: str):\n       safe_file_name_current = secure_filename(\n           export_filename_check_extension(file_name_current)\n   </code></pre>\n\n2. [frigate/api/media.py](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L684C41-L684C58)\n   <pre><code class=\"python\">def export_rename(file_name_current, file_name_new: str):\n       safe_file_name_current = secure_filename(\n           export_filename_check_extension(<strong>file_name_current</strong>)\n       )\n       file_current = os.path.join(EXPORT_DIR, safe_file_name_current)\n   </code></pre>\n\n3. [frigate/api/media.py](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L667C37-L667C45)\n   <pre><code class=\"python\">\n\n   def export_filename_check_extension(<strong>filename</strong>: str):\n       if filename.endswith(\".mp4\"):\n           return filename\n   </code></pre>\n\n4. [frigate/api/media.py](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L669C16-L669C24)\n   <pre><code class=\"python\">def export_filename_check_extension(filename: str):\n       if filename.endswith(\".mp4\"):\n           return <strong>filename</strong>\n       else:\n           return filename + \".mp4\"\n   </code></pre>\n\n5. [frigate/api/media.py](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L684C9-L684C59)\n   <pre><code class=\"python\">def export_rename(file_name_current, file_name_new: str):\n       safe_file_name_current = secure_filename(\n           <strong>export_filename_check_extension(file_name_current)</strong>\n       )\n       file_current = os.path.join(EXPORT_DIR, safe_file_name_current)\n   </code></pre>\n\n</details>\n\n<details>\n<summary>Path with 5 steps</summary>\n\n1. [frigate/api/media.py](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L682C19-L682C36)\n   <pre><code class=\"python\">\n   @MediaBp.route(\"/export/&lt;file_name_current&gt;/&lt;file_name_new&gt;\", methods=[\"PATCH\"])\n   def export_rename(<strong>file_name_current</strong>, file_name_new: str):\n       safe_file_name_current = secure_filename(\n           export_filename_check_extension(file_name_current)\n   </code></pre>\n\n2. [frigate/api/media.py](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L684C41-L684C58)\n   <pre><code class=\"python\">def export_rename(file_name_current, file_name_new: str):\n       safe_file_name_current = secure_filename(\n           export_filename_check_extension(<strong>file_name_current</strong>)\n       )\n       file_current = os.path.join(EXPORT_DIR, safe_file_name_current)\n   </code></pre>\n\n3. [frigate/api/media.py](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L667C37-L667C45)\n   <pre><code class=\"python\">\n\n   def export_filename_check_extension(<strong>filename</strong>: str):\n       if filename.endswith(\".mp4\"):\n           return filename\n   </code></pre>\n\n4. [frigate/api/media.py](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L671C16-L671C33)\n   <pre><code class=\"python\">        return filename\n       else:\n           return <strong>filename + \".mp4\"</strong>\n\n\n   </code></pre>\n\n5. [frigate/api/media.py](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L684C9-L684C59)\n   <pre><code class=\"python\">def export_rename(file_name_current, file_name_new: str):\n       safe_file_name_current = secure_filename(\n           <strong>export_filename_check_extension(file_name_current)</strong>\n       )\n       file_current = os.path.join(EXPORT_DIR, safe_file_name_current)\n   </code></pre>\n\n</details>\n\n----------------------------------------\n\n[frigate/api/media.py](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L705C42-L705C88)\n\n<pre><code class=\"python\">        )\n\n    safe_file_name_new = secure_filename(<strong>export_filename_check_extension(file_name_new)</strong>)\n    file_new = os.path.join(EXPORT_DIR, safe_file_name_new)\n\n</code></pre>\n\n*This [user-provided value](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L682C38-L682C51) can reach a [costly Unicode normalization operation](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L705C42-L705C88).*\n\n#### Paths\n\n<details>\n<summary>Path with 5 steps</summary>\n\n1. [frigate/api/media.py](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L682C38-L682C51)\n   <pre><code class=\"python\">\n   @MediaBp.route(\"/export/&lt;file_name_current&gt;/&lt;file_name_new&gt;\", methods=[\"PATCH\"])\n   def export_rename(file_name_current, <strong>file_name_new</strong>: str):\n       safe_file_name_current = secure_filename(\n           export_filename_check_extension(file_name_current)\n   </code></pre>\n\n2. [frigate/api/media.py](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L705C74-L705C87)\n   <pre><code class=\"python\">        )\n\n       safe_file_name_new = secure_filename(export_filename_check_extension(<strong>file_name_new</strong>))\n       file_new = os.path.join(EXPORT_DIR, safe_file_name_new)\n\n   </code></pre>\n\n3. [frigate/api/media.py](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L667C37-L667C45)\n   <pre><code class=\"python\">\n\n   def export_filename_check_extension(<strong>filename</strong>: str):\n       if filename.endswith(\".mp4\"):\n           return filename\n   </code></pre>\n\n4. [frigate/api/media.py](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L669C16-L669C24)\n   <pre><code class=\"python\">def export_filename_check_extension(filename: str):\n       if filename.endswith(\".mp4\"):\n           return <strong>filename</strong>\n       else:\n           return filename + \".mp4\"\n   </code></pre>\n\n5. [frigate/api/media.py](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L705C42-L705C88)\n   <pre><code class=\"python\">        )\n\n       safe_file_name_new = secure_filename(<strong>export_filename_check_extension(file_name_new)</strong>)\n       file_new = os.path.join(EXPORT_DIR, safe_file_name_new)\n\n   </code></pre>\n\n</details>\n\n<details>\n<summary>Path with 5 steps</summary>\n\n1. [frigate/api/media.py](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L682C38-L682C51)\n   <pre><code class=\"python\">\n   @MediaBp.route(\"/export/&lt;file_name_current&gt;/&lt;file_name_new&gt;\", methods=[\"PATCH\"])\n   def export_rename(file_name_current, <strong>file_name_new</strong>: str):\n       safe_file_name_current = secure_filename(\n           export_filename_check_extension(file_name_current)\n   </code></pre>\n\n2. [frigate/api/media.py](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L705C74-L705C87)\n   <pre><code class=\"python\">        )\n\n       safe_file_name_new = secure_filename(export_filename_check_extension(<strong>file_name_new</strong>))\n       file_new = os.path.join(EXPORT_DIR, safe_file_name_new)\n\n   </code></pre>\n\n3. [frigate/api/media.py](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L667C37-L667C45)\n   <pre><code class=\"python\">\n\n   def export_filename_check_extension(<strong>filename</strong>: str):\n       if filename.endswith(\".mp4\"):\n           return filename\n   </code></pre>\n\n4. [frigate/api/media.py](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L671C16-L671C33)\n   <pre><code class=\"python\">        return filename\n       else:\n           return <strong>filename + \".mp4\"</strong>\n\n\n   </code></pre>\n\n5. [frigate/api/media.py](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L705C42-L705C88)\n   <pre><code class=\"python\">        )\n\n       safe_file_name_new = secure_filename(<strong>export_filename_check_extension(file_name_new)</strong>)\n       file_new = os.path.join(EXPORT_DIR, safe_file_name_new)\n\n   </code></pre>\n\n</details>\n\n----------------------------------------\n\n[frigate/api/media.py](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L728C38-L728C80)\n\n<pre><code class=\"python\">@MediaBp.route(\"/export/&lt;file_name&gt;\", methods=[\"DELETE\"])\ndef export_delete(file_name: str):\n    safe_file_name = secure_filename(<strong>export_filename_check_extension(file_name)</strong>)\n    file = os.path.join(EXPORT_DIR, safe_file_name)\n\n</code></pre>\n\n*This [user-provided value](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L727C19-L727C28) can reach a [costly Unicode normalization operation](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L728C38-L728C80).*\n\n#### Paths\n\n<details>\n<summary>Path with 5 steps</summary>\n\n1. [frigate/api/media.py](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L727C19-L727C28)\n   <pre><code class=\"python\">\n   @MediaBp.route(\"/export/&lt;file_name&gt;\", methods=[\"DELETE\"])\n   def export_delete(<strong>file_name</strong>: str):\n       safe_file_name = secure_filename(export_filename_check_extension(file_name))\n       file = os.path.join(EXPORT_DIR, safe_file_name)\n   </code></pre>\n\n2. [frigate/api/media.py](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L728C70-L728C79)\n   <pre><code class=\"python\">@MediaBp.route(\"/export/&lt;file_name&gt;\", methods=[\"DELETE\"])\n   def export_delete(file_name: str):\n       safe_file_name = secure_filename(export_filename_check_extension(<strong>file_name</strong>))\n       file = os.path.join(EXPORT_DIR, safe_file_name)\n\n   </code></pre>\n\n3. [frigate/api/media.py](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L667C37-L667C45)\n   <pre><code class=\"python\">\n\n   def export_filename_check_extension(<strong>filename</strong>: str):\n       if filename.endswith(\".mp4\"):\n           return filename\n   </code></pre>\n\n4. [frigate/api/media.py](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L669C16-L669C24)\n   <pre><code class=\"python\">def export_filename_check_extension(filename: str):\n       if filename.endswith(\".mp4\"):\n           return <strong>filename</strong>\n       else:\n           return filename + \".mp4\"\n   </code></pre>\n\n5. [frigate/api/media.py](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L728C38-L728C80)\n   <pre><code class=\"python\">@MediaBp.route(\"/export/&lt;file_name&gt;\", methods=[\"DELETE\"])\n   def export_delete(file_name: str):\n       safe_file_name = secure_filename(<strong>export_filename_check_extension(file_name)</strong>)\n       file = os.path.join(EXPORT_DIR, safe_file_name)\n\n   </code></pre>\n\n</details>\n\n<details>\n<summary>Path with 5 steps</summary>\n\n1. [frigate/api/media.py](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L727C19-L727C28)\n   <pre><code class=\"python\">\n   @MediaBp.route(\"/export/&lt;file_name&gt;\", methods=[\"DELETE\"])\n   def export_delete(<strong>file_name</strong>: str):\n       safe_file_name = secure_filename(export_filename_check_extension(file_name))\n       file = os.path.join(EXPORT_DIR, safe_file_name)\n   </code></pre>\n\n2. [frigate/api/media.py](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L728C70-L728C79)\n   <pre><code class=\"python\">@MediaBp.route(\"/export/&lt;file_name&gt;\", methods=[\"DELETE\"])\n   def export_delete(file_name: str):\n       safe_file_name = secure_filename(export_filename_check_extension(<strong>file_name</strong>))\n       file = os.path.join(EXPORT_DIR, safe_file_name)\n\n   </code></pre>\n\n3. [frigate/api/media.py](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L667C37-L667C45)\n   <pre><code class=\"python\">\n\n   def export_filename_check_extension(<strong>filename</strong>: str):\n       if filename.endswith(\".mp4\"):\n           return filename\n   </code></pre>\n\n4. [frigate/api/media.py](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L671C16-L671C33)\n   <pre><code class=\"python\">        return filename\n       else:\n           return <strong>filename + \".mp4\"</strong>\n\n\n   </code></pre>\n\n5. [frigate/api/media.py](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L728C38-L728C80)\n   <pre><code class=\"python\">@MediaBp.route(\"/export/&lt;file_name&gt;\", methods=[\"DELETE\"])\n   def export_delete(file_name: str):\n       safe_file_name = secure_filename(<strong>export_filename_check_extension(file_name)</strong>)\n       file = os.path.join(EXPORT_DIR, safe_file_name)\n\n   </code></pre>\n\n</details>\n\n----------------------------------------\n\n[frigate/api/media.py](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L1346C46-L1346C55)\n\n<pre><code class=\"python\">def preview_thumbnail(file_name: str):\n    \"\"\"Get a thumbnail from the cached preview frames.\"\"\"\n    safe_file_name_current = secure_filename(<strong>file_name</strong>)\n    preview_dir = os.path.join(CACHE_DIR, \"preview_frames\")\n\n</code></pre>\n\n*This [user-provided value](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L1344C23-L1344C32) can reach a [costly Unicode normalization operation](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L1346C46-L1346C55).*\n\n#### Paths\n\n<details>\n<summary>Path with 2 steps</summary>\n\n1. [frigate/api/media.py](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L1344C23-L1344C32)\n   <pre><code class=\"python\">@MediaBp.route(\"/preview/&lt;file_name&gt;/thumbnail.jpg\")\n   @MediaBp.route(\"/preview/&lt;file_name&gt;/thumbnail.webp\")\n   def preview_thumbnail(<strong>file_name</strong>: str):\n       \"\"\"Get a thumbnail from the cached preview frames.\"\"\"\n       safe_file_name_current = secure_filename(file_name)\n   </code></pre>\n\n2. [frigate/api/media.py](https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L1346C46-L1346C55)\n   <pre><code class=\"python\">def preview_thumbnail(file_name: str):\n       \"\"\"Get a thumbnail from the cached preview frames.\"\"\"\n       safe_file_name_current = secure_filename(<strong>file_name</strong>)\n       preview_dir = os.path.join(CACHE_DIR, \"preview_frames\")\n\n   </code></pre>\n\n</details>\n\n\n\n## Impact\n\n* Application-level Denial of Service, the web app would hung undefinetly and not process any further request due to the use of the malicious payload.\n  \n\n## Mitigation\n\n* Limiting the length of the incoming filename, similar to this commit [fix](https://github.com/django/django/commit/048a9ebb6ea468426cb4e57c71572cbbd975517f).\n  \n\n## References\n\n* Similar to [CVE-2023-46695](https://github.com/advisories/GHSA-qmf9-6jqf-j8fq \"CVE-2023-46695\")",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:N/I:L/A:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "frigate"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "0.13.2"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/blakeblackshear/frigate/security/advisories/GHSA-w4h6-9wrp-v5jq"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2024-32874"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/blakeblackshear/frigate/commit/cc851555e4029647986dccc8b8ecf54afee31442"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/blakeblackshear/frigate"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L1346C46-L1346C55"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L408C33-L408C78"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L646C25-L646C47"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L684C9-L684C59"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L705C42-L705C88"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/blakeblackshear/frigate/blob/d7ae0eedf89e14f297093ac5c8042862034cbaeb/frigate/api/media.py#L728C38-L728C80"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-770" ],
    "severity" : "CRITICAL",
    "github_reviewed" : true,
    "github_reviewed_at" : "2024-05-09T15:13:49Z",
    "nvd_published_at" : "2024-05-14T15:37:13Z"
  }
}