-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
[3+] com_joomlaupdate allows upload of any filetype #29763
Comments
How far shall the validation go? Shall it just check for the extension, e.g. ".zip"? I ask because one could be so funny and rename the PNG file or whatever he or she tries to upload to a ZIP file, i.e. with chagning the extension. |
This comment was marked as abuse.
This comment was marked as abuse.
And I have an answer (42) and have forgotten the problem for which it was ;-) |
this should be reported to @joomla/security |
This comment was marked as abuse.
This comment was marked as abuse.
I agree with @PhilETaylor that I can hardly see an attack vector here, however, some proper error handling (at least validating the file type) makes sense to provide better feedback for users. |
@SniperSister What do you mean with file type? The file name extension? You know it’s not the same. I think we only can check for the extension. |
Does the extensions installer have the same problem? I can’t check that now because I’m on the road. Maybe someone else can do that faster? |
File type detection should NEVER rely on the given file name. You always analyze the file data. |
Right ... and I found out meanwhile that it can be done. If someone wants to work on it, let us know here so we are not working in parallel. I'n not sure if I can do something, but if so, then not before weekend. |
@mbabker I assume you mean with "analyze the file data" a MIME type check with functions like "mime_content_type" or "finfo_open" and "finfo_file", is that right? And do you really think it is necessary for the issue here? As far as I understand it, it is not a security issue here because it needs a super admin anyway to be logged in to backend. I understand it more as a check being needed to prevent uploading of an accidently selected wrong file. @PhilETaylor Is my understanding right that it's not a security but an UX issue? @SniperSister @zero-24 What's your opinion? Does it need the mime type check, too, or is a check of the file name before the upload in JS sufficient? I'd implement the check at least in J4 in the same way as I did for the maximum upload size with PR #27570 , i.e. as soon as the user selects a wrong file, a warning box is shown, and when he or she tries to upload it anyway, an alert is shown, and upload is rejected. |
I personally (not speaking in any official name of Production, maintainers or JSST) would implement an mine type check given that IIRC only zip files can be used anyway at this place. What we might have to check is whether there can be issues with mine type detection on different hosting configurations. |
Your personal opinion is welcome.
In the MediaHelper we use for things which are not pictures either "mime_content_type" or "finfo_open" and "finfo_file", depending on what's available, and we check it in this order. "mime_content_type" should be available at PHP version >= 4.3, including 7.x, and doesn't require an extra module, while the "finfo_..." functions are available at PHP versions >= 5.3, including 7.x, and they require PECL fileinfo. The "mime_content_type" is not marked as deprecated in PHP docs, but I did read something somwehere that this might be soon the case. So I am almost but not 100% sure it should work everywhere. But if it fails due to missing functions, and we decide to refuse the upload in that case, then it would block people behind firewalls who can't use the Live Update from updating forever. |
Sure just wanted to make this clear as at some places my opinions has been interpreted as opinion of any of my positions or teams that i'm involved in ;-)
That is exactly the case i mean. In some setups you might also have the issue that the mine type is not correctly interpreted. So we might add a switch to disable the mime type checking? As this is about com_joomlaupdate i would suggest to backport that to 3.10 too. |
You mean a configuration switch in com_joomlaupdate's options? Or maybe we should just silently skip the test if none of the functions is available?
The issue is even for 3.9. Should it be solved there, too, or only in 3.10 and 4? |
Hmm again my personal opinion when nothing is there we should issue an error and stop uploading. Yes a switch to turn it off in com_joomlaupdate. We might do a similiar thing in com_installer. As for com_joomlaupdate please fork the method in the com_joomlaupdate model so we do not depend on that method to be there on the systems where we send a updated com_joomlaupdate. In the installer we can use the media helper.
Up to @HLeithner to decide on. When it is implemented in 4 I'm happy to merge it into 3.10 for sure. |
@zero-24 I don't get it what you mean with fork, and which method. And the installer, would that be for extensions then? Or shall I put all that studff into the installer, and com_joomlaupdate shall use the installer functions? I'm available on Glip, too, so you can explain me there in detail in German. |
@HLeithner Shall I fix this issue here in staging? And shall I backport the change from #27570 , too (which would make sense because both touch the same code)? And if both, shall I do it in 1 or in 2 separate PRs? 2 separate would theoretically be better because later merge up into J4, but practically the JS has changes so much between 3 and 4 that it would be better not to merge it up but solve this issue here with 2 separate PRs in staging and J4 and later solve the merge conflicts. @wilsonge What would you prefer? In J3 the JS is hard-coded in the PH file "default_upload.php", in J4 it's a separate JS source, so there is no simple upmerge for that. |
@richard67 to make it pulled proof (because is a critical part of the cms) I would use the same function used by the update it self to uncompress the ZIP file to validate if it's a zip file. (and if we only support zip files). Every mime checker (or better guesser) could stop users from upgrading without a good reason. And in my opinion I would only check the .zip extension because there is no security risk only a ux problem. |
@HLeithner Am confused now. Shall I make it bullet proof, or shall I do the check of the file name extension only? |
bullet proof as in "it should never fail because the detection is wrong" |
Am still confused. Shall I do a mime type check or shall I not do it? |
Am working one one or several fixes, stay tuned. It may take a bit time due to private stuff keeping me a bit busy. |
File upload validation should be done right regardless of whether you’re supporting public uploads or the upload can only be done by a super user. Which means using dedicated filesystem functions (like those you listed) to handle validation. Any form of “does this uploaded file have X extension” check is unreliable and a borderline joke, file names and extensions are very easily changed and this is a very common exploit pattern used for attempting to upload not allowed content. I have cleaned JPG and PNG files off of servers way too often whose file contents were PHP scripts, with proper upload validation those files would have never made it to the upload destination; this is just one example of why filename validation is to me even worse than no validation at all. |
@mbabker Thanks for pointing me to the right direction with my other PRs. I've closed them and will make new ones. |
@mbabker For the client side (adding attribute "accept" to the input element), see PR #29877 : Was this what you had in mind, leaving the user the freedom to disable the filter on particular browser and upload another kind of file anyway? Or did you have in mind to keep the additional check in JS and the messages from my other, meanwhile closed PR, and just make that check use the "accept" attribute of the input element instead of another hard-coded regex? For the server side (MIME type check): Could you check if PR |
So what is the status here?
So I did what I can to solve this issue. @PhilETaylor If you think that PR #29877 is sufficient to solve this issue here, please close it, otherwise leave it open. In the latter case your opinion on how it should be solved would be welcome. |
This comment was marked as abuse.
This comment was marked as abuse.
There is a cross project initiative looking at signed packages |
This comment was marked as abuse.
This comment was marked as abuse.
Anyone with access to com_joomlaupdate is an SU anyway right?
When you check back this is intentional and will be changed in 4.x to an error.
https://theupdateframework.io/ - Done (we dont even try to reinvent the crypto here)
Well I can say it is working out good so far with the Drupal and TYPO3 people we work with on that topic. |
https://github.com/joomla/joomla-cms/tree/staging/libraries/vendor/typo3/phar-stream-wrapper Jup it is a small one but that is used in Drupal, TYPO3 and IIRC WP too :) |
This comment was marked as abuse.
This comment was marked as abuse.
No as mention above I would have added it only Harald did not want it to be shipped with 3.9
Right that is the thing we are working on :D it is not ready yet. As mention in the last JSST reports when you follow them.
Yes. IIRC @alikon was about to check that and do a PR.
You closed that issue here. ;) |
Do we discuess now how many people attend an optional meeting or do we talk about on the subject of this PR?
|
This comment was marked as abuse.
This comment was marked as abuse.
What are you talking about? There is no So can we please go back on topic? Feel free to reach out to me by Glip or Mail when you have any questions on JSST topics or meeting reports. So we can keep that issue here on topic. |
This comment was marked as abuse.
This comment was marked as abuse.
just to be clear #19792 have been followed by a POC #20073 closed by me cause of lack of interest sorry if i'm talking from the past ie 2018 iirc for the https://github.com//issues/29695 it is in my to do list..... just for history the original pr's that introduced the hash check .... which were originally developed as a GSOC project of too much year's ago.... they were submitted with error if hash check fail.... someone decided to have a more soft approach |
Well the process is that we update the team and the community with the reports published internaly and than as public reports. That meeting would allow than questions or discussiones when required. Some of that is also handled via the Glip chat and GH issues etc.
Yes as the only official meeting voting we had where the vote on the TL. As mention in that exact meeting report.
You are the native person in here so I will let the definition on you but this is what it is intended. An open meeting where we can meet and optionaly discuss stuff. But again can we please stay on topic of this issue here? |
PR for joomla#29765 ### Steps to reproduce the issue Joomla 4 System -> Joomla (Update box) Choose any file (joomla#29763 bug allows any file) Click upload and install ### Expected result Password hide/reveal icon is clickable like all other password boxes in Joomla 4
* [4.0] joomla update show password PR for #29765 ### Steps to reproduce the issue Joomla 4 System -> Joomla (Update box) Choose any file (#29763 bug allows any file) Click upload and install ### Expected result Password hide/reveal icon is clickable like all other password boxes in Joomla 4 * icon width
This comment was marked as abuse.
This comment was marked as abuse.
* [4.0] joomla update show password PR for joomla#29765 ### Steps to reproduce the issue Joomla 4 System -> Joomla (Update box) Choose any file (joomla#29763 bug allows any file) Click upload and install ### Expected result Password hide/reveal icon is clickable like all other password boxes in Joomla 4 * icon width
Steps to reproduce the issue
In Joomla 3+ go to com_joomlaupdate ->Upload & Update tab
Select a PNG file, or XML file or any-other-file-type
Expected result
Validation error - its not a zip file.
Actual result
The file is uploaded to the
tmp path
, renamed and prefixed with'ju
The file extension and mime type is not validated first.
Then you get a login screen.
Additional comments
Tested Joomla 3.9.19 and Joomla 4 beta 1
Cant think of anyway to exploit this so posting publicly.
The text was updated successfully, but these errors were encountered: