-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
Despite "Allow Guest Checkout" set to "No" it's possible to place a guest order with the guest-carts REST API #36691
Comments
Hi @C4rter. Thank you for your report.
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:
For more details, review the Magento Contributor Assistant documentation. Add a comment to assign the issue: To learn more about issue processing workflow, refer to the Code Contributions.
🕙 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. ✏️ Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel |
Hi @engcom-Bravo. Thank you for working on this issue.
|
@magento give me 2.4-develop instance |
Hi @engcom-Bravo. Thank you for your request. I'm working on Magento instance for you. |
Hi @engcom-Bravo, here is your Magento Instance: https://bb644a2717558fc68d3647adf2faf0d4.instances.magento-community.engineering |
Hi @C4rter, Thank you for reporting and collaboration. Using frontend not able to place the order as a Guest. Using API not able to place the order as a Guest. Kindly let us know if we miss anything. Thanks. |
The same thing happened to us a few days ago on 2.4.5-p1. Guest checkout was set as NO. Pretty worrying. |
thank you for testing. As I see from your screenshots you used the GraphQL endpoint. It might be that it's not possible via the GraphQL endpoint but I'm sure it's possible via the Rest API. The error that's visible in your screenshot is a GQL specific error, thrown in a file only used when using the GQL API:
So it makes sense, that it's not possible when using GQL Api. But it's unfortunately possible when using REST API. Can you please verify it via the REST API endpoint? |
To confirm, we had Rest API guest order as well. Just finished the Sansec scan, and with M2.4.5-p1 only the order was placed. No other harm was detected. Sansec Scrutinize mode found it in the db:quote |
Hi @C4rter, Thanks for your update. @viktorlantos Thanks for your contribution & collaboration over here. Verified the issue on Magento 2.4-develop instance and the issue is reproducible.Kindly refer the screenshots. Steps to reproduce Using frontend we are not able to place the order as a guest. Using Rest Api we are able to place the order as a guest. Hence confirming this issue. Thanks. |
❌ Cannot export the issue. This GitHub issue is already linked to Jira issue(s): https://jira.corp.adobe.com/browse/AC-7577 |
We are facing everyday the same hack (same requests) on multiple magento2, does someone have a fix? |
@mabt If you don't have guest orders, you can block requests to the guest endpoints. See https://developer.adobe.com/commerce/webapi/rest/use-rest/anonymous-api-security/ (Search on |
If you mean the "Allow Anonymous Guest Access" config mentioned there, that does not block access to the guest-carts API. It says so on the page: Only way would be to block them manually via a custom plugin. |
The mostly easiest solution is to block on server level (nginx, apache, etc) |
Not sure if I'm missing anything but not able to reproduce it Steps I followed is like below,
It's stopping me at step 5 with proper message |
@C4rter thank you for addressing the issue: we have reproduced it with following steps: We have disabled guest-cart-checkout in admin which disables storefront access. API:
And we see that every guest-cart API is functioning . We have also disabled WEB API Anonymous guest access though it works only for CMS, Catalog and store APIs. To add to this please check https://developer.adobe.com/commerce/webapi/rest/use-rest/anonymous-api-security/ we conclude it to be working as it is suppose to. |
I'm not able to reproduce it on 2.4-develop branch as it seems to be get fixed by this commit - 47c388a |
@C4rter @yogesh-valiya Yes The issue is no longer there on 2.4-develop as the commit #47c388a |
Hello, As I can see this issue got fixed in the scope of the internal Jira ticket ACP2E-1339 by the internal team Thanks |
@yogesh-valiya @glo05363 @engcom-Bravo It isn't merged with 2.4.6-p3 right? |
There's aparently quality patch with the ID ACSD-47920 that you can manually apply (see KB article linked below). However, it's not marked as compatible with 2.4.6-p*, so not sure if that's actually working. But actually I think the better question would actually be, why is a security fix not merged in 2.4.6 including p6 even though it should be? In my opinion this isn't just a "quality" patch, this is a potential security issue, as any attacker can still send orders without authentication. Which might include payloads (like stated in the original post regarding APSB22-12). So next time a similar exploit is found it can be executed even though guest checkout is disabled already. The KB article even states that this should be fixed in 2.4.6: https://experienceleague.adobe.com/en/docs/commerce-knowledge-base/kb/support-tools/patches/v1-1-24/acsd-47920-guest-order-allow-guest-checkout-off
|
There are some of the endpoints still used by magento even if you are only using the web UI. For example, |
This is still an issue, I received a "guest" order just fine despite having guest checkout disabled. 2.4.6-p5 |
I received a hacker's guest order via API in my Magento shop yesterday. The shop was updated to 2.4.6-p6 two days ago... |
We are running the same version and received a couple of orders last week. However, we are not using the APIs at the moment, so went ahead in Cloudflare and blocked the guest checkout APIs. You can try executing the guest apis yourself in Postman or any other clients, and see it yourself(Quick endpoint ref to make quick guest order). |
We've blocked access to guest cart APIs as we don't use them by adding the following rules to .htaccess after RewriteEngine on. This results in a 404 (before Magento's htaccess converts 403s to 404s) RewriteCond %{REQUEST_METHOD} POST |
I managed to deal with this, creating a custom module and block order execution if firstname or lastname contain characters like "}","{", <.. etc. and log the attempt too. Added also validation of the shpping address, billing address, post code, city, order comments and disallow more than 30 characters in firstname and lastname. |
Preconditions and environment
We just had a hacker that tried to use the vulnerability "APSB22-12" to hack our store.
Thankfully we had the patches applied on 2.4.4 (and now upgraded to 2.4.5-p1) and he was not successful.
But he was able to try out the vulnerability by placing a guest order via the Rest API despite the guest-checkout being disabled in the backend.
Why is this still possible via API? It's a big risk because it allows unwanted guest orders being placed and in my case letting a hacker try out vulnerabilities.
How do I know that he did it via API?
There is no way to place a guest order via the frontend and you can see it in the access log how he did it:
"POST /checkout/cart/add/uenc/aHR0cHM6Ly93d3cucGxhdGV3cml0ZS5kZS9jdHAtZHJ1Y2twbGF0dGVuYmVsaWNodHVuZy9kcnVja3BsYXR0ZS0yNTB4MzcwLmh0bWw%2C/product/500/ HTTP/1.1" 200 1025 "-"
"GET /checkout HTTP/1.1" 302 1388 "-"
"GET /checkout/cart/ HTTP/1.1" 200 34064 "-"
"POST /rest/default/V1/customers/isEmailAvailable HTTP/1.1" 400 354 "-"
"POST /rest/italian/V1/customers/isEmailAvailable HTTP/1.1" 400 4619 "-"
"POST /rest/de/V1/customers/isEmailAvailable HTTP/1.1" 200 4840 "-"
"POST /rest/de/V1/guest-carts/Qgfa1jFEf8m430Vlo0xnFLz2uIyqAUPI/estimate-shipping-methods HTTP/1.1" 200 1021 "-"
"POST /rest/de/V1/guest-carts/Qgfa1jFEf8m430Vlo0xnFLz2uIyqAUPI/shipping-information HTTP/1.1" 200 3374 "-"
"POST /rest/de/V1/guest-carts/Qgfa1jFEf8m430Vlo0xnFLz2uIyqAUPI/payment-information HTTP/1.1" 200 4843 "-"
"POST /b2b.php HTTP/1.1" 302 5380 "-"
At the end he even tries to call the b2b.php file that he tried to create with his injection.
Steps to reproduce
Get a new Cart:
POST https://[YOUR-SHOP-URL]/rest/[YOUR-STORE-VIEW-CODE]/V1/guest-carts
You receive a basket ID here that you need in every step.
Add a product to the Cart:
POST https://[YOUR-SHOP-URL]/rest/[YOUR-STORE-VIEW-CODE]/V1/guest-carts/[YOUR-BASKET-ID]/items
Body:
Set shipping and billing address:
POST https://[YOUR-SHOP-URL]/rest/[YOUR-STORE-VIEW-CODE]/V1/guest-carts/[YOUR-BASKET-ID]/shipping-information
Body:
(Make sure you use a shipping method that exists. Maybe adjust the country to one that's allowed in your setup.)
Place Order:
POST https://[YOUR-SHOP-URL]/rest/[YOUR-STORE-VIEW-CODE]/V1/guest-carts/[YOUR-BASKET-ID]/payment-information
Body:
(You will have to adjust the agreement IDs or leave them out entirely and make sure you use a payment method that exists)
Expected result
Guest checkout should not be possible via the API when the guest checkout is disabled in the configuration.
Actual result
Guest checkout can be used and an order can be placed as a guest.
Additional information
Maybe somewhere in vendor/magento/module-checkout/Model/GuestPaymentInformationManagement.php in the savePaymentInformationAndPlaceOrder function there can be a condition, that checks if guest checkout is even allowed.
Release note
No response
Triage and priority
The text was updated successfully, but these errors were encountered: