This issue expands on the issue at http://drupal.org/node/881752 with a focus on whether an "empty cart" confirmation is necessary in ALL use cases. To summarize the issue, the security concern with the original cart links empty cart function is that rogue sites can empty the user cart on your site, when the user browses their site, by posting your Cart Links on their site (even with a sneaky technique like
.
I'm interested in feedback surrounding whether a security compromise could be reached on this issue between the concern about rogue sites and the use cases where the rogue sites, in the opinion of the site owner, are not as problematic as the decreased usability of the "empty cart" confirmation. Site owners who are not concerned can obviously pick up the old Cart Links code from 6.x.2.3, but I for one would like to remain in the fold of the ever watchful security team coders for whom I'm extremely grateful.
My use case is: I sell only an annual subscription, or a monthly subscription, and I have discounted versions of each, for a total of four products. A user will only ever want one. If a user's cart gets emptied, it's not a problem at all (not even a little bit), since I don't use the cart. The only way to get to the checkout screen is by clicking on the cart link, and since every product is mutually exclusive this cart link also emptys the cart. For sites where every product is mutually exclusive, the balance on this issue falls decidedly on the side of allowing Cart Links to empty the cart without a confirmation screen.
On issues like this where a large number of site owners disagree with the decision of the security team, site owners are compelled to use old, unsupported code to get the functionality that is appropriate for their particular use case. Compelling people to use unsupported code (which I don't, by the way, but it's sure tempting...) is an additional concern the security team need to consider.
I suggest that the empty cart confirmation page be made optional via a checkbox at /admin/store/settings/cart_links. It should default to "on", with big red letters advising site owners not to disable it. Which I would, since that's what works for my site.
Comments
Comment #1
shaundychkoAhhh, should have hit preview... the "sneaky technique", which looks especially sneaky in the post above since it's invisible should read <img src="http://www.example.com/e-ihahaha" />
Comment #2
shaundychkoComment #3
longwaveAny further changes to this will need input from the security team.
Adding a checkbox in the settings page may be viable, or perhaps we could add a variable that has no corresponding UI, so you could set something like $conf['uc_cart_links_skip_confirm'] = TRUE in settings.php as the only way to enable this "feature".
Comment #4
RKopacz commentedHi, slightly off subject, but I am new to Ubercart and would like to know how you can set up products in a cart to make them mutually exclusive. Does anyone have a link to documentation or a tutorial? Much thanks.
Comment #5
shaundychko@RKopacz, the only way I'm aware of doing this is via Cart Links. You can empty the cart and add a product to it using a single URL. Enable Cart Links from your modules page and visit /admin/store/help/cart_links on your own site for instructions on creating these links. Note that currently you'll need the Cart Links module from 6.x-2.x-dev in order for the empty cart function to work. ("empty cart" doesn't work with 6.x-2.4 even though documentation suggests it will).
Comment #6
RKopacz commentedHey, thanks very much for the quick response. I will try out your suggestion, let you know what I come up with.
r
Comment #7
jrowny commentedI can create a patch to add a setting for enabling/disabling the confirmation screen. If there's adequate warning and the warning is turned ON by default, I don't see why the security team wouldn't approve it.
Comment #8
shaundychkoHey, you should check out http://drupal.org/node/881752 before spending too much time on that.
Comment #9
jrowny commentedThe result of that thread still has a "confirmation" page. My patch would be to make the confirmation page an option set in store configutation->cart links.
The patch wouldn't be very long... there's a single line of code which checks for "e" and returns the confirm form. I'd simply add to that the check for the setting.
Comment #10
longwaveBefore embarking on this, I suggest you contact security@drupal.org, or perhaps webchick or greggles directly as they were the ones involved in the previous issue - no further patches will be accepted for this without their blessing.
Comment #11
jrowny commentedtalked to Webchick in IRC and I agreed with her that my use case of cart links is probably an abuse of cart links and I should probably just write a hook to handle my product correctly.
Comment #12
tr commentedNew features should go into 7.x-3.x first at this point.
Comment #13
thehideki commentedMoved here from : http://drupal.org/node/1091122
I needed this also, decided on forking the cart_links module to use a hash created from the user & product data, and a check that the hash matches. If the hash value matches, the confirmation is skipped.
Maybe some kind of optional hash parameter could be added to the url check on 7.x? It could be done using an admin settings field with token support. Then one could create a link (with views or your preferred method), and the cart_links function could check the parameter, and bypass the validation if it matches.
Here's what i did to create this functionality on the D6 version. Currently works only on one product per link.
D6 version
--
FILE: uc_cart_links_pages:
rewrote the first function, and added another below it:
FILE: uc_carts_links.admin.inc
Added these to the settings form
Comment #14
tr commentedPlease make a patch and post it here as a file attachment.
Comment #15
thehideki commentedPatch as requested. (this patch is for 6.x-2.x, as i have not used 7.x yet)
Comment #16
tr commentedComment #18
longwaveComment #19
tr commented#15: ubercart-cart_links_hash_check-1091166-13.patch queued for re-testing.
Comment #21
tr commentedThe Cart Links module has very good test coverage right now. I don't think new features should go in unless we have new tests to accompany them. So I think this patch should include new test cases to verify this new feature is working and to ensure it stays working.
Also, the patch needs to be fixed to conform with Drupal coding standards. See http://drupal.org/coding-standards. You can use the Coder module to help you review your code. Coder catches a lot, but not everything, so it's worthwhile to become familiar with the standards.
Comment #22
tr commentedCrosspost - patch failed testing, should still be needs work.
Comment #23
mrfelton commentedNeeded a quick fix, no time to debug the patch in #15 which causes fatal errors. So here is a oneliner that at least allows us to move forward for now.
Comment #24
jimurl commentedI needed the ability for an administrator to override the 'Do you really want to empty your cart? 'confirmation page. The patch in #15 introduces the hash to deal with this, but isn't compliant. The patch submitted by Mr. Felton removes the confirmation page altogether-which, it sounds, won't fly with the security team. Until the hashing system for cart links can be completed, this patch gives the site administrator the ability to disable this 'empty cart verify' feature via a checkbox on the cart links settings page, admin/store/settings/cart_links .
Comment #25
tr commentedYou have to set the issue status to "needs review" to get the testbot to try out the patch.
Comment #27
jimurl commentedI notice now there are also some truncated lines, trying again.
Comment #28
longwaveFixing issue title
Comment #29
polmaresma commented#27 worked for me.
Thank's!
Comment #30
tr commentedThe patches in #23, #24, and #27 can't be put into Ubercart because they circumvent the confirmation that is required by the Drupal security team. They also don't address the specific topic of this issue.
The patch in #15 has potential to solve this issue, but the points I raised in #21 haven't been addressed and no one has tested it.
Moving back to "needs work" for these reasons. Also moving to 7.x-3.x because that is where new features should be implemented first.
Comment #31
julian.montagna commentedHi,
I've solved this in two simple steps:
1) Editing a custom module adding a new entry in hook_menu like:
2) Copy and modify uc_cart_links_form code from uc_cart_links.pages.inc like:
I really don't know if this is the best approach but since is a very particular business need, this way you can get what you need without modifying the module, the core or even better without disturbing security@drupal.org guys. :P
Hope this helps somebody.
Cheers,
Comment #32
oliverpolden commentedDon't do this, it is a hack which you shouldn't do because it will get wiped out if you upgrade the module but if you want the quickest way round this then in uc_cart_links.pages.inc find line 34:
Insert a new line after
$items = uc_cart_get_contents();On the new line insert
$items = array();You could also just edit the first line or comment it out but this way you can revert easily.
Comment #33
haysuess commentedJust throwing my (and all my clients) opinion(s) into the mix. This is something I have to patch with EVERY single site I developer, and it got old 10 sites ago.
Nobody I've developed for cares if another site can create cart links that can potentially empty a cart on their site. The extra warning step is alarming to buyers and kills business that people are trying to build themselves, directly on their OWN site.
Comment #34
petarb commentedI echo haysuess's comments.
This is the key takeout:
However, thanks to oliverpolden's suggested hack, everyone's happy with the outcome, it works perfectly. I think the maintainers of the module (who do a fantastic job by the way) should consider the ability for the admins to turn off this business-killing 'feature' on a per-site basis.
Comment #35
jimurl commentedThat is what patch #27 does.
Comment #36
tr commentedLet me reiterate what was said in #3 and #10 and #30; if you want to be able to turn off the Cart Links confirmation, then you will have to contact the security team and work with THEM to get approval of your proposed change. No patch for this issue will be committed without approval of the security team.
In fact, I'm going to just go ahead and close this issue as it is getting nowhere and hasn't produced a viable patch. Feel free to reopen (or better yet start a new thread) IF you have a patch and have discussed your approach with the security team AND they approve of the proposed solution.