Skip to content
Tcl Source Code History Of Ticket d59715d0cffb0b86
Login

History Of Ticket d59715d0cffb0b86

Artifacts Associated With Ticket d59715d0cffb0b86

  1. Ticket change [4e746a2f01] (rid 147004) by acpime on 2016-06-19 08:21:26:

    1. assignee initialized to: "nobody"
    2. closer initialized to: "nobody"
    3. cmimetype initialized to: "text/plain"
    4. comment initialized to:
      I discovered UAF in the Python tkinter module. 
      
      
      python bug:
      
      http://bugs.python.org/issue27254
      
      Asan report.
      =================================================================
      ==20559==ERROR: AddressSanitizer: heap-use-after-free on address 0x7fa46bec8810 at pc 0x4665ea bp 0x7ffd34fb4060 sp 0x7ffd34fb3820
      READ of size 1048575 at 0x7fa46bec8810 thread T0
      ==20559==WARNING: Trying to symbolize code, but external symbolizer is not initialized!
          #0 0x4665e9 (/home/eminus/Downloads/Python-2.7.11/python+0x4665e9)
          #1 0x7fa46f507e18 (/usr/lib/x86_64-linux-gnu/libtcl8.6.so+0x116e18)
          #2 0x7fa46f7eb44e (/usr/lib/x86_64-linux-gnu/libtk8.6.so+0x6244e)
          #3 0x7fa46fb1ae4c (/home/eminus/Downloads/Python-2.7.11/build/lib.linux-x86_64-2.7/_tkinter.so+0x19e4c)
          #4 0x7fa46fb0bfc5 (/home/eminus/Downloads/Python-2.7.11/build/lib.linux-x86_64-2.7/_tkinter.so+0xafc5)
          #5 0x5e1813 (/home/eminus/Downloads/Python-2.7.11/python+0x5e1813)
          #6 0x5d319c (/home/eminus/Downloads/Python-2.7.11/python+0x5d319c)
          #7 0x721353 (/home/eminus/Downloads/Python-2.7.11/python+0x721353)
          #8 0x4acb2a (/home/eminus/Downloads/Python-2.7.11/python+0x4acb2a)
          #9 0x4b6c62 (/home/eminus/Downloads/Python-2.7.11/python+0x4b6c62)
          #10 0x4acb2a (/home/eminus/Downloads/Python-2.7.11/python+0x4acb2a)
          #11 0x5f0823 (/home/eminus/Downloads/Python-2.7.11/python+0x5f0823)
          #12 0x4b0a08 (/home/eminus/Downloads/Python-2.7.11/python+0x4b0a08)
          #13 0x4acb2a (/home/eminus/Downloads/Python-2.7.11/python+0x4acb2a)
          #14 0x5e2d19 (/home/eminus/Downloads/Python-2.7.11/python+0x5e2d19)
          #15 0x5d319c (/home/eminus/Downloads/Python-2.7.11/python+0x5d319c)
          #16 0x5d2041 (/home/eminus/Downloads/Python-2.7.11/python+0x5d2041)
          #17 0x660980 (/home/eminus/Downloads/Python-2.7.11/python+0x660980)
          #18 0x65fc8a (/home/eminus/Downloads/Python-2.7.11/python+0x65fc8a)
          #19 0x48e46c (/home/eminus/Downloads/Python-2.7.11/python+0x48e46c)
          #20 0x7fa4727edec4 (/lib/x86_64-linux-gnu/libc.so.6+0x21ec4)
          #21 0x48c5bc (/home/eminus/Downloads/Python-2.7.11/python+0x48c5bc)
      
      0x7fa46bec8810 is located 16 bytes inside of 2097166-byte region [0x7fa46bec8800,0x7fa46c0c880e)
      freed by thread T0 here:
          #0 0x4766d3 (/home/eminus/Downloads/Python-2.7.11/python+0x4766d3)
          #1 0x7fa46f4ff52d (/usr/lib/x86_64-linux-gnu/libtcl8.6.so+0x10e52d)
      
      previously allocated by thread T0 here:
          #0 0x4764d9 (/home/eminus/Downloads/Python-2.7.11/python+0x4764d9)
          #1 0x7fa46f4ff0cc (/usr/lib/x86_64-linux-gnu/libtcl8.6.so+0x10e0cc)
      
      SUMMARY: AddressSanitizer: heap-use-after-free ??:0 ??
      Shadow bytes around the buggy address:
        0x0ff50d7d10b0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
        0x0ff50d7d10c0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
        0x0ff50d7d10d0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
        0x0ff50d7d10e0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
        0x0ff50d7d10f0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
      =>0x0ff50d7d1100: fd fd[fd]fd fd fd fd fd fd fd fd fd fd fd fd fd
        0x0ff50d7d1110: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
        0x0ff50d7d1120: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
        0x0ff50d7d1130: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
        0x0ff50d7d1140: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
        0x0ff50d7d1150: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
      Shadow byte legend (one shadow byte represents 8 application bytes):
        Addressable:           00
        Partially addressable: 01 02 03 04 05 06 07 
        Heap left redzone:     fa
        Heap right redzone:    fb
        Freed heap region:     fd
        Stack left redzone:    f1
        Stack mid redzone:     f2
        Stack right redzone:   f3
        Stack partial redzone: f4
        Stack after return:    f5
        Stack use after scope: f8
        Global redzone:        f9
        Global init order:     f6
        Poisoned by user:      f7
        ASan internal:         fe
      ==20559==ABORTING
      
    5. foundin initialized to: "8.6"
    6. is_private initialized to: "0"
    7. login: "acpime"
    8. priority initialized to: "5 Medium"
    9. private_contact initialized to: "a7f20d7eb12903ef82a40e2c72b12e66a013c422"
    10. resolution initialized to: "None"
    11. severity initialized to: "Critical"
    12. status initialized to: "Open"
    13. submitter initialized to: "acpime"
    14. subsystem initialized to: "41. Memory Allocation"
    15. title initialized to: "Use-after-free in Tcl_DStringAppend"
    16. type initialized to: "Bug"
  2. Ticket change [4b5497e36f] (rid 147006) by dgp on 2016-06-20 18:36:48:

    1. assignee changed to: "dgp"
    2. icomment:
      
      This ticketing system is for Tcl.
      
      'tkinter' is not part of Tcl; it is part of Python.
      
      If an error in Tcl is being exposed here, please
      include a clear demonstration of the problem
      in either Tcl or C code.
      
      If tkinter is simply failing to Tcl_DStringInit()
      where it needs to, that should be reported
      to the tkinter maintainers, not here.
      
      Good luck.
      
    3. login: "dgp"
    4. mimetype: "text/plain"
    5. resolution changed to: "Invalid"
    6. status changed to: "Pending"
  3. Ticket change [ad38752eb8] (rid 147019) by dah on 2016-06-21 00:53:43:

    1. icomment:
      Danger, Will Robinson
      There's some wicked action going on in Tk.
      In generic/tkwindow.c in function Initialize approx line 3193
      We hit this code path:
      
          /*
           * Figure out the application's name and class.
           */
      
          Tcl_DStringInit(&class);
          if (name == NULL) {
              int offset;
              TkpGetAppName(interp, &class);
              offset = Tcl_DStringLength(&class)+1;
              Tcl_DStringSetLength(&class, offset);
              Tcl_DStringAppend(&class, Tcl_DStringValue(&class), offset-1);
              name = Tcl_DStringValue(&class) + offset;
          }
      
      What's the problem here?
      If we're working with a string longer than will fit in DString's static storage then DStringAppend can ckrealloc here, but we're passing a pointer to the very memory we're reallocating! 
      
      This code doesn't make sense to me either, why is it taking a name 'foo' and appending it onto itself?
      
      I think it can be reduced to simply this:
      if (name == NULL) {
          TkpGetAppName(interp, &class);
          name = Tcl_DStringValue(&class);
      }
      
      I can provide a demo if necessary but I believe this evil line:
      Tcl_DStringAppend(&class, Tcl_DStringValue(&class), offset-1);
      speaks for itself and indeed is the culprit here.
      
      Finally and a bit unrelated, there are limits to Window class names, On Microsoft Windows the max is 256 (OS limitation). So if you get crazy with long names, Tk will silently not display any window.
      
    2. login: "dah"
    3. mimetype: "text/plain"
    4. username: "dah"
  4. Ticket change [846baa1246] (rid 147047) by dgp on 2016-06-21 11:39:12:

    1. closedate changed to: "2457560.98556225"
    2. closer changed to: "dgp"
    3. icomment:
      
      Holy Moly!
      
      Thanks for digging that out. Yuck!
      
      Opened in the Tk Tracker here:
      
      http://core.tcl.tk/tk/tktview/787adc5ed7
      
    4. login: "dgp"
    5. mimetype: "text/plain"
    6. status changed to: "Closed"
  5. Ticket change [ad78a7ac84] (rid 147060) by dgp on 2016-06-22 15:49:00:

    1. closedate changed to: "2457562.15903043"
    2. icomment:
      
      See also
      
      http://core.tcl.tk/tcl/tktview/16896d49fd
      
    3. login: "dgp"
    4. mimetype: "text/plain"
  6. Ticket change [c5109fa203] (rid 147417) by acpime on 2016-07-02 16:51:07:

    1. closedate changed to: "2457572.20217508"
    2. closer changed to: "acpime"
    3. comment changed to:
      I get the following report when running the script (which are generally used third party TCL library) on python with ASAN enabled.
      
      python bug:
      
      http://bugs.python.org/issue27254
      
      Asan report.
      =================================================================
      ==20559==ERROR: AddressSanitizer: heap-use-after-free on address 0x7fa46bec8810 at pc 0x4665ea bp 0x7ffd34fb4060 sp 0x7ffd34fb3820
      READ of size 1048575 at 0x7fa46bec8810 thread T0
      ==20559==WARNING: Trying to symbolize code, but external symbolizer is not initialized!
          #0 0x4665e9 (/home/eminus/Downloads/Python-2.7.11/python+0x4665e9)
          #1 0x7fa46f507e18 (/usr/lib/x86_64-linux-gnu/libtcl8.6.so+0x116e18)
          #2 0x7fa46f7eb44e (/usr/lib/x86_64-linux-gnu/libtk8.6.so+0x6244e)
          #3 0x7fa46fb1ae4c (/home/eminus/Downloads/Python-2.7.11/build/lib.linux-x86_64-2.7/_tkinter.so+0x19e4c)
          #4 0x7fa46fb0bfc5 (/home/eminus/Downloads/Python-2.7.11/build/lib.linux-x86_64-2.7/_tkinter.so+0xafc5)
          #5 0x5e1813 (/home/eminus/Downloads/Python-2.7.11/python+0x5e1813)
          #6 0x5d319c (/home/eminus/Downloads/Python-2.7.11/python+0x5d319c)
          #7 0x721353 (/home/eminus/Downloads/Python-2.7.11/python+0x721353)
          #8 0x4acb2a (/home/eminus/Downloads/Python-2.7.11/python+0x4acb2a)
          #9 0x4b6c62 (/home/eminus/Downloads/Python-2.7.11/python+0x4b6c62)
          #10 0x4acb2a (/home/eminus/Downloads/Python-2.7.11/python+0x4acb2a)
          #11 0x5f0823 (/home/eminus/Downloads/Python-2.7.11/python+0x5f0823)
          #12 0x4b0a08 (/home/eminus/Downloads/Python-2.7.11/python+0x4b0a08)
          #13 0x4acb2a (/home/eminus/Downloads/Python-2.7.11/python+0x4acb2a)
          #14 0x5e2d19 (/home/eminus/Downloads/Python-2.7.11/python+0x5e2d19)
          #15 0x5d319c (/home/eminus/Downloads/Python-2.7.11/python+0x5d319c)
          #16 0x5d2041 (/home/eminus/Downloads/Python-2.7.11/python+0x5d2041)
          #17 0x660980 (/home/eminus/Downloads/Python-2.7.11/python+0x660980)
          #18 0x65fc8a (/home/eminus/Downloads/Python-2.7.11/python+0x65fc8a)
          #19 0x48e46c (/home/eminus/Downloads/Python-2.7.11/python+0x48e46c)
          #20 0x7fa4727edec4 (/lib/x86_64-linux-gnu/libc.so.6+0x21ec4)
          #21 0x48c5bc (/home/eminus/Downloads/Python-2.7.11/python+0x48c5bc)
      
      0x7fa46bec8810 is located 16 bytes inside of 2097166-byte region [0x7fa46bec8800,0x7fa46c0c880e)
      freed by thread T0 here:
          #0 0x4766d3 (/home/eminus/Downloads/Python-2.7.11/python+0x4766d3)
          #1 0x7fa46f4ff52d (/usr/lib/x86_64-linux-gnu/libtcl8.6.so+0x10e52d)
      
      previously allocated by thread T0 here:
          #0 0x4764d9 (/home/eminus/Downloads/Python-2.7.11/python+0x4764d9)
          #1 0x7fa46f4ff0cc (/usr/lib/x86_64-linux-gnu/libtcl8.6.so+0x10e0cc)
      
      SUMMARY: AddressSanitizer: heap-use-after-free ??:0 ??
      Shadow bytes around the buggy address:
        0x0ff50d7d10b0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
        0x0ff50d7d10c0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
        0x0ff50d7d10d0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
        0x0ff50d7d10e0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
        0x0ff50d7d10f0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
      =>0x0ff50d7d1100: fd fd[fd]fd fd fd fd fd fd fd fd fd fd fd fd fd
        0x0ff50d7d1110: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
        0x0ff50d7d1120: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
        0x0ff50d7d1130: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
        0x0ff50d7d1140: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
        0x0ff50d7d1150: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
      Shadow byte legend (one shadow byte represents 8 application bytes):
        Addressable:           00
        Partially addressable: 01 02 03 04 05 06 07 
        Heap left redzone:     fa
        Heap right redzone:    fb
        Freed heap region:     fd
        Stack left redzone:    f1
        Stack mid redzone:     f2
        Stack right redzone:   f3
        Stack partial redzone: f4
        Stack after return:    f5
        Stack use after scope: f8
        Global redzone:        f9
        Global init order:     f6
        Poisoned by user:      f7
        ASan internal:         fe
      ==20559==ABORTING
      
    4. login: "acpime"
    5. mimetype: "text/plain"