The SentinelOne Annual Threat Report - A Defenders Guide from the FrontlinesThe SentinelOne Annual Threat ReportGet the Report
Experiencing a Breach?Blog
Get StartedContact Us
SentinelOne
  • Platform
    Platform Overview
    • Singularity Platform
      Welcome to Integrated Enterprise Security
    • AI for Security
      Leading the Way in AI-Powered Security Solutions
    • Securing AI
      Accelerate AI Adoption with Secure AI Tools, Apps, and Agents.
    • How It Works
      The Singularity XDR Difference
    • Singularity Marketplace
      One-Click Integrations to Unlock the Power of XDR
    • Pricing & Packaging
      Comparisons and Guidance at a Glance
    Data & AI
    • Purple AI
      Accelerate SecOps with Generative AI
    • Singularity Hyperautomation
      Easily Automate Security Processes
    • AI-SIEM
      The AI SIEM for the Autonomous SOC
    • Singularity Data Lake
      AI-Powered, Unified Data Lake
    • Singularity Data Lake for Log Analytics
      Seamlessly Ingest Data from On-Prem, Cloud or Hybrid Environments
    Endpoint Security
    • Singularity Endpoint
      Autonomous Prevention, Detection, and Response
    • Singularity XDR
      Native & Open Protection, Detection, and Response
    • Singularity RemoteOps Forensics
      Orchestrate Forensics at Scale
    • Singularity Threat Intelligence
      Comprehensive Adversary Intelligence
    • Singularity Vulnerability Management
      Application & OS Vulnerability Management
    • Singularity Identity
      Identity Threat Detection and Response
    Cloud Security
    • Singularity Cloud Security
      Block Attacks with an AI-Powered CNAPP
    • Singularity Cloud Native Security
      Secure Cloud and Development Resources
    • Singularity Cloud Workload Security
      Real-Time Cloud Workload Protection Platform
    • Singularity Cloud Data Security
      AI-Powered Threat Detection for Cloud Storage
    • Singularity Cloud Security Posture Management
      Detect and Remediate Cloud Misconfigurations
    Securing AI
    • Prompt Security
      Secure AI Tools Across Your Enterprise
  • Why SentinelOne?
    Why SentinelOne?
    • Why SentinelOne?
      Cybersecurity Built for What’s Next
    • Our Customers
      Trusted by the World’s Leading Enterprises
    • Industry Recognition
      Tested and Proven by the Experts
    • About Us
      The Industry Leader in Autonomous Cybersecurity
    Compare SentinelOne
    • Arctic Wolf
    • Broadcom
    • CrowdStrike
    • Cybereason
    • Microsoft
    • Palo Alto Networks
    • Sophos
    • Splunk
    • Trellix
    • Trend Micro
    • Wiz
    Verticals
    • Energy
    • Federal Government
    • Finance
    • Healthcare
    • Higher Education
    • K-12 Education
    • Manufacturing
    • Retail
    • State and Local Government
  • Services
    Managed Services
    • Managed Services Overview
      Wayfinder Threat Detection & Response
    • Threat Hunting
      World-Class Expertise and Threat Intelligence
    • Managed Detection & Response
      24/7/365 Expert MDR Across Your Entire Environment
    • Incident Readiness & Response
      DFIR, Breach Readiness, & Compromise Assessments
    Support, Deployment, & Health
    • Technical Account Management
      Customer Success with Personalized Service
    • SentinelOne GO
      Guided Onboarding & Deployment Advisory
    • SentinelOne University
      Live and On-Demand Training
    • Services Overview
      Comprehensive Solutions for Seamless Security Operations
    • SentinelOne Community
      Community Login
  • Partners
    Our Network
    • MSSP Partners
      Succeed Faster with SentinelOne
    • Singularity Marketplace
      Extend the Power of S1 Technology
    • Cyber Risk Partners
      Enlist Pro Response and Advisory Teams
    • Technology Alliances
      Integrated, Enterprise-Scale Solutions
    • SentinelOne for AWS
      Hosted in AWS Regions Around the World
    • Channel Partners
      Deliver the Right Solutions, Together
    • SentinelOne for Google Cloud
      Unified, Autonomous Security Giving Defenders the Advantage at Global Scale
    • Partner Locator
      Your Go-to Source for Our Top Partners in Your Region
    Partner Portal→
  • Resources
    Resource Center
    • Case Studies
    • Data Sheets
    • eBooks
    • Reports
    • Videos
    • Webinars
    • Whitepapers
    • Events
    View All Resources→
    Blog
    • Feature Spotlight
    • For CISO/CIO
    • From the Front Lines
    • Identity
    • Cloud
    • macOS
    • SentinelOne Blog
    Blog→
    Tech Resources
    • SentinelLABS
    • Ransomware Anthology
    • Cybersecurity 101
  • About
    About SentinelOne
    • About SentinelOne
      The Industry Leader in Cybersecurity
    • Investor Relations
      Financial Information & Events
    • SentinelLABS
      Threat Research for the Modern Threat Hunter
    • Careers
      The Latest Job Opportunities
    • Press & News
      Company Announcements
    • Cybersecurity Blog
      The Latest Cybersecurity Threats, News, & More
    • FAQ
      Get Answers to Our Most Frequently Asked Questions
    • DataSet
      The Live Data Platform
    • S Foundation
      Securing a Safer Future for All
    • S Ventures
      Investing in the Next Generation of Security, Data and AI
  • Pricing
