Skip to main content

CVE-2026-40334

LOW
Improper Null Termination (CWE-170)
2026-04-18 security-advisories@github.com
3.5
CVSS 3.1 · Vendor: github
View

Attack ChainAIDerived

Hypothetical attack flow derived from CVE metadata – not a confirmed exploit chain

  1. Access
    Connect malicious camera via USB
  2. Delivery
    libgphoto2 reads PTP packet
  3. Exploit
    strncpy copies 13 unterminated bytes
  4. Execution
    String operation reads past buffer
  5. Persist
    Out-of-bounds read occurs
  6. Impact
    Memory disclosure or crash

Vulnerability Assessment

Weakness
CWE
OWASP Top 10:2025
A05:2025 - Injection
ASVS 5.0
V1 - Encoding and Sanitization Null terminator handling
Exploitation Conditions

Physical access to a Canon camera connected to the target system running libgphoto2 is mandatory. The camera must return a malformed or malicious PTP packet containing a filename field that is exactly 13 bytes with no null terminator - this data must originate from the camera itself (via PTP protocol) to reach the vulnerable code path. The vulnerability does NOT exist in remote PTP connections over network; only direct USB camera connections are affected. Default libgphoto2 configurations with standard Canon cameras will not trigger this; the camera firmware or packets must be non-standard or deliberately crafted.

Impact

The CVSS score of 3.5 reflects low impact despite the vulnerability class. Attack Vector is Physical (AV:P), meaning the attacker must have direct access to a camera connected to the system - a significant barrier eliminating remote exploitation. Attack Complexity is Low (AC:L) and no authentication is required (PR:N), but these factors are muted by the physical access requirement. Confidentiality impact is Low (C:L) - out-of-bounds reads can leak small amounts of adjacent memory - and Availability impact is Low (A:L) via crash/denial of service. The CVSS vector explicitly eliminates remote exploitation scenarios. No EPSS score, KEV listing, or public POC has been provided; this appears to be a researcher-reported vulnerability addressed through GitHub security advisory rather than active in-the-wild exploitation. The real-world risk is low because it requires a specialized setup: a system running libgphoto2 connected to a Canon camera, with malformed firmware or crafted PTP packets from the camera itself. Most deployments use libgphoto2 on desktop Linux for casual photo import, not in contexts where camera firmware can be controlled by attackers. Patch availability (commit 259fc7d) is confirmed, reducing urgency.

Exploit ScenarioDerived

An attacker with physical access to a Linux system connected to a Canon camera modifies or supplies a malicious camera with crafted PTP firmware containing a 13-byte filename field without null termination. When libgphoto2 attempts to unpack the camera data, it copies the unterminated filename into the 13-byte buffer. A subsequent string operation (such as filename printing or logging) reads past the buffer boundary, leaking heap memory or crashing the application.

Monitor Track and reassess. Why: LOW severity (CVSS 0.1-3.9).
Patch available 0.0% exploitation probability (EPSS)

Get an e-mail when this CVE is exploited, patched or re-scored. Free account.

Alert me

AnalysisAIv1 – Apr 18, 2026

Missing null terminator in libgphoto2's ptp_unpack_Canon_FE() function allows out-of-bounds memory reads when processing Canon camera filenames. Versions up to 2.5.33 are vulnerable when a 13-byte filename without null termination is supplied, causing subsequent string operations to read beyond buffer boundaries. The vulnerability requires physical camera access and results in information disclosure or denial of service, not remote code execution.

RemediationAI

Apply the upstream fix by upgrading libgphoto2 to version 2.5.34 or later, which includes commit 259fc7d3bfe534ce4b114c464f55b448670ab873. The patch adds explicit null termination to the buffer after strncpy(). For systems unable to update immediately, reduce exposure by disconnecting untrusted or unfamiliar camera devices and avoiding use of libgphoto2 with cameras of unknown firmware origin. Because the vulnerability requires a malformed or compromised camera to trigger, the practical mitigation is patch deployment on systems that actively use libgphoto2; systems that have libgphoto2 installed but never connect cameras have negligible risk. See GitHub security advisory GHSA-ph87-cc3j-c6hm for vendor patch details and commit reference.

Affected ProductsAI

libgphoto2 versions up to and including 2.5.33 (CPE: cpe:2.3:a:gphoto:libgphoto2:*:*:*:*:*:*:*:*) are vulnerable. The vulnerability is specific to Canon PTP packet handling and only triggers when a 13-byte filename without null termination is present in camera data. Affected systems are those using libgphoto2 to interface with Canon digital cameras.

