Closed C4rter closed 1 year ago
Hi @C4rter. Thank you for your report. To speed up processing of this issue, make sure that you provided the following information:
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:
@magento give me 2.4-develop instance
- upcoming 2.4.x release
For more details, review the Magento Contributor Assistant documentation.
Add a comment to assign the issue: @magento I am working on this
To learn more about issue processing workflow, refer to the Code Contributions.
Join Magento Community Engineering Slack and ask your questions in #github channel.
:warning: According to the Magento Contribution requirements, all issues must go through the Community Contributions Triage process. Community Contributions Triage is a public meeting.
:clock10: You can find the schedule on the Magento Community Calendar page.
:telephone_receiver: 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.
:pencil2: 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. In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:
[ ] 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).Details
If the issue has a valid description, the label Issue: Format is valid
will be added to the issue automatically. Please, edit issue description if needed, until label Issue: Format is valid
appears.
[ ] 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add Issue: Clear Description
label to the issue by yourself.
[ ] 3. Add Component: XXXXX
label(s) to the ticket, indicating the components it may be related to.
[ ] 4. Verify that the issue is reproducible on 2.4-develop
branchDetails
- 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.
@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 Admin access: https://bb644a2717558fc68d3647adf2faf0d4.instances.magento-community.engineering/admin_8dd6 Login: 50a1d619 Password: 6cba8bad502b
Hi @C4rter,
Thank you for reporting and collaboration. Verified the issue on Magento 2.4-develop instance and the issue is not reproducible.Kindly refer the screenshots.
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.
Hi @engcom-Bravo
thank you for testing. As I see from your screenshots you used the GraphQL endpoint. I mentioned that the hacker used the REST API endpoint and my "Steps to reproduce" also show the Rest API.
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: vendor/magento/module-quote-graph-ql/Model/Cart/CheckCartCheckoutAllowance.php
public function execute(Quote $quote): void
{
if (!$quote->getCustomerIsGuest()) {
return;
}
$isAllowedGuestCheckout = (bool)$this->checkoutHelper->isAllowedGuestCheckout($quote);
if (false === $isAllowedGuestCheckout) {
throw new GraphQlAuthorizationException(
__(
'Guest checkout is not allowed. ' .
'Register a customer account or login with existing one.'
)
);
}
}
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? Thanks
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 10% MALWARE m2_template_attack_payload_cc6e3
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 1.Make sure "Allow Guest Checkout" is set to "No" in Backend Config (Stores->Configuration->Sales->Checkout->Allow Guest Checkout) 2.Check if guest checkout is possible when going through the frontend (should not and is not possible) 3.Do a guest-checkout with the use of the Rest API.
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.
:white_check_mark: Jira issue https://jira.corp.adobe.com/browse/AC-7577 is successfully created for this GitHub issue.
:white_check_mark: Confirmed by @engcom-Bravo. Thank you for verifying the issue.
Issue Available: @engcom-Bravo, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.
Hi, we have seen this (at least partially automated, few pages were visited but there were 6 checkout attempts in 2 minutes) attack happening on an older installation of Magento as well, we were wondering if this was fixed in a newer version, but apparently it is not (yet). The attack was used in combination with a code injection attempt.
The access logs look very similar as in the original report.
Same here on 2.4.5-1 Guest Checkout disabled
BUT Also: WEB API - Allow Anonymus Guest Access: No
I do not know what the later means, but it looks like both checks failed!
Complete access.log that might helps to understand a bit more (going trough all the pages makes it not anonymous guest anymore?):
"GET / HTTP/1.1" 200 29438 "-"
"GET / HTTP/1.1" 200 29438 "-"
"POST /pr-cookie-consent/consent_guest/update/ HTTP/1.1" 302 31 "-"
"GET / HTTP/1.1" 200 29438 "-"
"GET /someproducturl.html HTTP/1.1" 200 20423 "-"
"POST /checkout/cart/add/uenc/aHR0cHM6Ly93d3cudHJhZGVzZXJ2aWNlLmh1L3R6NGstbXQ4L2ZwbTgwMy5odG1s/product/9108/ HTTP/1.1" 200 89 "-"
"GET /checkout HTTP/1.1" 302 31 "-"
"GET /checkout/cart/ HTTP/1.1" 200 64515 "-"
"POST /rest/default/V1/customers/isEmailAvailable HTTP/1.1" 200 35 "-"
"POST /rest/default/V1/guest-carts/SEJoFR1LPXT1VpcBXqP8q1suSllJMvoG/estimate-shipping-methods HTTP/1.1" 200 219 "-"
"POST /rest/default/V1/guest-carts/SEJoFR1LPXT1VpcBXqP8q1suSllJMvoG/shipping-information HTTP/1.1" 200 547 "-"
"POST /b2b.php HTTP/1.1" 404 368 "-"
BUT Also: WEB API - Allow Anonymus Guest Access: No I do not know what the later means, but it looks like both checks failed!
As it says in the backend right under the configuration, this has nothing to do with the checkout API, it only applies to CMS, Catalog and Store API: "This feature applies only to CMS, Catalog and Store APIs. Please consult your developers for details on potential security risks."
(going trough all the pages makes it not anonymous guest anymore?)
As far as I know the check if guest checkout is allowed is just missing entirely on the guest-checkout rest api.
:x: Cannot export the issue. This GitHub issue is already linked to Jira issue(s): https://jira.corp.adobe.com/browse/AC-7577
Same here on 2.4.5-1 Guest Checkout disabled
BUT Also: WEB API - Allow Anonymus Guest Access: No
I do not know what the later means, but it looks like both checks failed!
Complete access.log that might helps to understand a bit more (going trough all the pages makes it not anonymous guest anymore?):
"GET / HTTP/1.1" 200 29438 "-" "GET / HTTP/1.1" 200 29438 "-" "POST /pr-cookie-consent/consent_guest/update/ HTTP/1.1" 302 31 "-" "GET / HTTP/1.1" 200 29438 "-" "GET /someproducturl.html HTTP/1.1" 200 20423 "-" "POST /checkout/cart/add/uenc/aHR0cHM6Ly93d3cudHJhZGVzZXJ2aWNlLmh1L3R6NGstbXQ4L2ZwbTgwMy5odG1s/product/9108/ HTTP/1.1" 200 89 "-" "GET /checkout HTTP/1.1" 302 31 "-" "GET /checkout/cart/ HTTP/1.1" 200 64515 "-" "POST /rest/default/V1/customers/isEmailAvailable HTTP/1.1" 200 35 "-" "POST /rest/default/V1/guest-carts/SEJoFR1LPXT1VpcBXqP8q1suSllJMvoG/estimate-shipping-methods HTTP/1.1" 200 219 "-" "POST /rest/default/V1/guest-carts/SEJoFR1LPXT1VpcBXqP8q1suSllJMvoG/shipping-information HTTP/1.1" 200 547 "-" "POST /b2b.php HTTP/1.1" 404 368 "-"
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 /V1/guest-carts
)
@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
/V1/guest-carts
)
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: "The following APIs remain accessible to anonymous users" and then lists all guest-cart endpoints.
Only way would be to block them manually via a custom plugin.
@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
/V1/guest-carts
)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: "The following APIs remain accessible to anonymous users" and then lists all guest-cart endpoints.
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:
{ "cartItem": { "sku": "simple", "qty": 1 } }
{ "addressInformation": { "shipping_address": { "region": "New York", "region_id": 0, "region_code": "", "country_id": "DE", "street": [ "123 Oak Ave" ], "postcode": "10577", "city": "Purchase", "firstname": "Jane", "lastname": "Doe", "email": "jdoe@example.com", "telephone": "512-555-1111" }, "billing_address": { "region": "New York", "region_id": 0, "region_code": "", "country_id": "DE", "street": [ "123 Oak Ave" ], "postcode": "10577", "city": "Purchase", "firstname": "Jane", "lastname": "Doe", "email": "jdoe@example.com", "telephone": "512-555-1111" }, "shipping_carrier_code": "flatrate", "shipping_method_code": "flatrate" } }
{ "email": "jdoe@example.com", "paymentMethod": { "method": "checkmo" }, "billing_address": { "email": "jdoe@example.com", "region": "New York", "region_id": 0, "region_code": "", "country_id": "DE", "street": [ "123 Oak Ave" ], "postcode": "10577", "city": "Purchase", "telephone": "512-555-1111", "firstname": "Jane", "lastname": "Doe", "same_as_billing": 0 } }
Response:
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/ Here it is mentioned that:
we conclude it to be working as it is suppose to.
I thought the payment-information endpoint created the order, did you check that despite the shipping endpoint failing? (maybe there are some extra checks preventing the shipping flow from continuing, every store can be configured differently)
Not sure if I'm missing anything but not able to reproduce it
Steps I followed is like below,
- POST http://magento-github.local/rest/V1/guest-carts => GOT cart ID h8YLEHwbzZ9ewbXjhr29B6iBO2ksNs01
- GET http://magento-github.local/rest/V1/guest-carts/h8YLEHwbzZ9ewbXjhr29B6iBO2ksNs01 => Got quote ID
- POST http://magento-github.local/rest/default/V1/guest-carts/h8YLEHwbzZ9ewbXjhr29B6iBO2ksNs01/items
- POST http://magento-github.local/rest/default/V1/guest-carts/h8YLEHwbzZ9ewbXjhr29B6iBO2ksNs01/estimate-shipping-methods
- POST http://magento-github.local/rest/default/V1/guest-carts/h8YLEHwbzZ9ewbXjhr29B6iBO2ksNs01/shipping-information
- POST http://magento-github.local/rest/default/V1/guest-carts/2FHsrl9MF58IKc8AIxk70Psvl4EYyoLW/payment-information
It's stopping me at step 5 with proper message
I'm not able to reproduce it on 2.4-develop branch as it seems to be get fixed by this commit - https://github.com/magento/magento2/commit/47c388a093fd5621b19eb2089877db80254a937a
@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 Related commits: https://github.com/magento/magento2/search?q=ACP2E-1339&type=commits
Thanks
@yogesh-valiya @glo05363 @engcom-Bravo It isn't merged with 2.4.6-p3 right? What is the best way to merge this commit into own environment?
@yogesh-valiya @glo05363 @engcom-Bravo It isn't merged with 2.4.6-p3 right? What is the best way to merge this commit into own environment?
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
Please note that the issue is scheduled to be fixed in Adobe Commerce 2.4.6
There are some of the endpoints still used by magento even if you are only using the web UI. For example, rest/storecode/V1/guest-carts/quote-id/estimate-shipping-methods
which used in the /checkout/cart
page to retrieve the shipping charges. In case you completely blocked the guest APIs, this feature will not work.
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...
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 RewriteRule ^rest/V1/guest-carts - [F,NC,L] RewriteRule ^rest/default/V1/guest-carts - [F,NC,L]
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.
https://github.com/magento/magento2/issues/39002#issuecomment-2291143582
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