Improper Validation of Array Index Affecting github.com/golang/image/tiff package, versions *


Severity

Recommended
0.0
medium
0
10

CVSS assessment made by Snyk's Security Team

    Threat Intelligence

    Exploit Maturity
    Proof of concept
    EPSS
    0.05% (17th 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 ID SNYK-GOLANG-GITHUBCOMGOLANGIMAGETIFF-7268349
  • published 19 Jun 2024
  • disclosed 18 Jun 2024
  • credit John Wright

How to fix?

A fix was pushed into the master branch but not yet published.

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 Scores

version 4.0
version 3.1
Expand this section

Snyk

Recommended
5.3 medium
  • Attack Vector (AV)
    Network
  • Attack Complexity (AC)
    Low
  • Attack Requirements (AT)
    None
  • Privileges Required (PR)
    None
  • User Interaction (UI)
    Passive
  • Confidentiality (VC)
    None
  • Integrity (VI)
    None
  • Availability (VA)
    Low
  • Confidentiality (SC)
    None
  • Integrity (SI)
    None
  • Availability (SA)
    None