Heap-buffer-overflow in json_parse in the file package

file Updated 02 Oct 2025

Summary

06/07/2022
MEDIUM
Yes i
Medium
Not published

OSV-2022-534: Heap-buffer-overflow in json_parse. Affects file versions >= 522e7901a20dc6f2d1ceafb5d12d44f94946e11a, < 16756ff9286df9a43b4b6e21824975a1c6809835. Fixed in 16756ff9286df9a43b4b6e21824975a1c6809835. How to fix ↓

Free scan

Check if this vulnerability affects your application

Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.

Check my app free

No signup required · Results in about 60 seconds

Upload your dependency manifest or SBOM

Drag & drop your file here or

Java Javascript PHP Python Go Rust Ruby Dart C/C++ Elixir CycloneDX SPDX

Upload a supported dependency manifest or SBOM. No installation or source-code access required.

See supported files and SBOM formats
SBOM sbom.json · bom.json · bom.xml · *.spdx.json · *.cdx.json · *.cdx.xml
Java pom.xml · gradle.lockfile · buildscript-gradle.lockfile
Javascript package-lock.json · yarn.lock · pnpm-lock.yaml
PHP composer.lock
Python poetry.lock · requirements.txt · Pipfile.lock
Go go.mod
Rust Cargo.lock
Ruby Gemfile.lock
Dart pubspec.lock
C/C++ conan.lock
Elixir mix.lock
Enter your work email to receive your report link.

Verify your email to view the full report and start 30 days of continuous monitoring. No credit card required.

Sponsored Devnack Mobile apps built by Devnack Design, build and launch iOS and Android apps with a senior product team. From idea to store release Start a project

Background

The file package is an open-source library that provides functionality for determining file types based on their content. It is widely used in various software applications to identify file formats and handle them accordingly. However, a vulnerability has been discovered in the json_parse function of the file package, which can lead to a heap-buffer-overflow read. This vulnerability can potentially be exploited by an attacker to execute arbitrary code or cause a denial of service.

Vulnerability Detail

The vulnerability in the json_parse function of the file package arises from a heap-buffer-overflow read. When processing a specially crafted JSON file, the function fails to properly validate the input, leading to a buffer overflow. This can result in the reading of unintended memory contents, potentially allowing an attacker to gain unauthorized access to sensitive information or execute arbitrary code. The vulnerability has been assigned a medium severity rating.

How To Fix

Minimum fixed version

16756ff9286df9a43b4b6e21824975a1c6809835

This is the first release that contains the fix.

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Workaround

As a temporary workaround, developers can implement input validation to ensure that the JSON files being processed by the file package do not contain malicious or malformed data. By validating the input before passing it to the json_parse function, the risk of triggering the heap-buffer-overflow read can be mitigated. Here is an example of how input validation can be implemented in Python:

import json

def process_json_file(file_path):
    with open(file_path, 'r') as file:
        json_data = json.load(file)
        if validate_json(json_data):
            # Proceed with processing the JSON data
        else:
            # Handle invalid JSON


def validate_json(json_data):
    # Implement your validation logic here
    # Return True if the JSON data is valid, False otherwise

Conclusion

In conclusion, the file package is vulnerable to a heap-buffer-overflow read in the json_parse function. This vulnerability can be exploited by providing a specially crafted JSON file, potentially leading to unauthorized access or arbitrary code execution. To mitigate this vulnerability, it is recommended to update the file package to version 16756ff9286df9a43b4b6e21824975a1c6809835 or a later version. Developers can also implement input validation as a temporary workaround. For further assistance or support in vulnerability remediation, please contact DevNack.com.

See every vulnerability recorded for file →

Share this vulnerability

FAQ

The file package is an open-source library that provides functionality for determining file types based on their content. It is commonly used in software applications to identify file formats and handle them accordingly.

A heap-buffer-overflow vulnerability occurs when a program attempts to read or write data outside the bounds of a heap-allocated buffer. This can lead to memory corruption, crashes, or even remote code execution.

An attacker can exploit this vulnerability by providing a specially crafted JSON file that triggers the heap-buffer-overflow read. By carefully manipulating the input, the attacker may be able to execute arbitrary code or gain unauthorized access to sensitive information.

Yes, this vulnerability has been fixed in the file package. Developers are advised to update to version 16756ff9286df9a43b4b6e21824975a1c6809835 or a later version to ensure they are protected against this vulnerability.

Yes, developers can implement input validation to mitigate the risk of triggering the heap-buffer-overflow read. By validating the JSON files before passing them to the json_parse function, the vulnerability can be mitigated until the package is updated.

Related vulnerabilities

Recent vulnerabilities recorded for file.

How To Fix

Minimum fixed version

16756ff9286df9a43b4b6e21824975a1c6809835

This is the first release that contains the fix.

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback