Skip to content

[crash] obs-filters color-grade: LUT_*_SIZE overflows data_size → heap OOB write driven by .cube file #94

Closed

Description

@chriscoveries

Class: integer overflow into allocation size → heap out-of-bounds write, reachable from a user file (Color Grade filter path, also via scene-collection JSON).

load_cube_file (plugins/obs-filters/color-grade-filter.c:192-194) accepts LUT_1D_SIZE %u / LUT_3D_SIZE %u with no bound.

load_1d_lut/load_3d_lut (:115, :140):

const uint32_t data_size = 4 * width * width * width * sizeof(struct half);
struct half *values = bmalloc(data_size);

4 * w³ is evaluated in uint32_t and wraps before the sizeof multiply: width = 1024 already yields 4·1024³ = 2³² → data_size = 0; e.g. width = 65536 gives a small nonzero wrap. The nested write loop (:145-161, same for 1D :120-133) iterates width³ voxels and writes 4 struct half entries per voxel — bounded only by get_cube_entry finding another r g b line (:132/:159). Each extra line in the file = 8 more bytes written past the allocation.

So LUT_3D_SIZE 1024 plus N data lines writes ~8·N bytes into bmalloc(0) → deterministic heap corruption. Larger w either crashes immediately or turns filter->cube_width into a huge texture dimension at :261-265.

Fix sketch: parse into size_t, reject w above a sane ceiling (e.g. 256), and compute data_size in size_t with an overflow check before bmalloc.

— RD1

Activity

  1. chriscoveries commented on Oct 10, 2026

    @chriscoveries
    ContributorAuthor

    Fixed upstream by #113 (cube-lut.c: caps LUT_1D_SIZE_MAX 65536 / LUT_3D_SIZE_MAX 256, size_t data_size, cmocka test).

  2. added a commit that references this issue on Oct 31, 2026
    6d38498
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions