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

Đang mở
#3 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
55/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
c, github, shell
Lĩnh vực
security, testing

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.”

Ngôn ngữ chính
Shell
Star
140
Fork
2
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của alibaba/last-secure-code-benchmark

Tất cả issue của alibaba/last-secure-code-benchmark

Issue tương tự

Thêm issue về Shell/Bash

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.