Out-of-bounds WriteWeakness · CWE-787

CVE-2026-40494

CRITICAL · 9.8 CVSS v3.1 Published 2026-04-18
Patch available
A vendor patch is available. No clean upgrade release — apply the published patch.
See remediation →
100/100
Remediation priority · Urgent
Remotely reachable No privileges Zero-click Patch available

Official description Straight from the sourceThe vendor's or NVD's own wording, published unedited. Authoritative, but often terse — it says what broke, rarely what to do.

NVD · unedited
SAIL is a cross-platform library for loading and saving images with support for animation, metadata, and ICC profiles. Prior to commit 45d48d1f2e8e0d73e80bc1fd5310cb57f4547302, the TGA codec's RLE decoder in `tga.c` has an asymmetric bounds check vulnerability. The run-packet path (line 297) correctly clamps the repeat count to the remaining buffer space, but the raw-packet path (line 305-311) has no equivalent bounds check. This allows writing up to 496 bytes of attacker-controlled data past the end of a heap buffer. Commit 45d48d1f2e8e0d73e80bc1fd5310cb57f4547302 patches the issue.

Technical summary Written by usOur analysis, written from the advisory, the CVSS vector and the affected-version data. It adds context the advisory leaves out, and never invents facts that are not in the source.

dbcve analysis · high confidence

The TGA codec's RLE decoder in tga.c has an asymmetric bounds check vulnerability where the run-packet path correctly clamps the repeat count to remaining buffer space, but the raw-packet path (lines 305-311) lacks equivalent bounds checking. This allows writing up to 496 bytes of attacker-controlled data past the end of a heap buffer, resulting in a heap buffer overflow.

MitigationUpdate SAIL library to include commit 45d48d1f2e8e0d73e80bc1fd5310cb57f4547302 which adds proper bounds checking to the raw-packet path in tga.c, or apply the patch to add equivalent buffer length validation before writing raw packet data.

Verify against the referenced sources before acting — the references below are authoritative for this CVE, this summary is not.

CVSS breakdown How the score is builtThe industry scoring standard. It rates how the flaw is reached, what it takes to exploit, and what an attacker gains — the score is derived from those, not the other way round.

From the vector
Attack vector
Network
Complexity
Low
Privileges
None
User interaction
None
Scope
Unchanged
Confidentiality
High
Integrity
High
Availability
High

CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H

Am I affected? How to checkSteps we derive from the advisory and the affected-version data, so you can decide whether this CVE reaches your setup. They are a guide, not a scan — your own configuration is the authority.

dbcve checks

Work through these to decide whether this CVE applies to you.

  1. Identify SAIL library installation
    Search for SAIL library files (libsail.so, sail.h, or related binaries) in the system or within the application's dependencies
    Affected if SAIL library is present in the environment
  2. Determine SAIL library version
    Run commands such as 'pkg-config --modversion sail' or check the library file metadata (ldd, file version info) to obtain the SAIL version
    Affected if The installed version is older than the patched version containing commit 45d48d1f2e8e0d73e80bc1fd5310cb57f4547302
  3. Locate tga.c source file
    Find the tga.c file within the SAIL library source code or the application's codebase
    Affected if The tga.c file exists and contains the RLE decoder implementation
  4. Inspect raw-packet bounds check
    Examine lines 305-311 in tga.c and verify whether bounds checking (buffer length validation) is performed before writing raw packet data to the buffer
    Affected if The raw-packet path (lines 305-311) lacks buffer length validation before writing data, allowing writes beyond buffer boundaries
  5. Confirm TGA image processing
    Review application logs, code, or runtime behavior to determine if TGA format images are being decoded using the SAIL library
    Affected if The application processes TGA images using the vulnerable RLE decoder in tga.c

A user is affected if they use a version of the SAIL library prior to the fix commit and process TGA images with the library's RLE decoder, allowing heap buffer overflow via the unchecked raw-packet path.

Generated from the published advisory. Verify against your own configuration.

Check your environment

Paste your version and any relevant configuration and it will be compared against the affected criteria above. Do not include secrets or credentials.

AI-assisted, checked against the advisory. Informational, not a guarantee.

Remediation Closing itWhat it takes to close this. Where a vendor fix exists we point at it; where none exists we say so plainly, and can build one. Effort estimates are scoped from the advisory, not from your codebase.

dbcve · scoped
Patch available Apply the vendor patch
Vendor patch github.com →
Interim mitigation

Update SAIL library to include commit 45d48d1f2e8e0d73e80bc1fd5310cb57f4547302 which adds proper bounds checking to the raw-packet path in tga.c, or apply the patch to add equivalent buffer length validation before writing raw packet data.

Recommended fix Moderate confidence
  1. 1. Locate the TGA codec source file (tga.c) in the SAIL library codebase
  2. 2. Navigate to the RLE decoder function, specifically around lines 297-311
  3. 3. Review the run-packet path at line 297 which correctly clamps the repeat count to remaining buffer space
  4. 4. Add equivalent bounds checking to the raw-packet path (lines 305-311) to prevent writing past the end of the heap buffer
  5. 5. The fix should ensure that raw packet size does not exceed remaining buffer space before performing the memcpy operation
  6. 6. Apply the bounds check logic similar to the run-packet path: clamp the packet size to the remaining buffer capacity
  7. 7. Rebuild the library after applying the patch
  8. 8. Test the TGA codec with crafted RLE-compressed TGA images to verify the vulnerability is resolved

Generated from the published advisory — verify against the referenced sources before acting.

Have this fixed Scoped from the published advisory
  • Consultation2.0 h
  • Implementation4.0 h
  • Testing6.0 h
  • Review / QA3.0 h
15.0 hours of engineering $2,560
Get the patch applied

An estimate, not a bill — we confirm scope with you before any work starts. Need it this week? Rush from $4,096.

Scan for this in your stack

Free · runs locally
dbcve dependency scanner

Check whether your project pulls in CVE-2026-40494 — or any other known-vulnerable package — straight from your lock files. Free and open source; it runs locally and uploads nothing.

References Go to the primary sourcePrimary sources — vendor advisories, patches and trackers. Where our summary and a reference disagree, the reference wins.

Primary sources

Practitioner notes

Contributed

Peer-ranked notes from engineers who’ve handled CVE-2026-40494 in production — separate from our analysis above.

No notes yet

Be the first to add a field note for this CVE — a mitigation you’ve verified, a version caveat, or a link to a working fix. Sign in above to contribute.

What this is

A place for practitioners to share what actually worked: a mitigation you’ve tested, a configuration change, a version- or environment-specific caveat, or a link to a verified patch. The most useful notes rise to the top as peers upvote them, so the signal stays high.

What belongs here
  • Verified mitigations, workarounds, and config changes
  • Version or environment caveats, and links to real fixes
  • No weaponised exploit code, or anything meant to cause harm
  • No spam, self-promotion, credentials, or personal data