Here's the original report:
This module has XSS/DOS/CSRF vulnerabilities. The issues were found during an audit in 7.x-2.2+29-dev, but appear to be present in 7.x-2.2 as well.
crop/ajax/%/% stores crop coordinates from $_POST without token verification. This enables updating crop coordinates via a CSRF attack against users with the permission 'epsacrop create crops' or 'epsacrop edit all crops'.
CSRF POSTs to crop/ajax/put/[fid], with [fid] a valid file id and the payload in $_POST['coord'] will store the payload as crop parameters for the specified fid.
$_POST['coord'] can be an array of coordinates, but also a string.
This leads to two additional vulnerabilities:
- DOS: There are no bounds checks on the provided coordinates. Given a sufficiently large target canvas, generating the crop will use a large amount of memory.
- XSS: The stored value of $_POST['coord'], when a string, is shown unescaped on the page crop/dialog/all/all/all/[fid], where [fid] is the valid file id from the earlier example url.
Note; users with the permission 'epsacrop create crops' or 'epsacrop edit all crops' can also exploit these vulnerabilities without having to resort to CSRF.
Proposed solution:
- epsacrop_ajax() needs to verify a token that is sent along with the request.
- epsacrop_dialog() needs to check_plain data before inserting it into the textarea.
- Bounds checking needs to be implemented either before attempting a crop or when saving/submitting coordinates.
| Comment | File | Size | Author |
|---|---|---|---|
| #30 | 2710653-xss_csrf_dos-30.patch | 6.26 KB | alexfarr |
| #29 | 2710653-xss_csrf_dos-29.patch | 5.16 KB | wolffereast |
| #26 | 2710653-xss_csrf_dos-26.patch | 4.76 KB | bart vanhoutte |
| #3 | 2710653-xss_csrf_dos-3.patch | 3.27 KB | bart vanhoutte |
| #2 | 0001-Patch-security.patch | 3.15 KB | yvmarques |
Comments
Comment #2
yvmarques commentedHello,
Some part of the security issue has been fixed already with the attached patch, if somebody wants to finish he can start with it.
-- Yvan
Comment #3
bart vanhoutte commentedAdded check_plain to encode special characters, should fix XSS.
Comment #4
bart vanhoutte commentedShould/Can we treat the DOS/coordinate bounds issue as a separate issue and get this reviewed and committed? The bounds problem will be mitigated by the fact that the users needs permissions to edit the coordinates. This way we already have a fix out for the XSS/CSRF vulnerabilities.
Comment #5
alexfarr commentedHere is a patch for the coordinates DOS issue. It checks the coordinates were not set larger than the current images dimensions before saving.
Comment #6
alexfarr commentedApologies wrong patch uploaded here is the working version....
Comment #7
cbDoes not meet standards, can we move the comment into the function doc?
That looks better! :)
Comment #8
cb@Bart that patch looks good.
We can apply both patches and then create a mumma patch with both issues fixed.
Comment #9
cb@alexfarr can you remove #5?
Comment #10
alexfarr commentedUpdating patch for coordinates, fixes issue with comment and failure of exact coordinate test.
Comment #11
cbLooks the goods! Well done!
Comment #12
drupalgideonI'm happy to test this as soon as a single patch is created as I've got two production sites currently using this that I have had to disable this module on. I've also got another site that is due for launch in the next two weeks using this where I can easily apply any patches.
I was in the process of switching over to Manual Crop but would rather carry on using this module!
Thanks for all the speedy work so far everyone.
Comment #13
bart vanhoutte commentedAll patches merged.
Comment #14
drupalgideonI got an error trying to apply which highlighted a spelling error
Should be "reaches" .
I will try to apply using patch command.
Comment #15
bart vanhoutte commentedFixed the spelling error.
Comment #16
bart vanhoutte commentedHidden 2710653-xss_csrf_dos-12.patch.
Comment #17
jelle_sFixed comments (punctuation & should not be longer than 80 chars).
Comment #18
jelle_sMy editor was a bit too aggressive there...
Comment #19
Yaron Tal commentedCan the access checks not be moved to the access callbacks?
Besides that everything looks good, path applies, module keeps working and I was unable to reproduce the XSS or CSRF, did not test the DOS yet.
Comment #20
cinnamon commentedLast year we used this patch to solve this issue, perhaps it can still be of any use
Comment #21
wolffereast commentedI'm having an issue in _epsacrop_save_coords, the $file object doesnt have the height and width. Am I missing something?
Comment #22
bart vanhoutte commentedMoved token validation for the AJAX callback in an access callback as per #19. Patch uses #18 as basis.
Comment #23
jelle_s@wolfereast: Try this one (based on #22).
Comment #24
yvmarques commentedI think $token should be removed if you moved it to access callback ?
Comment #25
wolffereast commentedBeat me to the punch @Jelle_s, image_get_info works like a charm. The attached patch is based on the opatch in 22. It adds image_get_info and checks all the field coords instead of just the first.
Comment #26
bart vanhoutte commented#24 is right, removed $token in the page callback. Patch based #23.
Comment #27
wolffereast commentedUpdated 26 to test all coordinates passed, not just the first.
Comment #28
alexfarr commented@wollereast That patch has an variable miss name error on lines 981 and 982 variable names need to be changed to $info from $file_info in No #27.
Comment #29
wolffereast commentedOops, thats what I get for merging too quickly. Updated variable names
Comment #30
alexfarr commentedHere is a patch which shifts the coordinate data from the current textarea in the dialog and into a urlencoded data- attribute of the wrapping div.
Comment #31
cb#30 applied cleanly for me.
Comment #32
jelle_sI think this patch is good to go, security-wise. From a UX point of view #2634692: Coords should only be saved when node gets saved would be a better solution. If coords only get saved on form submit, this problem goes away altogether, but I don't know how much of a rewrite that would be, and I think we should get a security release out ASAP.
Comment #33
googletorp commented+1 on this is ready (security wise), we can do a follow up and fix other issues with the module, but for now making a security release should be minimal solution
Comment #34
drupalgideonAgree with #32 but having tested patch #30 last night it does look good from a security point of view. I hope someone from security team can review this quickly!
Well done all.
Comment #35
jimmynash commentedI can't vouch for the security aspect of it, but the patch in #30 applied for me and I'm not seeing any issues with the use of the cropping interface or the resulting images after it was applied.
Thanks to all for the work!
Comment #36
cb@yvmarques, do we need to contact security team and ask them to review this?
I'm wondering if it should be left as 'to review' so security team will see it?
Comment #37
cbI've emailed Heine to get feedback on how we get this reviewed.
Comment #38
yvmarques commentedHello,
I notified the security team on the first place time where we had this discussion.
-- Yvan
Comment #39
MattHalo commented+1 for the patch working.
Comment #40
laborouge commented+1 this patch working.
Comment #41
jphelan commentedDoes anyone know if this effects the 6.x version as well?
Comment #42
cbHi @jphelan, no this was for 7.x only.
Comment #43
vadim.hirbu commented+1 this patch working.
Comment #44
alexfarr commented@yvmarques any word from the security team on the progress of this patch?
Comment #45
yvmarques commented@jphelan Most likely the Drupal 6 version of the module is also affected by the security issue, unfortunately due to the fact that Drupal 6 isn't anymore supported, we will not fix the security on that version as well. An issue on d6lts has been open to see if any company wants to fix it. https://www.drupal.org/node/2710755
@alexfarr Not yet, updated the security issue to bring it up.
Comment #46
cbI emailed Heine on the 25th. No response.
Comment #47
cbSetting to Needs Review because it may be missed if it is RTBC.
Comment #48
lukusLooks like we need to follow the actions here: https://www.drupal.org/node/101497
Comment #49
cbI'm not sure how much of that has been done ...
Comment #50
cbI've just emailed the security team to arrange a review time.
Comment #51
dstolThanks everybody. The process for re-supporting an unsupported module can be found at https://www.drupal.org/node/251466.
@cbiggins Please create a new security issue by reporting an issue to the security team from the module's homepage and someone from the team will work with you to review and resolve the issue.
Thanks,
David Stoline on behalf of the Drupal Security team
Comment #52
cbThank you @dstol!
All other contributors in this issue, I'll create the security issue and work with the security team to get the module cleared with the patch that has been created by you guys.
I'll report updates here.
Comment #53
lukusHi all
Any update?
L
Comment #54
cbI can't talk with the security team about the issue because I don't have the permissions on the module.
I've asked Yvan for the access but he has stopped responding to me.
I'm going to try and contact the security team about this again to see if I can get anything moving.
I'll definitely update this issue with any progress.
Comment #55
seanbWould be very nice to see an update on this! Please let us know if we can do anything to help.
Comment #56
lukus@cbiggins I contacted Yvan who mentioned that he's given you permissions now.
Let me know if there's anything I can do to help. Would be great to get this module back on track.
Thanks for you help
Luke
Comment #57
cbThanks Luke, will update when I have anything.
Comment #58
cbGot an update - spoke to the security team member (mlhess) who is looking after the review (not the one who lodged the issue) and they are going to chat about giving me the user role I require to deal with them on the patch.
This is the big hurdle, if we can get over this then we'll be able to have more open communication with the security team on this issue and any others.
Comment #59
bart vanhoutte commentedAny news?
Comment #60
cbNot yet, still with security team.
Comment #61
gregglesFWIW, the security team worked on this issue in private for a good bit before abandoning the private process and pushing it to the public queue. So, yes, it's waiting on the security team at this point. It was the reverse for a while ;)
I've given this a cursory review and it seems like it's at least headed in the right direction.
I suggest adding some automated tests to confirm at least the CSRF code is working properly and perhaps the xss.
Comment #63
cbPatch #30 has been committed to 7.x-2.x.
Sorry @greggles, only just saw your reply.
Comment #64
cbWe've released 7.x-2.4 containing this patch.
mlhess is going to review it and if all is good will remove the security warning and restrictions.
FIngers crossed everybody, thanks to all of you.
Comment #65
cbThis is fixed guys. 2.4 is available now and security statement removed!
Thanks to all involved, well done!