Artifacts Associated With Ticket d051b77fc18d7340
Ticket change [5d11be0b90] (rid 164690) by jfe on 2018-07-25 13:25:55:
- assignee initialized to: "nobody"
- closer initialized to: "nobody"
- cmimetype initialized to: "text/plain"
- comment initialized to:
Hi, I am working on a project in which I use the afl fuzzer to find bugs in open-source software and I decided to fuzz tcl. In doing so, I discovered a segmentation fault in generic/tclStringObj.c, line 2405. Following is a detailed backtrace as supplied by the address sanitizer: ASAN:DEADLYSIGNAL ================================================================= ==65478==ERROR: AddressSanitizer: SEGV on unknown address 0x629000090000 (pc 0x7f3ee8d2b9dc bp 0x000000000d68 sp 0x7fffcfede090 T0) ==65478==The signal is caused by a WRITE memory access. #0 0x7f3ee8d2b9db in _IO_default_xsputn (/lib/x86_64-linux-gnu/libc.so.6+0x7b9db) #1 0x7f3ee8d1ee65 in _IO_padn (/lib/x86_64-linux-gnu/libc.so.6+0x6ee65) #2 0x7f3ee8d02cf7 (/lib/x86_64-linux-gnu/libc.so.6+0x52cf7) #3 0x7f3ee8cfe360 in vfprintf (/lib/x86_64-linux-gnu/libc.so.6+0x4e360) #4 0x7f3ee8d200d0 in _IO_vsprintf (/lib/x86_64-linux-gnu/libc.so.6+0x700d0) #5 0x7f3eea43ba28 in vsprintf (/usr/lib/x86_64-linux-gnu/libasan.so.4+0x9aa28) #6 0x7f3eea43be56 in sprintf (/usr/lib/x86_64-linux-gnu/libasan.so.4+0x9ae56) #7 0x7f3ee9f90b3b in Tcl_AppendFormatToObj /home/jfe/tcl/generic/tclStringObj.c:2405 #8 0x7f3ee9f97dc7 in Tcl_Format /home/jfe/tcl/generic/tclStringObj.c:2513 #9 0x7f3ee9bc62b8 in TclCompileFormatCmd /home/jfe/tcl/generic/tclCompCmds.c:3184 #10 0x7f3ee9dc16cd in TclAttemptCompileProc /home/jfe/tcl/generic/tclEnsemble.c:3256 #11 0x7f3ee9d62c85 in CompileCmdCompileProc /home/jfe/tcl/generic/tclCompile.c:1947 #12 0x7f3ee9d62c85 in CompileCommandTokens /home/jfe/tcl/generic/tclCompile.c:2062 #13 0x7f3ee9d62c85 in TclCompileScript /home/jfe/tcl/generic/tclCompile.c:2193 #14 0x7f3ee9d6404a in TclSetByteCodeFromAny /home/jfe/tcl/generic/tclCompile.c:800 #15 0x7f3ee9dd8ebe in TclCompileObj /home/jfe/tcl/generic/tclExecute.c:1689 #16 0x7f3ee9b28aab in TclNREvalObjEx /home/jfe/tcl/generic/tclBasic.c:5668 #17 0x7f3ee9b29340 in TclEvalObjEx /home/jfe/tcl/generic/tclBasic.c:5546 #18 0x7f3ee9e2bf3b in Tcl_RecordAndEvalObj /home/jfe/tcl/generic/tclHistory.c:182 #19 0x7f3ee9ee4b61 in Tcl_MainEx /home/jfe/tcl/generic/tclMain.c:537 #20 0x55db82b8fc62 in main /home/jfe/tcl/unix/tclAppInit.c:84 #21 0x7f3ee8cd1a86 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21a86) #22 0x55db82b8fc99 in _start (/home/jfe/tcl/unix/tclsh+0xc99) AddressSanitizer can not provide additional info. SUMMARY: AddressSanitizer: SEGV (/lib/x86_64-linux-gnu/libc.so.6+0x7b9db) in _IO_default_xsputn ==65478==ABORTING This bug can be reproduced by running: echo "format %6600000000g 0"|tclsh cheers, project-repo - foundin initialized to: "9.0a0 source distribution"
- is_private initialized to: "0"
- login: "jfe"
- priority initialized to: "5 Medium"
- private_contact initialized to: "3d546a40bbabbab36e7a717488c01c05ed9eb24a"
- resolution initialized to: "None"
- severity initialized to: "Minor"
- status initialized to: "Open"
- submitter initialized to: "jfe"
- subsystem initialized to: "47. Bytecode Compiler"
- title initialized to: "segmentation fault in tclStringObj.c, line 2405"
- type initialized to: "Bug"
Ticket change [dc2dc3a1c3] (rid 164691) by sebres on 2018-07-25 13:57:58:
- foundin changed to: "all"
- icomment:
Hmmm... seems to be *nix bug (or sprintf/stdlib) only, I can pretty good reproduce this there, trying since v.8.5. Not reproducible on windows, no matter which compiler (VC or gcc) and target (x86 or x64) selected. (Of course by x86 I tried shorter prefix). Although sprintf is known as vulnerable, we should try to find the way to fix it (meant to avoid segfault).
- login: "sebres"
- mimetype: "text/plain"
Ticket change [78d4f86974] (rid 164695) by aspect on 2018-07-26 15:24:04:
- icomment:
This crash can be stopped by changing tclStringObj.c at line 1870 (trunk): - if (width > limit) { + if (width > limit || width < 0) { but the underlying issue is earlier: int width; width = strtoul(..); looks like there are several signed int's that are assumed to not overflow, all should be examined. - login: "aspect"
- mimetype: "text/plain"
- icomment:
Ticket change [760654989f] (rid 164703) by sebres on 2018-07-26 16:01:48:
- closedate changed to: "2458326.16792247"
- closer changed to: "sebres"
- icomment:
fixed now within [16846911c7] for 8.5, can be simply merged into upper branches
- login: "sebres"
- mimetype: "text/plain"
- resolution changed to: "Fixed"
- status changed to: "Closed"
Ticket change [7b31d54f6a] (rid 164704) by sebres on 2018-07-26 16:03:13:
- closedate changed to: "2458326.16890897"
- login: "sebres"
- mimetype: "text/plain"
- subsystem changed to: "11. Conversions from String"
Ticket change [f53cf21cc2] (rid 164731) by dgp on 2018-07-27 15:31:03:
- closedate changed to: "2458327.14657304"
- closer changed to: "dgp"
- icomment:
There's plenty more mis-use of strtoul() lurking in the [format] implementation for an interested programmer to go in and correct. One example: % format {%4294967297$s} foo foo Possibly conversion to make use of TclParseNumber is a better idea. - login: "dgp"
- mimetype: "text/plain"
Ticket change [c898f735f1] (rid 164733) by sebres on 2018-07-27 17:29:27:
- closedate changed to: "2458327.22879435"
- closer changed to: "sebres"
- icomment:
On which version you have tested this, Don? and x64/x86? (I thing the $ was a typo, but) I get following: <code><pre> % format {%4294967297$s} foo "%n$" argument index out of range % format {%4294967297s} foo max size for a Tcl value exceeded </pre></code> Possibly the limit is large... - login: "sebres"
- mimetype: "text/plain"