Skip to main content
COSMICBYTEZLABS
NewsSecurityHOWTOsToolsStudyTraining
ProjectsChecklistsAI RankingsNewsletterStatusTagsAbout
Subscribe

Press Enter to search or Esc to close

News
Security
HOWTOs
Tools
Study
Training
Projects
Checklists
AI Rankings
Newsletter
Status
Tags
About
RSS Feed
Reading List
Subscribe

Stay in the Loop

Get the latest security alerts, tutorials, and tech insights delivered to your inbox.

Subscribe NowFree forever. No spam.
COSMICBYTEZLABS

Your trusted source for IT intelligence, cybersecurity insights, and hands-on technical guides.

686+ Articles
118+ Guides

CONTENT

  • Latest News
  • Security Alerts
  • HOWTOs
  • Projects
  • Exam Prep

RESOURCES

  • Search
  • Browse Tags
  • Newsletter Archive
  • Reading List
  • RSS Feed

COMPANY

  • About Us
  • Contact
  • Privacy Policy
  • Terms of Service

© 2026 CosmicBytez Labs. All rights reserved.

System Status: Operational
  1. Home
  2. Security
  3. CVE-2026-40494: SAIL TGA Codec RLE Decoder Asymmetric Bounds Check (CVSS 9.8)
CVE-2026-40494: SAIL TGA Codec RLE Decoder Asymmetric Bounds Check (CVSS 9.8)

Critical Security Alert

This vulnerability is actively being exploited. Immediate action is recommended.

SECURITYCRITICALCVE-2026-40494

CVE-2026-40494: SAIL TGA Codec RLE Decoder Asymmetric Bounds Check (CVSS 9.8)

A critical heap write-past-end vulnerability in SAIL's TGA codec RLE decoder stems from an asymmetric bounds check that correctly validates run-packets but misses the literal-packet code path, enabling arbitrary code execution.

Dylan H.

Security Team

April 18, 2026
3 min read

Affected Products

  • SAIL Image Library prior to commit 45d48d1f2e8e0d73e80bc1fd5310cb57f4547302

Overview

CVE-2026-40494 is a critical (CVSS 9.8) heap write-past-end vulnerability in the SAIL image library's TGA codec. The vulnerability resides in the RLE (Run-Length Encoding) decoder within tga.c and is caused by an asymmetric bounds check — one code path is correctly guarded while its counterpart is not.

Technical Details

The TGA RLE decoder handles two distinct packet types:

  • Run-packets: A single pixel value repeated N times.
  • Literal packets: N consecutive unique pixel values read directly from the stream.

The fix commit message and NVD description confirm that at line 297 of tga.c, the run-packet path includes a correct bounds check before writing pixel data. However, the literal-packet path (the else branch) lacks an equivalent check, allowing the decoder to write pixel data past the end of the allocated output buffer.

Exploitation Mechanics

A crafted TGA file can be constructed to trigger the literal-packet code path with a pixel count that, combined with the current write offset, exceeds the buffer boundary. The decoder proceeds to write N pixels without verifying remaining capacity, resulting in:

  1. Heap write-past-end — overwriting bytes in adjacent allocations.
  2. Depending on allocator layout, this may corrupt metadata, function pointers, or other objects.
  3. In a worst-case scenario, this enables arbitrary code execution within the context of the process loading the image.

This type of asymmetric bounds check flaw is a recurring pattern in hand-rolled image codec parsers where dual code paths diverge over time and one loses its guard.

Affected Versions

All versions of SAIL prior to commit 45d48d1f2e8e0d73e80bc1fd5310cb57f4547302.

Fix

The patch adds the missing bounds check to the literal-packet branch, ensuring that both code paths validate the remaining buffer capacity before writing any pixel data.

git pull origin master
git checkout 45d48d1f2e8e0d73e80bc1fd5310cb57f4547302
cmake -B build && cmake --build build

Impact Assessment

FactorDetail
CVSS Score9.8 (Critical)
Attack VectorNetwork (via crafted TGA file)
Attack ComplexityLow
Privileges RequiredNone
User InteractionRequired (open a malicious image)
ScopeUnchanged
ConfidentialityHigh
IntegrityHigh
AvailabilityHigh

Recommendations

  • Patch immediately — update to a SAIL build at or after commit 45d48d1.
  • Audit codec symmetry — review all dual-path decoders (run/literal, compressed/uncompressed) in your image processing stack to ensure bounds checks are applied in every branch.
  • Fuzz TGA inputs — use property-based or mutation fuzzing targeting RLE boundary conditions in TGA decoding.
  • Sandbox image processing — consider running image codec workloads in isolated processes or containers to limit blast radius if exploitation occurs.

Related CVEs in This Batch

These three SAIL library CVEs (CVE-2026-40492, CVE-2026-40493, CVE-2026-40494) were disclosed together and all carry CVSS 9.8. Organizations using SAIL should apply all three patches simultaneously.

References

  • NVD: CVE-2026-40494
  • SAIL GitHub Repository
#CVE#Vulnerability#Image Processing#Heap Overflow#SAIL#TGA

Related Articles

CVE-2026-40492: SAIL XWD Codec Heap Buffer Overflow (CVSS 9.8)

A critical heap buffer overflow in the SAIL image library's XWD codec arises from a mismatch between pixel depth and bits-per-pixel, enabling arbitrary code execution via crafted image files.

3 min read

CVE-2026-40493: SAIL PSD Codec Buffer Overflow via channels * depth Miscalculation (CVSS 9.8)

A critical out-of-bounds write in SAIL's PSD codec occurs when the pixel buffer is allocated using a raw header formula that doesn't account for actual decoded size, enabling heap corruption with crafted PSD files.

3 min read

CVE-2026-6518: WordPress CMP Plugin Arbitrary File Upload and Remote Code Execution (CVSS 8.8)

The CMP Coming Soon & Maintenance Plugin for WordPress contains a critical arbitrary file upload flaw that allows subscriber-level authenticated users to upload PHP shells and achieve remote code execution on affected sites.

3 min read
Back to all Security Alerts