Affects your stack

Find out whether the stacks and servers you run are on an affected version.

Checking this CVE against your own stacks and servers is part of the Basic plan and up.

Technical ContextAI · show details

libgphoto2 is a camera control library used by Linux and Unix systems to interface with digital cameras via the Picture Transfer Protocol (PTP). The vulnerability exists in the Canon-specific PTP packet unpacking routine (ptp_unpack_Canon_FE) in camlibs/ptp2/ptp-pack.c at line 1377. The function uses strncpy() to copy a filename into a fixed 13-byte buffer without explicitly null-terminating the copied string. CWE-170 (Improper Null Termination) describes the root cause: when strncpy() copies exactly N bytes into an N-byte buffer, it does not append a null terminator, leaving the buffer unterminated. Any subsequent string function (strlen, strcpy, printf) will read past the buffer boundary seeking a null terminator, violating memory safety. CPE affected: cpe:2.3:a:gphoto:libgphoto2:*:*:*:*:*:*:*:* with versions up to and including 2.5.33.

Know when the next one hits your stack

  • Watch products and get an email when something new is published
  • Check this CVE against your own stack and servers
  • Exploit and PoC references, threat intelligence from 22 sources

No credit card · 7-day full trial

Severity by source

Vendor (github) PRIMARY 3.5 LOW
AV:P/AC:L/PR:N/UI:N/S:U/C:L/I:N/A:L

Primary rating from Vendor (github) · only source for this CVE.

CVSS VectorVendor: github

Attack Vector
Physical
Attack Complexity
Low
Privileges Required
None
User Interaction
None
Scope
Unchanged
Confidentiality
Low
Integrity
None
Availability
Low

DescriptionCVE.org

libgphoto2 is a camera access and control library. In versions up to and including 2.5.33, a missing null terminator exists in ptp_unpack_Canon_FE() in camlibs/ptp2/ptp-pack.c (line 1377). The function copies a filename into a 13-byte buffer using strncpy without explicitly null-terminating the result. If the source data is exactly 13 bytes with no null terminator, the buffer is left unterminated, leading to out-of-bounds reads in any subsequent string operation. Commit 259fc7d3bfe534ce4b114c464f55b448670ab873 patches the issue.

Threat Intelligence Overview

EPSS Score
0.0%
Top 96% exploitable
Data Quality
6 sources
Confidence: High
NVD CVE.org EPSS Vulnrichment GitHub VulDB

How this decision was reached

The engine reads each signal below and applies a fixed list of rules from top to bottom. The first rule that matches sets the recommended action – like a statement, every line is shown.

SignalValue
Severity LOW
CISA KEV No
Public POC No
EPSS 0.0%
Patch available Yes
Active threat No
Deciding rule
LOW severity (CVSS 0.1-3.9)
What every action level means
Emergency Immediate action required. Criteria: CRITICAL + in CISA KEV (actively exploited) without patch, OR CRITICAL + EPSS > 30% without patch, OR CRITICAL + active threat signals without patch.
Act Now Prioritize within 24-48h. Criteria: in KEV with patch available, OR CRITICAL + public POC, OR HIGH + EPSS > 10%, OR CRITICAL + active threat, OR any CRITICAL severity.
This Week Schedule remediation this week. Criteria: HIGH severity (CVSS 7.0-8.9). Patch within normal change window.
This Month Plan within 30 days. Criteria: MEDIUM severity (CVSS 4.0-6.9), lower exploitation probability. Include in regular patch cycle.
Monitor Track and reassess. Criteria: LOW severity (CVSS 0.1-3.9), minimal exploitation risk. No immediate action needed.

SSVC AssessmentENISA

SSVC Decision· derived
Defer
Exploitation
None
System Exposure· derived
Small
Automatable
No
Human Impact· derived
Low
Technical Impact
Partial

Priority Score

18
Low Medium High Critical
KEV: 0
EPSS: 0
CVSS: +18
PoC: 0
Weaponized: 0
Threat intel: 0
Gov advisory: 0

Attack Technique

A buffer overflow occurs when a program writes more data to a memory buffer than it was allocated to hold, causing the excess data to spill into adjacent memory regions.

This site uses cookies essential for authentication and security. No tracking or analytics cookies are used. Privacy Policy