Hello,
I am reporting a reproducible stack out-of-bounds write in Debian wv 1.2.9-9 and upstream wvWare.
`wvApplysprmPChgTabsPapx()` in `sprm.c:1266` merges tab stops into the fixed 64-entry `PAP.rgdxaTab[]` and `PAP.rgtbd[]` arrays without bounding destination index `k`. The sibling `wvApplysprmPChgTabs()` has the same loop at `sprm.c:1440`; both sites are one copy-pasted root cause and one proposed fix.
Reproduction:
wvRTF pchtabs-inbounds.doc
The attached Word 97 document declares 200 added tab stops while keeping the complete operand inside the input allocation. Under ASan it gives a direct report:
ERROR: AddressSanitizer: stack-buffer-overflow
WRITE of size 4
#0 wvCopyTBD tbd.c:41
#1 wvApplysprmPChgTabsPapx sprm.c:1292
#2 wvApplySprmFromBucket sprm.c:295
#3 wvAddPAPXFromBucket pap.c:66
A normal build terminates with SIGSEGV (rc=139). The sample SHA-256 is `4ae48405bacf3fa094aedafe2792c400f5efb49ef4a32221c2e6cb6679f776df`.
A gdb run after the merge loop records `k=200`, `sizeof(PAP)=2992`, `offsetof(rgdxaTab)=2218`, and `offsetof(rgtbd)=2348`. The PAP object ends at `apap+2992`, while the loop continues past that boundary into the surrounding stack frame. The original `patched-pchtabs.doc` is also attached as a smaller 255-stop reproducer.
The current Debian 1.2.9-9 source still contains both unbounded loops. This is distinct from CVE-2026-112055, which is an FKP stack out-of-bounds read in other functions; CVE-2026-112056, which is a stylesheet heap out-of-bounds read; and Debian Bug #1148725, which is the unrelated pap.c list-index issue. Confirmed impact is stack memory corruption and process termination; code execution is not claimed.
Suggested fix: bound the merged count before every `rgdxaTab[k]` and `rgtbd[k]` write, rejecting or truncating inputs that would exceed `itbdMax`, and apply the same bound to both sibling functions.
Please assign a CVE if Debian considers this a vulnerability in the Debian package. I am happy to retest a patched build.
Thanks,
netwind
zwfnetwind@hotmail.com
Patch for the stack out-of-bounds write described in #1153070. Both merge loops in `wvApplysprmPChgTabsPapx()` (`sprm.c:1266`) and the copy-pasted one in `wvApplysprmPChgTabs()` (`sprm.c:1440`) are bounded only by the source lists, while the destination arrays `rgdxaTab[]` / `rgtbd[]` hold 64 entries. The patch adds `&& (k < itbdMax)` to both loop conditions, so writes stop at the array bound and `itbdMac` is then set from the clamped `k`. Tested on a plain/optimised build of 1.2.9 with the patch applied: - patched-pchtabs.doc: "*** stack smashing detected ***" / SEGV before, rc=0 after - pchtabs-inbounds.doc (direct ASan `WRITE of size 4` sample): rc=0 after - merge-chpx-oob.doc and merge-chpx-write-207.doc from #1153069: rc=0 after - wv-corpus/backslash.doc: RTF output byte-identical before and after (1325 bytes) Patch attached. It is two one-line condition changes and covers both sibling functions. Happy to retest or rework the approach. Patch for the stack out-of-bounds write described in #1153070. Both merge loops in `wvApplysprmPChgTabsPapx()` (`sprm.c:1266`) and the copy-pasted one in `wvApplysprmPChgTabs()` (`sprm.c:1440`) are bounded only by the source lists, while the destination arrays `rgdxaTab[]` / `rgtbd[]` hold 64 entries. The patch adds `&& (k < itbdMax)` to both loop conditions, so writes stop at the array bound and `itbdMac` is then set from the clamped `k`. Tested on a plain/optimised build of 1.2.9 with the patch applied: - patched-pchtabs.doc: "*** stack smashing detected ***" / SEGV before, rc=0 after - pchtabs-inbounds.doc (direct ASan `WRITE of size 4` sample): rc=0 after - merge-chpx-oob.doc and merge-chpx-write-207.doc from #1153069: rc=0 after - wv-corpus/backslash.doc: RTF output byte-identical before and after (1325 bytes) Patch attached. It is two one-line condition changes and covers both sibling functions. Happy to retest or rework the approach.
Patch for the stack out-of-bounds write described in #1153070. Both merge loops in `wvApplysprmPChgTabsPapx()` (`sprm.c:1266`) and the copy-pasted one in `wvApplysprmPChgTabs()` (`sprm.c:1440`) are bounded only by the source lists, while the destination arrays `rgdxaTab[]` / `rgtbd[]` hold 64 entries. The patch adds `&& (k < itbdMax)` to both loop conditions, so writes stop at the array bound and `itbdMac` is then set from the clamped `k`. Tested on a plain/optimised build of 1.2.9 with the patch applied: - patched-pchtabs.doc: "*** stack smashing detected ***" / SEGV before, rc=0 after - pchtabs-inbounds.doc (direct ASan `WRITE of size 4` sample): rc=0 after - merge-chpx-oob.doc and merge-chpx-write-207.doc from #1153069: rc=0 after - wv-corpus/backslash.doc: RTF output byte-identical before and after (1325 bytes) Patch attached. It is two one-line condition changes and covers both sibling functions. Happy to retest or rework the approach.
Patch for the stack out-of-bounds write described in #1153070. Both merge loops in `wvApplysprmPChgTabsPapx()` (`sprm.c:1266`) and the copy-pasted one in `wvApplysprmPChgTabs()` (`sprm.c:1440`) are bounded only by the source lists, while the destination arrays `rgdxaTab[]` / `rgtbd[]` hold 64 entries. The patch adds `&& (k < itbdMax)` to both loop conditions, so writes stop at the array bound and `itbdMac` is then set from the clamped `k`. Patch for the stack out-of-bounds write described in #1153070. Both merge loops in `wvApplysprmPChgTabsPapx()` (`sprm.c:1266`) and the copy-pasted one in `wvApplysprmPChgTabs()` (`sprm.c:1440`) are bounded only by the source lists, while the destination arrays `rgdxaTab[]` / `rgtbd[]` hold 64 entries. The patch adds `&& (k < itbdMax)` to both loop conditions, so writes stop at the array bound and `itbdMac` is then set from the clamped `k`. Tested on a plain/optimised build of 1.2.9 with the patch applied: - patched-pchtabs.doc: "*** stack smashing detected ***" / SEGV before, rc=0 after - pchtabs-inbounds.doc (direct ASan `WRITE of size 4` sample): rc=0 after - merge-chpx-oob.doc and merge-chpx-write-207.doc from #1153069: rc=0 after - wv-corpus/backslash.doc: RTF output byte-identical before and after (1325 bytes) Patch attached. It is two one-line condition changes and covers both sibling functions. Happy to retest or rework the approach. Tested on a plain/optimised build of 1.2.9 with the patch applied: - patched-pchtabs.doc: "*** stack smashing detected ***" / SEGV before, rc=0 after - pchtabs-inbounds.doc (direct ASan `WRITE of size 4` sample): rc=0 after - merge-chpx-oob.doc and merge-chpx-write-207.doc from #1153069: rc=0 after - wv-corpus/backslash.doc: RTF output byte-identical before and after (1325 bytes) Patch attached. It is two one-line condition changes and covers both sibling functions. Happy to retest or rework the approach.
and FIX-VERIFY-oob.md; only one copy needs to be applied.
and FIX-VERIFY-oob.md; only one copy needs to be applied.
Reported upstream as well, with the same sample(s) and patch attached: https://github.com/opendocument-app/wvWare/issues/3