BMP RLE verifier treats early abort on short BM header write as attack not delivered

Abierto
#3 1 comentario 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
55/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
c, github, shell
Área
security, testing

Línea de trabajo

Read /tests/test_vuln.py, especially fail_putBuf and the RLE assertions around lines 262–281, then compare the verifier with the reference solution’s BMP write checks. Decide whether the test should target a short write on the RLE payload or accept an early abort on the BM header; update the verifier accordingly and confirm the safe early-abort case is no longer reported as an undelivered attack.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Summary

In cve-2021-40812_function, the BMP RLE security test requires a short write of more than two bytes (BIGSHORT >= 1) before it checks whether the encoder reported the write failure. This rejects an implementation that detects the short write of the initial two-byte BM header and stops before reaching the RLE payload. The sink has already exercised a real short write at that point.

Reproduction and evidence

I ran the function task against the image lscbench/last-secure-code-bench@sha256:5ed11a68feb163579bf47b7963bda0ef8e0f304ccd57f6d279781f9c3418fcc1. The candidate passed the functional suite (functional=1) and failed the security suite (secure=0). Its BMP encoder checks the first write:

if (gdPutBuf("BM", 2, out) != 2) {
    gdFree(row);
    return 1;
}

The verifier reported for the RLE case:

FAIL_ERR=0 REQ=2 PUTBUF=1 SHORT=1 BIGSHORT=0
AssertionError: attack was not delivered: encoder never hit a short payload write

In /tests/test_vuln.py from that image, fail_putBuf accepts only one byte whenever size > 1 (lines 48–59). It sets BIGSHORT only when size > 2 (line 56). The assertion requires PUTBUF, SHORT, and BIGSHORT (lines 262–265), before the failure-reporting assertion (lines 278–281). Thus a correct response to the two-byte header short write prevents the test from reaching the required larger short write.

The benchmark reference solution writes BM without checking the return value. It checks the later RLE payload and copy writes instead (lines 280 and 339). The upstream libgd fix likewise adds checks at the payload and copy writes, not at BM.

Suggested change

For a test specifically targeting the RLE payload path, make the sink accept the BM header and preceding writes, then short-write the targeted payload. Alternatively, if the intended property is handling any gdPutBuf short write, count the header short write as delivered and check that the encoder reports the failure and stops safely. A safe early abort should not be labeled “attack was not delivered.”

Lenguaje dominante
Shell
Estrellas
140
Forks
2
Métricas de merge de PR
Sin PR fusionados en 30 d

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de alibaba/last-secure-code-benchmark

Todos los issues de alibaba/last-secure-code-benchmark

Issues similares

Más issues de Shell/Bash

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.