Get StartedContact Us
CVE Vulnerability Database
Vulnerability Database/CVE-2022-31627

CVE-2022-31627: PHP Use After Free Vulnerability

CVE-2022-31627 is a use after free vulnerability in PHP's fileinfo functions that can cause heap corruption through improper memory deallocation. This article covers technical details, affected versions, and mitigation.

Published: February 11, 2026

CVE-2022-31627 Overview

In PHP versions 8.1.x below 8.1.8, a heap corruption vulnerability exists in fileinfo functions such as finfo_buffer. Due to an incorrect patch applied to the third-party code from libmagic, an incorrect function may be used to free allocated memory, which may lead to heap corruption. This vulnerability represents a serious memory safety issue that could potentially be exploited for remote code execution.

Critical Impact

This heap corruption vulnerability in PHP's fileinfo extension could allow attackers to corrupt heap memory, potentially leading to arbitrary code execution or denial of service on systems processing untrusted file data through finfo_buffer and related functions.

Affected Products

  • PHP versions 8.1.x below 8.1.8
  • Applications using PHP fileinfo functions (finfo_buffer, finfo_file, etc.)
  • Web servers running vulnerable PHP versions with fileinfo extension enabled

Discovery Timeline

  • 2022-07-28 - CVE-2022-31627 published to NVD
  • 2024-11-21 - Last updated in NVD database

Technical Details for CVE-2022-31627

Vulnerability Analysis

This vulnerability (CWE-590: Free of Memory not on the Heap, CWE-787: Out-of-bounds Write) stems from improper memory management within PHP's fileinfo extension. The fileinfo extension relies on libmagic, a third-party library for determining file types based on content. An incorrectly applied patch to the libmagic integration caused a mismatch between memory allocation and deallocation functions.

When PHP's fileinfo functions process data, memory is allocated for internal operations. Due to the flawed patch, a different (incorrect) function is called to free this memory than the one used to allocate it. This mismatch corrupts the heap metadata, leading to heap corruption. An attacker who can influence the data processed by fileinfo functions could potentially exploit this corruption for arbitrary code execution.

Root Cause

The root cause is a patch integration error in PHP's bundled libmagic code. When upstream libmagic patches were applied to PHP, the memory deallocation calls were not properly matched to their corresponding allocation calls. This results in using an incompatible free function (such as calling free() on memory allocated with a different allocator, or vice versa), which violates the memory management contract and corrupts heap structures.

Attack Vector

The attack vector is network-based, requiring no privileges or user interaction. An attacker can exploit this vulnerability by:

  1. Sending specially crafted file content to a PHP application that uses fileinfo functions
  2. Triggering the vulnerable code path through finfo_buffer(), finfo_file(), or related functions
  3. Exploiting the resulting heap corruption to achieve code execution or crash the application

The vulnerability can be triggered when PHP applications analyze file types or MIME types of user-supplied content, a common operation in file upload handlers and content management systems.

Detection Methods for CVE-2022-31627

Indicators of Compromise

  • Unexpected PHP process crashes or segmentation faults when processing file uploads
  • Anomalous memory patterns or heap corruption errors in PHP error logs
  • Increased memory usage or memory allocation failures in PHP-FPM workers
  • Core dumps indicating heap corruption in fileinfo-related operations

