Join the Cyber Forum: Threat Intel on May 12, 2026 to learn how AI is reshaping threat defense.Join the Virtual Cyber Forum: Threat IntelRegister Now
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
    • AI Data Pipelines
      Security Data Pipeline for AI SIEM and Data Optimization
    • 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-2026-40339

CVE-2026-40339: libgphoto2 Buffer Overflow Vulnerability

CVE-2026-40339 is a buffer overflow flaw in libgphoto2 that causes out-of-bounds reads in Sony camera handling. This article covers the technical details, affected versions up to 2.5.33, impact, and mitigation.

Published: April 23, 2026

CVE-2026-40339 Overview

CVE-2026-40339 is an out-of-bounds read vulnerability in libgphoto2, a widely-used camera access and control library. Versions up to and including 2.5.33 contain a flaw in the ptp_unpack_Sony_DPD() function located in camlibs/ptp2/ptp-pack.c (line 842). The vulnerability occurs because the function reads the FormFlag byte via dtoh8o(data, *poffset) without performing a prior bounds check. While the standard ptp_unpack_DPD() function at lines 686–687 correctly validates *offset + sizeof(uint8_t) > dpdlen before this same read operation, the Sony variant omits this critical validation entirely.

Critical Impact

An attacker with physical access to a system running a vulnerable version of libgphoto2 could potentially trigger an out-of-bounds read, leading to information disclosure or application crashes when connecting a malicious or specially crafted camera device.

Affected Products

  • libgphoto2 versions up to and including 2.5.33
  • Applications and systems that depend on libgphoto2 for camera communication

Discovery Timeline

  • 2026-04-18 - CVE CVE-2026-40339 published to NVD
  • 2026-04-20 - Last updated in NVD database

Technical Details for CVE-2026-40339

Vulnerability Analysis

This out-of-bounds read vulnerability (CWE-125) exists within the Sony-specific Device Property Description (DPD) unpacking routine in libgphoto2. When parsing PTP (Picture Transfer Protocol) data from Sony cameras, the ptp_unpack_Sony_DPD() function fails to validate buffer boundaries before reading the FormFlag byte. This inconsistency with the standard ptp_unpack_DPD() implementation, which properly validates bounds, creates a security gap that can be exploited through physical access to a USB port.

The vulnerability requires physical access to exploit, limiting its attack surface. However, in environments where USB ports are accessible to untrusted parties or when connecting unknown camera devices, this vulnerability could be leveraged to read memory beyond the allocated buffer boundaries, potentially exposing sensitive information or causing denial of service through application crashes.

Root Cause

The root cause is a missing bounds check in the Sony-specific DPD unpacking function. The standard implementation properly validates that sufficient data exists in the buffer before reading (*offset + sizeof(uint8_t) > dpdlen), but this safety check was not replicated in the ptp_unpack_Sony_DPD() variant. This oversight allows the function to read beyond the allocated buffer when processing malformed or maliciously crafted PTP data.

Attack Vector

Exploitation requires physical access to a USB port on the target system. An attacker would need to connect a malicious device that presents itself as a Sony camera and provides specially crafted PTP responses designed to trigger the out-of-bounds read. The malicious device would send DPD data that causes the function to read past the end of the allocated buffer when parsing the FormFlag field.

c
 	   code or the Data Type is a string (with two empty strings as
 	   values). In both cases Form Flag should be set to 0x00 and FORM is
 	   not present. */
 	if (*poffset==PTP_dpd_Sony_DefaultValue)
 		return 1;
+	if (*poffset + sizeof(uint8_t) > dpdlen)
+		return 1;

 	dpd->FormFlag = dtoh8o(data, *poffset);
 	ptp_debug (params, "formflag 0x%04x", dpd->FormFlag);

Source: GitHub Commit

The patch adds the missing bounds check before the FormFlag read operation, ensuring that the buffer contains sufficient data before attempting to access it.

Detection Methods for CVE-2026-40339

Indicators of Compromise

  • Unexpected crashes in applications using libgphoto2 when connecting camera devices
  • Segmentation faults or memory access violations in processes interfacing with USB camera hardware
  • Unusual memory read patterns in processes utilizing the libgphoto2 library

Detection Strategies

  • Monitor system logs for crashes or errors related to libgphoto2 or camera-related applications
  • Implement USB device monitoring to detect unauthorized or suspicious camera device connections
  • Use memory sanitizers (ASan, MSan) in development and testing environments to detect out-of-bounds reads

Monitoring Recommendations

  • Enable enhanced logging for USB device connections and libgphoto2 interactions
  • Deploy endpoint detection solutions that monitor for unusual memory access patterns
  • Implement physical security controls for USB ports in sensitive environments

How to Mitigate CVE-2026-40339

Immediate Actions Required

  • Update libgphoto2 to a version containing commit 09f8a940b1e418b5693f5c11e3016a1ad2cea62d or later
  • Restrict physical access to USB ports on systems in sensitive environments
  • Consider disabling USB camera support on systems where it is not required

Patch Information

The vulnerability has been fixed in commit 09f8a940b1e418b5693f5c11e3016a1ad2cea62d. Users should update to the latest version of libgphoto2 that includes this security fix. The patch adds the missing bounds check in the ptp_unpack_Sony_DPD() function to validate that sufficient data exists before reading the FormFlag byte.

For more information, see the GitHub Security Advisory and the patch commit.

Workarounds

  • Implement USB port blocking or whitelisting policies to prevent unauthorized device connections
  • Use USB device authorization controls available in modern operating systems to restrict camera device access
  • Consider deploying USB host controller guards in high-security environments
bash
# Configuration example - Disable USB camera access on Linux systems
# Add udev rule to block unauthorized camera devices
echo 'SUBSYSTEM=="usb", ATTR{bDeviceClass}=="06", MODE="0000"' | sudo tee /etc/udev/rules.d/99-block-ptp-cameras.rules
sudo udevadm control --reload-rules

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

  • Vulnerability Details
  • TypeBuffer Overflow

  • Vendor/TechLibgphoto2

  • SeverityMEDIUM

  • CVSS Score5.2

  • EPSS Probability0.01%

  • Known ExploitedNo
  • CVSS Vector
  • CVSS:3.1/AV:P/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:L
  • Impact Assessment
  • ConfidentialityLow
  • IntegrityNone
  • AvailabilityLow
  • CWE References
  • CWE-125
  • Technical References
  • GitHub Commit Update

  • GitHub Security Advisory
  • Related CVEs
  • CVE-2026-40338: libgphoto2 Buffer Overflow Vulnerability

  • CVE-2026-40333: libgphoto2 Buffer Overflow Vulnerability

  • CVE-2026-40334: libgphoto2 Buffer Overflow Vulnerability

  • CVE-2026-40335: libgphoto2 Buffer Overflow Vulnerability
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