Bug 761 - sudo caused symbol lookup error with noexec when wordexp is called
sudo caused symbol lookup error with noexec when wordexp is called
Status: RESOLVED FIXED
Product: Sudo
Classification: Unclassified
Component: Sudo
1.8.18
PC Linux
: low normal
Assigned To: Todd C. Miller
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2016-11-13 10:15 MST by Balint Reczey
Modified: 2016-12-20 06:15 MST (History)
0 users

See Also:


Attachments
patch (1.09 KB, patch)
2016-11-13 10:15 MST, Balint Reczey
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Balint Reczey 2016-11-13 10:15:20 MST
Created attachment 485 [details]
patch

The fix for CVE-2016-7076 made sudo_noexec.so call dlsym() without linking with libdl causing the symbol lookup error:

$ cat sudo-poc.c
#include <stdlib.h>
#include <stdio.h>
#include <wordexp.h>

int main () {
  wordexp_t p;
  printf("sudo CVE-2016-7032 & CVE-2016-7076 tests\n");
  printf("Set the noexec default setting in the sudoers file then run this binary with sudo.\n\n");
  if (-1 != system("ls /")) {
    printf("\nSystem's system() call is not protected, sudo is vulnerable to CVE-2016-7032\n");
  } else {
    printf("System's system() call is protected (CVE-2016-7032)\n");
  }
  if (NULL != popen("ls /", "r")) {
    printf("\nSystem's popen() call is not protected, sudo is vulnerable to CVE-2016-7032\n");
  } else {
    printf("System's popen() call is protected (CVE-2016-7032)\n");
  }
  if (WRDE_CMDSUB != wordexp("$(echo e)", &p, 0)) {
    printf("\nSystem's wordexp() call is not protected, sudo is vulnerable to CVE-2016-7076\n");
  } else {
    printf("System's wordexp() call is protected (CVE-2016-7076)\n");
  }

$ cc sudo-poc.c
$ sudo ./a.out
./a.out: symbol lookup error: /usr/lib/sudo/sudo_noexec.so: undefined symbol: dlsym

The attached patch fixed the issue for me.
Comment 1 Todd C. Miller 2016-11-13 16:02:47 MST
Thanks for the patch, I've committed it.
https://www.sudo.ws/repos/sudo/rev/120a317ce25b
Comment 2 Todd C. Miller 2016-12-20 06:15:05 MST
Fixed in sudo 1.8.19