Detection Strategies

  • Monitor PHP error logs for segmentation faults and memory-related errors when fileinfo functions are invoked
  • Implement application-level logging around finfo_buffer() and finfo_file() calls to detect anomalous behavior
  • Deploy web application firewalls (WAF) to inspect file upload payloads for exploit patterns
  • Use memory sanitizers (AddressSanitizer) in development/staging environments to detect heap corruption

Monitoring Recommendations

  • Enable comprehensive PHP error logging with stack traces for memory-related errors
  • Configure alerting on PHP-FPM worker restarts or crashes
  • Monitor for unusual patterns in file upload functionality
  • Implement application performance monitoring (APM) to track fileinfo function behavior

How to Mitigate CVE-2022-31627

Immediate Actions Required

  • Upgrade PHP to version 8.1.8 or later immediately
  • If immediate upgrade is not possible, consider disabling the fileinfo extension temporarily
  • Review and restrict file upload functionality until patching is complete
  • Implement strict input validation on all file upload endpoints

Patch Information

The vulnerability is fixed in PHP version 8.1.8 and later. Organizations should upgrade to the latest PHP 8.1.x release to ensure all security patches are applied. The official bug report is available at PHP Bug Report #81723.

Additional security advisories have been published by:

  • Gentoo GLSA 2022-20
  • NetApp Security Advisory NTAP-20220826-0008

Workarounds

  • Disable the fileinfo extension in php.ini if not required for application functionality
  • Implement a proxy layer that sanitizes or validates file content before passing to PHP
  • Restrict file uploads to authenticated users only to reduce attack surface
  • Use alternative file type detection methods that do not rely on PHP's fileinfo extension
bash
# Configuration example - Disable fileinfo extension temporarily
# Add to php.ini or create a separate configuration file

# Option 1: Comment out or remove the extension line
# extension=fileinfo

# Option 2: Disable via command line for CLI scripts
php -d "extension=" -r "// your script"

# Verify fileinfo is disabled
php -m | grep -i fileinfo

Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

  • Vulnerability Details
  • TypeUse After Free

  • Vendor/TechPhp

  • SeverityCRITICAL

  • CVSS Score9.8

  • EPSS Probability0.18%

  • Known ExploitedNo
  • CVSS Vector
  • CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H
  • Impact Assessment
  • ConfidentialityLow
  • IntegrityNone
  • AvailabilityHigh
  • CWE References
  • CWE-590

  • CWE-787
  • Technical References
  • Gentoo GLSA 2022-20

  • NetApp Security Advisory NTAP-20220826-0008
  • Vendor Resources
  • PHP Bug Report #81723
  • Related CVEs
  • CVE-2021-21708: PHP Use-After-Free Vulnerability

  • CVE-2020-7068: PHP PHAR Use-After-Free Vulnerability

  • CVE-2026-22427: GoTravel Path Traversal Vulnerability

  • CVE-2025-69409: PJ Coaching Theme Path Traversal Flaw
Default Legacy - Prefooter | Experience the World’s Most Advanced Cybersecurity Platform

Experience the World’s Most Advanced Cybersecurity Platform

See how our intelligent, autonomous cybersecurity platform can protect your organization now and into the future.

Try SentinelOne
  • Get Started
  • Get a Demo
  • Product Tour
  • Why SentinelOne
  • Pricing & Packaging
  • FAQ
  • Contact
  • Contact Us
  • Customer Support
  • SentinelOne Status
  • Language
  • Platform
  • Singularity Platform
  • Singularity Endpoint
  • Singularity Cloud
  • Singularity AI-SIEM
  • Singularity Identity
  • Singularity Marketplace
  • Purple AI
  • Services
  • Wayfinder TDR
  • SentinelOne GO
  • Technical Account Management
  • Support Services
  • Verticals
  • Energy
  • Federal Government
  • Finance
  • Healthcare
  • Higher Education
  • K-12 Education
  • Manufacturing
  • Retail
  • State and Local Government
  • Cybersecurity for SMB
  • Resources
  • Blog
  • Labs
  • Case Studies
  • Videos
  • Product Tours
  • Events
  • Cybersecurity 101
  • eBooks
  • Webinars
  • Whitepapers
  • Press
  • News
  • Ransomware Anthology
  • Company
  • About Us
  • Our Customers
  • Careers
  • Partners
  • Legal & Compliance
  • Security & Compliance
  • Investor Relations
  • S Foundation
  • S Ventures

©2026 SentinelOne, All Rights Reserved.

Privacy Notice Terms of Use

English