Fossil Forum
Post: Read from uninitialized stack variable seqno in page_xfer
The handler for
the clone card calls blob_is_int without checking the return value to
see whether the *pValue was actually written to. Sending a clone card
with a non-integer seqno token causes a read of uninitialized stack
memory.
int seqno, max;
/* ... */
blob_is_int(&xfer.aToken[2], &seqno);
if( seqno<=0 ){
Demonstration:
mkdir test
cd test
fossil new test.fossil
fossil open --force test.fossil
valgrind fossil server
curl --data-binary 'clone 3 X' -H 'Content-Type: application/x-fossil' http://127.0.0.1:8080/
The output of valgrind is:
==PID== Conditional jump or move depends on uninitialised value(s)
==PID== at 0x34848B: page_xfer (xfer.c:1643)
==PID== by 0x29BB95: process_one_web_page (main.c:2252)
==PID== by 0x29D9C3: cmd_webserver (main.c:3709)
==PID== by 0x29A825: fossil_main (main.c:1028)
==PID== by 0x138035: main (main.c:731)
==PID==
==PID== Conditional jump or move depends on uninitialised value(s)
==PID== at 0x3484D9: page_xfer (xfer.c:1649)
==PID== by 0x29BB95: process_one_web_page (main.c:2252)
==PID== by 0x29D9C3: cmd_webserver (main.c:3709)
==PID== by 0x29A825: fossil_main (main.c:1028)
==PID== by 0x138035: main (main.c:731)
The output of curl depends on whether the uninitialized integer seqno is positive.
You may get:
error invalid\sclone\ssequence\snumber
Or you may get something like:
clone_seqno 0
push db60098bda16cba7a95689f5896a4b9bf2e6d572 6478e785c77f015a56616aed90747a8f3a8de433
# timestamp 2026-11-25T19:43:34 errors 0
The bug could allow approximate remote reading
of the bytes that correspond to the seqno stack variable. If the
value is positive and less than the maximum rid, only rids up to that
value will be returned by the server.
There is another place in src/xfer.c where
blob_is_int is called and the return value is not checked,
in the clone_seqno handler in the client_sync function.
In that function, the cloneSeqno variable is initialized where it is declared,
so it may be a bug, but it's not a read from uninitialized memory.