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

Fix unsafe extraction by using mkdir() instead of shell command #5

Merged
merged 1 commit into from
Sep 21, 2016

Conversation

tuomasjjrasanen
Copy link
Contributor

This commit fixes following vulnerabilities:

  • CVE-2016-1243: stack buffer overflow caused by blindly trusting on
    pathname lengths of archived files

    Stack allocated buffer sysbuf was filled with sprintf() without any
    bounds checking in extracTree() function.

  • CVE-2016-1244: execution of unsanitized input

    Shell command used for creating directory paths was constructed by
    concatenating names of archived files to the end of the command
    string.

So, if the user was tricked to extract a specially crafted .adf file,
the attacker was able to execute arbitrary code with privileges of the
user.

This commit fixes both issues by

  1. replacing mkdir shell commands with mkdir() function calls
  2. removing redundant sysbuf buffer

@@ -305,20 +309,20 @@ void processFile(struct Volume *vol, char* name, char* path, unsigned char *extb
}
else {
/* the all-in-one string : to call system(), to find the filename, the convert dir sep char ... */
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like the comment needs an update as well...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, thanks. I'll force-update the pull request to just update the comments. I'll remove that comment and modify the comment about portability at the top of the file.

p.s. extractTree() needs quite a bit cleaning/refactoring, but that needs to be done separately.

This commit fixes following vulnerabilities:

- CVE-2016-1243: stack buffer overflow caused by blindly trusting on
  pathname lengths of archived files

  Stack allocated buffer sysbuf was filled with sprintf() without any
  bounds checking in extracTree() function.

- CVE-2016-1244: execution of unsanitized input

  Shell command used for creating directory paths was constructed by
  concatenating names of archived files to the end of the command
  string.

So, if the user was tricked to extract a specially crafted .adf file,
the attacker was able to execute arbitrary code with privileges of the
user.

This commit fixes both issues by

 1) replacing mkdir shell commands with mkdir() function calls
 2) removing redundant sysbuf buffer
Copy link
Owner

@lclevy lclevy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correctly fixes CVE-2016-1243 and CVE-2016-1244, thank you Tuomas !

@lclevy lclevy merged commit 69af1e5 into lclevy:master Sep 21, 2016
t-w added a commit that referenced this pull request May 16, 2024
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

Successfully merging this pull request may close these issues.

3 participants