Heap-buffer-overflow in json_parse in file
Summary
OSV-2022-468: Heap-buffer-overflow in json_parse. Affects file versions >= 87060b287acdc06297bb73e668445e57023f3a75, < 46976e05f97e4b2bc77476a16f7107ff0be12df1. Fixed in 46976e05f97e4b2bc77476a16f7107ff0be12df1. How to fix ↓
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.
No signup required · Results in about 60 seconds
Background
The 'file' package is an open-source tool that is used to determine the type of a file by examining its contents. It provides functionality to identify the file format and metadata, making it a widely used utility in various applications. However, a vulnerability has been discovered in the json_parse function of the 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 condition.
Vulnerability Detail
The vulnerability in the 'file' package arises from a heap-buffer-overflow read in the json_parse function. This can occur when parsing a specially crafted JSON file, leading to the reading of more data than allocated in the buffer. An attacker can exploit this vulnerability by providing a malicious JSON file, potentially resulting in the execution of arbitrary code or crashing the application. The vulnerability has been assigned a severity rating of HIGH.
How To Fix
Minimum fixed version
46976e05f97e4b2bc77476a16f7107ff0be12df1
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, users can avoid parsing untrusted JSON files using the 'file' package until the fix is applied. It is recommended to validate the source and integrity of JSON files before parsing them to mitigate the risk of exploitation.
Conclusion
The 'file' package is vulnerable to a heap-buffer-overflow read in the json_parse function. This can be exploited by providing a specially crafted JSON file, potentially leading to arbitrary code execution or a denial-of-service condition. It is crucial to update to a fixed version of the package or apply the recommended workaround to mitigate the risk. For further support on vulnerability remediation, please contact DevNack.com.
See every vulnerability recorded for file →
FAQ
This vulnerability can potentially allow an attacker to execute arbitrary code or cause a denial-of-service condition by providing a specially crafted JSON file.
At the time of this report, there is no known public exploit for this vulnerability. However, it is important to apply the fix as soon as possible to prevent potential exploitation.
Yes, this vulnerability can be exploited remotely if an application using the 'file' package parses untrusted JSON files received from external sources.
No, only versions introduced before commit 46976e05f97e4b2bc77476a16f7107ff0be12df1 in the 'file' repository are affected. Updating to the fixed version will resolve the vulnerability.
You can use the Vulert Playground at Vulert Scanner to check if your application is affected by this vulnerability. Simply upload your package-lock.json file and the playground will provide real-time alerts for open-source vulnerabilities, including this one.
References
Related vulnerabilities
Recent vulnerabilities recorded for file.