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
    • 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-40340

CVE-2026-40340: libgphoto2 Buffer Overflow Vulnerability

CVE-2026-40340 is a buffer overflow flaw in libgphoto2 versions up to 2.5.33 that causes out-of-bounds reads in camera control functions. This article covers technical details, affected versions, and mitigation.

Published: April 23, 2026

CVE-2026-40340 Overview

CVE-2026-40340 is an out-of-bounds read vulnerability affecting libgphoto2, a widely-used camera access and control library. The vulnerability exists in the ptp_unpack_OI() function within camlibs/ptp2/ptp-pack.c (lines 530–563). The flaw stems from insufficient boundary validation where the function validates len < PTP_oi_SequenceNumber (i.e., len < 48) but subsequently accesses offsets 48–56, reading up to 9 bytes beyond the validated boundary via the Samsung Galaxy 64-bit objectsize detection heuristic.

Critical Impact

Physical access exploitation could lead to disclosure of sensitive memory contents or cause application crashes, impacting confidentiality and availability of systems using libgphoto2 for camera communications.

Affected Products

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

Discovery Timeline

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

Technical Details for CVE-2026-40340

Vulnerability Analysis

This out-of-bounds read vulnerability (CWE-125) occurs in the PTP ObjectInfo parsing logic. The ptp_unpack_OI() function is responsible for unpacking Picture Transfer Protocol (PTP) ObjectInfo structures received from connected cameras. A specific code path designed to handle Samsung Galaxy devices with 64-bit object sizes fails to properly validate buffer boundaries before accessing memory at offsets 48–56.

The vulnerability requires physical access to exploit, as an attacker would need to connect a malicious or specially-crafted device that sends malformed PTP packets. Upon successful exploitation, an attacker could read up to 9 bytes of adjacent memory, potentially disclosing sensitive information, or trigger a denial of service through application crashes.

Root Cause

The root cause is insufficient boundary checking in the Samsung Galaxy 64-bit objectsize detection heuristic. The original validation only ensures the buffer length is at least 48 bytes (len < PTP_oi_SequenceNumber), but the subsequent code path accesses memory at offsets 48–56 without verifying the buffer contains sufficient data. This disconnect between validation and access creates the out-of-bounds read condition.

Attack Vector

The attack vector requires physical access to the target system. An attacker would need to:

  1. Connect a malicious USB device masquerading as a PTP-compatible camera
  2. Send specially crafted PTP ObjectInfo packets with insufficient data length
  3. Trigger the Samsung Galaxy detection heuristic code path
  4. Cause the vulnerable function to read beyond the allocated buffer

The physical access requirement limits the exploitability, though it remains a concern for shared workstations, kiosk systems, or scenarios where USB device connections are not strictly controlled.

c
 {
 	char *capture_date;
 
-	if (!data || len < PTP_oi_SequenceNumber)
+	if (!data || len < PTP_oi_filenamelen + 5)
 		return;
 
 	oi->Filename = oi->Keywords = NULL;

Source: GitHub Commit Reference

The security patch modifies the boundary check from PTP_oi_SequenceNumber to PTP_oi_filenamelen + 5, ensuring the buffer is validated to contain all data that will be accessed, including the offsets used by the Samsung Galaxy detection logic.

Detection Methods for CVE-2026-40340

Indicators of Compromise

  • Unexpected crashes or segmentation faults in applications using libgphoto2
  • Unusual USB device connection events followed by application instability
  • Memory access violations in ptp_unpack_OI() or related PTP parsing functions
  • Log entries indicating malformed PTP ObjectInfo packets from connected devices

Detection Strategies

  • Monitor for segmentation faults or memory access errors in processes linked against libgphoto2
  • Implement USB device whitelisting to detect unauthorized PTP device connections
  • Deploy memory sanitizers (AddressSanitizer) in development environments to detect out-of-bounds accesses
  • Review system logs for unusual camera device enumeration patterns

Monitoring Recommendations

  • Enable application crash reporting for software utilizing libgphoto2
  • Monitor USB connection events for unexpected PTP device class connections
  • Implement endpoint detection solutions to track USB device activity
  • Set up alerts for repeated application crashes involving camera access functionality

How to Mitigate CVE-2026-40340

Immediate Actions Required

  • Update libgphoto2 to a version containing commit 7c7f515bc88c3d0c4098ac965d313518e0ccbe33 or later
  • Review and restrict USB device connection policies on sensitive systems
  • Implement USB device whitelisting where possible
  • Consider disabling unused USB ports on high-security workstations

Patch Information

The vulnerability is fixed in commit 7c7f515bc88c3d0c4098ac965d313518e0ccbe33. The fix corrects the boundary validation in ptp_unpack_OI() to ensure all accessed offsets are within the validated buffer range. Organizations should update to a libgphoto2 version containing this fix or apply the patch manually if building from source.

For additional details, refer to the GitHub Security Advisory and the patch commit.

Workarounds

  • Restrict physical access to systems running libgphoto2-based applications
  • Disable USB ports or implement strict USB device access controls via udev rules
  • Use USB lockdown solutions to prevent unauthorized device connections
  • Consider network isolation for systems that must remain unpatched temporarily
bash
# Example udev rule to restrict PTP device access
# Add to /etc/udev/rules.d/99-ptp-restrict.rules
SUBSYSTEM=="usb", ATTR{bDeviceClass}=="06", MODE="0000"
# Reload udev rules
sudo udevadm control --reload-rules
sudo udevadm trigger

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 Score6.1

  • 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:H
  • Impact Assessment
  • ConfidentialityLow
  • IntegrityNone
  • AvailabilityHigh
  • CWE References
  • CWE-125
  • Technical References
  • GitHub Commit Reference

  • 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