magento / magento2

Prior to making any Submission(s), you must sign an Adobe Contributor License Agreement, available here at: https://opensource.adobe.com/cla.html. All Submissions you make to Adobe Inc. and its affiliates, assigns and subsidiaries (collectively “Adobe”) are subject to the terms of the Adobe Contributor License Agreement.
http://www.magento.com
Open Software License 3.0
11.57k stars 9.32k forks source link

[Address Book Bug] Template filter `\Magento\Framework\Filter\Template` cannot deal with improper input #39353

Open wubinworks opened 1 week ago

wubinworks commented 1 week ago

Preconditions and environment

User input value such as {{var firstname}} is parsed in Address Book.

Steps to reproduce

01 \ Magento 2.4.7 + use the system default HTML Address Template Company: {{if city}}{{var city}}, {{/if}} Street Address(street1): {{var firstname}}{{var lastname}}{{var country}} \ \ 02 \ \ 03 \ \ 04

Expected result

The displayed address should be what the customer input. {{something}} should not be parsed.

Actual result

Customer input got parsed.

Additional information

The cause is this line Template.php#L317. str_replace is dangerous when you don't know what will be replaced, how many times the original string will be modified. The best way is to sanitize the user input. The "deferred directives" may not be reliable because you still cannot control the user input value.

Release note

No response

Triage and priority

m2-assistant[bot] commented 1 week ago

Hi @wubinworks. 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.

m2-assistant[bot] commented 1 week ago

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:

engcom-Bravo commented 1 week ago

Hi @wubinworks,

Thanks for your reporting and collaboration.

We have verified the issue in Latest 2.4-develop instance and the issue is reproducible.Kindly refer the screenshots.

Screenshot 2024-11-12 at 10 28 02 Screenshot 2024-11-12 at 10 28 12

Customer input got parsed in Address Book and also in Customer view in admin.

But it is working fine in Admin side addresses

Screenshot 2024-11-12 at 10 27 54

Hence Confirming the issue.

Thanks.

github-jira-sync-bot commented 1 week ago

:white_check_mark: Jira issue https://jira.corp.adobe.com/browse/AC-13341 is successfully created for this GitHub issue.

m2-assistant[bot] commented 1 week ago

: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.