-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Description
Preconditions and environment
- Magento 2.4.4 and 2.4.5-p1
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
- Make sure "Allow Guest Checkout" is set to "No" in Backend Config (Stores->Configuration->Sales->Checkout->Allow Guest Checkout)
- Check if guest checkout is possible when going through the frontend (should not and is not possible)
- Do a guest-checkout with the use of the Rest API.
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:
{
"cartItem": {
"sku": "[SOME-EXISTING-SKU]",
"qty": 1
}
}
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.)
{
"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": "freeshipping",
"shipping_method_code": "freeshipping"
}
}
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)
{
"email": "jdoe@example.com",
"paymentMethod": {
"method": "banktransfer",
"extension_attributes": {"agreement_ids": ["1","2","5"]}
},
"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
}
}
- Guest Order will be placed.
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
- 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”.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status