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

Querying order by meta key with empty value returns an order. #4393

Closed
shendy-a8c opened this issue Jul 4, 2022 · 5 comments · Fixed by #8433
Closed

Querying order by meta key with empty value returns an order. #4393

shendy-a8c opened this issue Jul 4, 2022 · 5 comments · Fixed by #8433
Assignees
Labels
category: core WC Payments core related issues, where it’s obvious. focus: payments acceptance & processing good first issue The issue is a good candidate for the first community contribution/for a newcomer to the team. type: bug The issue is a confirmed bug.

Comments

@shendy-a8c
Copy link
Contributor

shendy-a8c commented Jul 4, 2022

Describe the bug

order_id_from_meta_key_value() when passed with empty value, will return some order id, which is unexpected and potentially expose a security problem.

To Reproduce

  1. Define a new route, `/disputes/something', at the end of WC_REST_Payments_Disputes_Controller:: register_routes().
  2. Defining it at the end like that is incorrect because the /disputes/{dispute_id} route will match first.
  3. An order will be returned along in the response, which is unexpected.

I actually bumped into this bug by accident when working on my PR and I'm not sure if this bug affects UX or exploitable because going to a dispute page with invalid id, eg /wp-admin/admin.php?page=wc-admin&path=%2Fpayments%2Fdisputes%2Fdetails&id=something, doesn't let me through.

Additional context

I found that WC_Payments_API_Client::get_dispute() calls add_order_info_to_object() with a null $charge_id which will eventually calls order_from_charge_id().

@shendy-a8c shendy-a8c added type: bug The issue is a confirmed bug. needs triage Manually put issue into triage process. labels Jul 4, 2022
@deepakpathania deepakpathania added category: core WC Payments core related issues, where it’s obvious. component: disputes Issues related to Disputes labels Jul 5, 2022
@jessy-p
Copy link
Contributor

jessy-p commented Sep 21, 2022

@shendy-a8c The code for order_id_from_meta_key_value has changed recently, could you check if this is still applicable?

@shendy-a8c
Copy link
Contributor Author

This issue is still valid.

I just tested by following these steps:

  1. Install WP-Console.
  2. Open the Console menu from the top bar of the admin page.
  3. Run this code
$client = WC_Payments::create_api_client();
$client->get_dispute('');
  1. Note that the $order_id returned in this line is a valid order id.

It should not be like that. $order_id should be empty / null.

@shendy-a8c
Copy link
Contributor Author

@jessy-p is this issue something @Automattic/gamma can / should do?

@shendy-a8c shendy-a8c removed their assignment Oct 31, 2023
@haszari
Copy link
Contributor

haszari commented Nov 21, 2023

Removing disputes label (so Helix can ignore when triaging our backlog). Based on the above, this is a specific code bug in data access code, not necessarily related to disputes.

@naman03malhotra can you add this Gamma's backlog? (maybe it's already there!)

@haszari haszari removed the component: disputes Issues related to Disputes label Nov 21, 2023
@htdat
Copy link
Member

htdat commented Nov 21, 2023

Thanks @haszari. I am going to move it to the proper Gamma queue for prioritiazation.

@htdat htdat added the good first issue The issue is a good candidate for the first community contribution/for a newcomer to the team. label Nov 23, 2023
@jessy-p jessy-p self-assigned this Dec 14, 2023
@zmaglica zmaglica removed the needs triage Manually put issue into triage process. label Jan 31, 2024
@haszari haszari added the focus: misc or unknown Issues that need to be added to a focus area (aka "needs focus"). label Mar 11, 2024
@vbelolapotkov vbelolapotkov added focus: payments acceptance & processing and removed focus: misc or unknown Issues that need to be added to a focus area (aka "needs focus"). labels Mar 13, 2024
@zmaglica zmaglica assigned zmaglica and unassigned jessy-p Mar 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category: core WC Payments core related issues, where it’s obvious. focus: payments acceptance & processing good first issue The issue is a good candidate for the first community contribution/for a newcomer to the team. type: bug The issue is a confirmed bug.
Projects
None yet
7 participants