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-40335

CVE-2026-40335: libgphoto2 Buffer Overflow Vulnerability

CVE-2026-40335 is a buffer overflow flaw in libgphoto2 affecting versions up to 2.5.33, caused by an out-of-bounds read in ptp_unpack_DPV(). This article covers technical details, affected versions, and mitigation.

Published: April 23, 2026

CVE-2026-40335 Overview

CVE-2026-40335 is an out-of-bounds read vulnerability affecting libgphoto2, a widely used camera access and control library. The vulnerability exists in the ptp_unpack_DPV() function within camlibs/ptp2/ptp-pack.c at lines 622-629. Specifically, the UINT128 and INT128 case handlers advance the offset pointer by 16 bytes without properly verifying that 16 bytes remain available in the buffer. The existing boundary check at line 609 only confirms that *offset < total (guaranteeing at least 1 byte is available), leaving up to 15 bytes unvalidated and potentially triggering an out-of-bounds memory read.

Critical Impact

Physical access to a system with a malicious or specially crafted camera device could allow an attacker to read sensitive data from memory beyond buffer boundaries, potentially leaking confidential information or causing application instability.

Affected Products

  • libgphoto2 versions up to and including 2.5.33
  • Applications and systems integrating libgphoto2 for camera communication
  • Linux distributions packaging vulnerable libgphoto2 versions

Discovery Timeline

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

Technical Details for CVE-2026-40335

Vulnerability Analysis

This vulnerability is classified as CWE-125 (Out-of-Bounds Read). The flaw occurs during the unpacking of Picture Transfer Protocol (PTP) Device Property Values when handling 128-bit integer types. The ptp_unpack_DPV() function processes various data types from camera devices, and when encountering UINT128 or INT128 values, it unconditionally advances the buffer offset by 16 bytes.

The core issue stems from insufficient boundary validation—the function only verifies that at least one byte remains in the buffer before processing, rather than confirming that the full 16 bytes required for 128-bit integers are available. This allows a malicious device to craft PTP responses that trigger reads beyond the allocated buffer boundaries.

Root Cause

The root cause is an insufficient bounds check in the switch-case handlers for PTP_DTC_UINT128 and PTP_DTC_INT128 data types. The entry condition at line 609 (*offset < total) provides minimal validation, only ensuring at least 1 byte exists. When processing 128-bit types, the code blindly increments the offset by 16 without verifying buffer capacity, creating a window where 15 bytes could be read from unallocated memory.

Attack Vector

This vulnerability requires physical access to the target system (AV:P). An attacker would need to connect a malicious or compromised camera device that sends specially crafted PTP responses containing UINT128 or INT128 values when the buffer does not contain sufficient data. When the vulnerable function processes these responses, it reads beyond the buffer boundaries, potentially exposing sensitive memory contents or causing the application to crash.

c
// Security patch in camlibs/ptp2/ptp-pack.c
// Source: https://github.com/gphoto/libgphoto2/commit/433bde9888d70aa726e32744cd751d7dbe94379a

 	case PTP_DTC_UINT64: CTVAL(value->u64,dtoh64a); break;
 
 	case PTP_DTC_UINT128:
+		if (total - *offset < 16)
+			return 0;
 		*offset += 16;
 		/*fprintf(stderr,"unhandled unpack of uint128n");*/
 		break;
 	case PTP_DTC_INT128:
+		if (total - *offset < 16)
+			return 0;
 		*offset += 16;
 		/*fprintf(stderr,"unhandled unpack of int128n");*/
 		break;

The patch adds explicit validation to ensure 16 bytes remain in the buffer before advancing the offset, returning 0 (indicating failure) if insufficient data is available.

Detection Methods for CVE-2026-40335

Indicators of Compromise

  • Unexpected crashes or segmentation faults in applications using libgphoto2 when connecting camera devices
  • Memory access violations logged by system monitoring tools during PTP communication
  • Unusual camera device enumeration or connection behavior
  • Application core dumps showing memory access issues in ptp_unpack_DPV() or related functions

Detection Strategies

  • Monitor system logs for segmentation faults or memory access errors in processes using libgphoto2
  • Deploy memory sanitizers (AddressSanitizer, Valgrind) in development and testing environments to catch out-of-bounds reads
  • Implement USB device monitoring to detect unauthorized or suspicious camera device connections
  • Use SentinelOne's behavioral AI to detect anomalous memory access patterns in camera-handling applications

Monitoring Recommendations

  • Enable verbose logging for applications that interface with camera devices via libgphoto2
  • Monitor /var/log/syslog and /var/log/messages for PTP-related errors or crashes
  • Deploy endpoint detection solutions capable of monitoring USB device enumeration events
  • Establish baseline behavior for camera communication processes to identify deviations

How to Mitigate CVE-2026-40335

Immediate Actions Required

  • Update libgphoto2 to a patched version that includes commit 433bde9888d70aa726e32744cd751d7dbe94379a
  • Restrict physical USB port access on sensitive systems where feasible
  • Implement USB device whitelisting to prevent unauthorized camera devices from connecting
  • Audit systems to identify applications dependent on vulnerable libgphoto2 versions

Patch Information

The vulnerability has been addressed in commit 433bde9888d70aa726e32744cd751d7dbe94379a. This patch adds proper bounds checking for UINT128 and INT128 data types, ensuring that 16 bytes are available in the buffer before advancing the offset. Users should update to a libgphoto2 version containing this fix. Refer to the GitHub Security Advisory and GitHub Commit Details for additional information.

Workarounds

  • Disable or restrict USB port access on systems where camera functionality is not required
  • Implement USB device class filtering to block unauthorized PTP/MTP devices at the kernel level
  • Use USB guard solutions to whitelist only trusted camera devices by vendor and product ID
  • Consider network isolation for systems that must use vulnerable libgphoto2 versions until patches can be applied
bash
# Example: Block PTP/MTP device class using usbguard
# Install usbguard and configure device policy
sudo apt-get install usbguard
# Create policy to block unauthorized imaging devices (class 06h)
echo 'block with-interface equals { 06:*:* }' | sudo tee -a /etc/usbguard/rules.conf
sudo systemctl restart usbguard

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 Details

  • 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-40339: 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