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

reflected file download vulnerability #2029

Closed
splitbrain opened this issue Jun 27, 2017 · 22 comments
Closed

reflected file download vulnerability #2029

splitbrain opened this issue Jun 27, 2017 · 22 comments

Comments

@splitbrain
Copy link
Collaborator

originally reported in https://hackerone.com/reports/238316

Description

The call= parameter on https://www.dokuwiki.org/lib/exe/ajax.php does not properly encode user input, which leads to the reflected file download vulnerability.

Example: https://www.dokuwiki.org/lib/exe/ajax.php?call=%7c%7c%63%61%6c%63%7c%7c

The server responds with: AJAX call '||calc||' unknown!.

Impact

This can lead to arbitrary code execution on a victim's machine!

Reproduction on Windows!!

1.) Open Chrome Browser
2.) Visit redacted - contained a link with a download attribute
3.) Right click the Download link and click Save Link As and then save.
4.) installer.bat should then download, which contains the attacker's shellcode, downloaded from https://www.dokuwiki.org/lib/exe/ajax.php?call=%7c%7c%63%61%6c%63%7c%7c

If the user runs this batch file in Windows, it will open your calculator! This could lead to the entire compromise of the victim's computer.

Patch

I recommend URL encoding any characters in the server response (if the ajax call is not found) such as & and ; and |

References

@splitbrain
Copy link
Collaborator Author

The actual problem here is that the error message reflects the passed parameter uncleaned (because it is a text/plain response). This allows to inject arbitrary code in the response, eg. to create a valid batch file. A user may be tricked into downloading and executing the resulting code (assisted by the download html attribute) since it seems the code comes from a trustworthy server.

@splitbrain
Copy link
Collaborator Author

Correction: the response is of a text/html mime type and the error message is correctly escaped via htmlspecialchars. However the attack still works since it will keep bash control chars intact.

@michitux
Copy link
Collaborator

I would suggest to simply remove the call parameter from the output. If it is really useful for debugging (I doubt that), it could be printed when debugging is enabled.

@splitbrain
Copy link
Collaborator Author

fixed in 238b8e8

@lc
Copy link

lc commented Jun 29, 2017

Hey there, looks like it this patch doesn't actually fix this issue.

view-source:https://www.dokuwiki.org/lib/exe/ajax.php?call=%7c%7ccalc%7c%7c

You will see ||calc|| in the source which means it's still vulnerable!

An easy patch that I would recommend is to urlencode(); the output if the Ajax Call is unknown!

@lc
Copy link

lc commented Jun 29, 2017

Issue is here:

https://github.com/splitbrain/dokuwiki/blob/master/lib/exe/ajax.php

 29         print "AJAX call '".htmlspecialchars($call)."' unknown!\n";

htmlspecialchars doesn't do anything to | characters so I would recommend changing the code to

 29         print "AJAX call '".urlencode($call)."' unknown!\n";

easy fix :)

Thanks,
-Corben Douglas (@sxcurity)

@splitbrain
Copy link
Collaborator Author

the issue has been fixed but not rolled out to dokuwiki.org, yet.

@lc
Copy link

lc commented Jun 29, 2017

Oh yep you're right @splitbrain ! I checked a vulnerable version haha! Thanks.

@trichimtrich
Copy link

Is there any h1 private program for dokuwiki.
Can I join? @splitbrain

@splitbrain
Copy link
Collaborator Author

@trichimtrich I'm not sure what you mean, can you contact me at andi[at]splitbrain.org?

@lc
Copy link

lc commented Aug 29, 2017

He was asking if you had a program on https://hackerone.com. This was originally reported by me to a program running this wiki. @trichimtrich they do not have a program on there.

@trichimtrich
Copy link

I've got it. Thank you

@lc
Copy link

lc commented Aug 29, 2017

No problem.

@carnil
Copy link

carnil commented Feb 3, 2018

This issue was assigned CVE-2017-18123

@zcater
Copy link

zcater commented Feb 4, 2018

Is there a stable release planned that includes these fixes?

@Klap-in
Copy link
Collaborator

Klap-in commented Feb 4, 2018

For the coming release, there are still pending issues. Please see https://github.com/splitbrain/dokuwiki/issues?q=is%3Aopen+is%3Aissue+milestone%3A%22%F0%9F%90%B1+Greebo%22

There is no release date planned.

@takuy
Copy link
Contributor

takuy commented May 8, 2018

@splitbrain Has this been fixed with Greebo?

238b8e8

@phy25
Copy link
Collaborator

phy25 commented May 8, 2018

@takuy It should be fixed, because there are release_stable_2018-04-22 and release_stable_2018-04-22a tags on the GitHub commit you posted.

@takuy
Copy link
Contributor

takuy commented May 8, 2018

@phy25 I see. Thanks! Just saw this issue was still opened; there's a CVE still open for this, so wanted to make sure it was resolved or not.

@r0bag
Copy link

r0bag commented Jul 27, 2018

For me Greebo bahaved the same as the previous vulnerable version. Did anyone else test it?

@micgro42
Copy link
Collaborator

@r0bag Tested it. The reponse is cleaned. You can test it with the links in the original post above.

DokuWiki.org will respond to https://www.dokuwiki.org/lib/exe/ajax.php?call=%7c%7c%63%61%6c%63%7c%7c with the cleaned AJAX call 'calc' unknown! instead of the dangerous AJAX call '||calc||' unknown!`.

@lc
Copy link

lc commented Jul 30, 2018

Yep, I can confirm this is fixed.

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

No branches or pull requests