2

I realized that it is possible to register customers through API without authentication.

https://devdocs.magento.com/guides/v2.2/rest/anonymous-api-security.html

Just make a POST call to https://example.com/rest/V1/customers with JSON content:

{
    "customer":{
        "email": "[email protected]",
        "firstname": "Customer Name",
        "lastname": "Customer Lastname"
    },
    "password": "UserPassword"
}

What would happen if an attacker exploited this possibility to "dirty" my customer database?

How can we protect?

Thanks

1 Answer 1

3

I solved editing /vendor/magento/module-customer/etc/webapi.xml

<route url="/V1/customers" method="POST">
    <service class="Magento\Customer\Api\AccountManagementInterface" method="createAccount"/>
    <resources>
        <!-- resource ref="anonymous"/ -->
        <resource ref="self"/>
    </resources>
</route>

I changed ref="anonymous" to ref="self".

Now isn't accessible without authentication.

1
  • How can I use admin authentication token requried for my custom API. @Francesco Mineo Commented Aug 30, 2022 at 11:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.