Skip to content

Update js.phtml DOM text reinterpreted as HTML #38804

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

Open
wants to merge 7 commits into
base: 2.4-develop
Choose a base branch
from

Conversation

Shivam7-1
Copy link
Contributor

@Shivam7-1 Shivam7-1 commented Jun 5, 2024

Description (*)

By using innerText, it will avoid the risk of HTML injection, as these properties automatically escape any HTML special characters in the provided text. This helps prevent cross-site scripting (XSS) vulnerabilities by treating the input as plain text rather than interpreted HTML.

Contribution checklist (*)

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • README.md files for modified modules are updated and included in the pull request if any README.md predefined sections require an update
  • All automated tests passed successfully (all builds are green)

Resolved issues:

  1. resolves [Issue] Update js.phtml DOM text reinterpreted as HTML #38821: Update js.phtml DOM text reinterpreted as HTML

Copy link

m2-assistant bot commented Jun 5, 2024

Hi @Shivam7-1. Thank you for your contribution!
Here are some useful tips on how you can test your changes using Magento test environment.

Add the comment under your pull request to deploy test or vanilla Magento instance:
  • @magento give me test instance - deploy test instance based on PR changes
  • @magento give me 2.4-develop instance - deploy vanilla Magento instance

❗ Automated tests can be triggered manually with an appropriate comment:

  • @magento run all tests - run or re-run all required tests against the PR changes
  • @magento run <test-build(s)> - run or re-run specific test build(s)
    For example: @magento run Unit Tests

<test-build(s)> is a comma-separated list of build names.

Allowed build names are:
  1. Database Compare
  2. Functional Tests CE
  3. Functional Tests EE
  4. Functional Tests B2B
  5. Integration Tests
  6. Magento Health Index
  7. Sample Data Tests CE
  8. Sample Data Tests EE
  9. Sample Data Tests B2B
  10. Static Tests
  11. Unit Tests
  12. WebAPI Tests
  13. Semantic Version Checker

You can find more information about the builds here
ℹ️ Run only required test builds during development. Run all test builds before sending your pull request for review.


For more details, review the Code Contributions documentation.
Join Magento Community Engineering Slack and ask your questions in #github channel.

@Shivam7-1 Shivam7-1 changed the title Update js.phtml Update js.phtml DOM text reinterpreted as HTML Jun 5, 2024
@Shivam7-1
Copy link
Contributor Author

@magento run all tests

@engcom-Charlie
Copy link
Contributor

@magento create issue

@engcom-Charlie engcom-Charlie added the Priority: P2 A defect with this priority could have functionality issues which are not to expectations. label Jun 11, 2024
@Shivam7-1 Shivam7-1 closed this Jul 22, 2024
@Shivam7-1 Shivam7-1 reopened this Nov 11, 2024
Copy link

m2-assistant bot commented Nov 11, 2024

Hi @Shivam7-1. Thank you for your contribution!
Here are some useful tips on how you can test your changes using Magento test environment.
❗ Automated tests can be triggered manually with an appropriate comment:

  • @magento run all tests - run or re-run all required tests against the PR changes
  • @magento run <test-build(s)> - run or re-run specific test build(s)
    For example: @magento run Unit Tests

<test-build(s)> is a comma-separated list of build names.

Allowed build names are:
  1. Database Compare
  2. Functional Tests CE
  3. Functional Tests EE
  4. Functional Tests B2B
  5. Integration Tests
  6. Magento Health Index
  7. Sample Data Tests CE
  8. Sample Data Tests EE
  9. Sample Data Tests B2B
  10. Static Tests
  11. Unit Tests
  12. WebAPI Tests
  13. Semantic Version Checker

You can find more information about the builds here
ℹ️ Run only required test builds during development. Run all test builds before sending your pull request for review.


For more details, review the Code Contributions documentation.
Join Magento Community Engineering Slack and ask your questions in #github channel.

@Shivam7-1
Copy link
Contributor Author

Hii @engcom-Charlie it's not yet Merged
If possible Could Team Reviews this As Soon As possible

Thanks

@Shivam7-1
Copy link
Contributor Author

Shivam7-1 commented Dec 3, 2024

Hii @engcom-Charlie , @engcom-Dash @engcom-Bravo and @engcom-Hotel Could You Please Review This PR
As Soon As Possible Because its pending for Review since many months

Thanks & Regards

@Shivam7-1
Copy link
Contributor Author

Hii @engcom-Hotel Could You Please Review This PR
As Soon As Possible Because its pending for Review since many months

Thanks & Regards

@engcom-Hotel
Copy link
Contributor

@magento run all tests

@engcom-Hotel engcom-Hotel self-requested a review March 4, 2025 14:52
@github-project-automation github-project-automation bot moved this to Pending Review in Pull Requests Dashboard Mar 4, 2025
@engcom-Hotel engcom-Hotel moved this from Pending Review to Review in Progress in Pull Requests Dashboard Mar 4, 2025
@engcom-Hotel engcom-Hotel moved this from Review in Progress to Changes Requested in Pull Requests Dashboard Mar 4, 2025
@engcom-Hotel engcom-Hotel moved this from Changes Requested to Ready for Testing in Pull Requests Dashboard Mar 4, 2025
@engcom-Bravo engcom-Bravo added the Triage: Dev.Experience Issue related to Developer Experience and needs help with Triage to Confirm or Reject it label Mar 6, 2025
@Shivam7-1
Copy link
Contributor Author

Hii @engcom-Hotel any update on this PR ?
Regards

@engcom-Dash engcom-Dash self-assigned this Apr 7, 2025
@engcom-Dash
Copy link
Contributor

@magento run all tests

@engcom-Dash
Copy link
Contributor

@magento run all tests

@engcom-Dash engcom-Dash moved this from Ready for Testing to Testing in Progress in Pull Requests Dashboard Apr 7, 2025
@engcom-Dash
Copy link
Contributor

Hi @Shivam7-1

Thanks for your PR. I have tested the changes using custom script and everything seems to be working fine from that angle.

Custom Script:
Screenshot 2025-04-08 at 12 45 19 PM

However, I am just curious to identify the exact area in the Magento admin where this code would have a direct impact. Could you please share some manual testing scenarios or specific place in the admin where this can be verified? That would really help ensure thorough testing.

Also, the static tests are failing because ot the PR changes. Let me know if you are working on them. If not, Can I take care of the static failures?

Appreciate you help!

@Shivam7-1
Copy link
Contributor Author

Hii @engcom-Dash

Thank you for testing the changes and for your valuable feedback!

Regarding your question about the Magento admin, the change I made to innerText instead of innerHTML primarily impacts areas where dynamic content is injected into the DOM, such as in product descriptions, CMS pages, or any input that may render user-provided HTML. This will help prevent potential XSS vulnerabilities by treating the content as plain text. You can verify the change by testing these areas—specifically by submitting content with HTML special characters in places like product descriptions or custom CMS pages.

If you prefer to take care of the static failures, please feel free to do

Thanks

@Shivam7-1
Copy link
Contributor Author

Hii @engcom-Dash any update on this PR?
Is it ready to merge ?

@engcom-Dash
Copy link
Contributor

Hii @engcom-Dash

Thank you for testing the changes and for your valuable feedback!

Regarding your question about the Magento admin, the change I made to innerText instead of innerHTML primarily impacts areas where dynamic content is injected into the DOM, such as in product descriptions, CMS pages, or any input that may render user-provided HTML. This will help prevent potential XSS vulnerabilities by treating the content as plain text. You can verify the change by testing these areas—specifically by submitting content with HTML special characters in places like product descriptions or custom CMS pages.

If you prefer to take care of the static failures, please feel free to do

Thanks

Hello @Shivam7-1,

Thank you for your reply!

I have tested the changes by adding the content with HTML special character, script in the product description and CMS Pages. Even after injecting a script with XSS vulnerabilities on product description or CMS page the script still renders instead of being treated as plain text. In case of HTML tag there is no visible difference on 2.4-develop & PR branch.

It looks like the PR file changes doesn't have any visible effect on the product description or CMS page. Just to make sure I am validating the relevant functionality could you please share the exact manual test scenarios/steps and where this file is getting executed?

Please find below screenshot with or without PR changes for product description:
On develop Branch: 2.4-develop

Screenshot 2025-04-14 at 7 28 00 PM

On PR Branch: patch-3

Screenshot 2025-04-14 at 7 09 04 PM

Thank You

@Shivam7-1
Copy link
Contributor Author

Hii @engcom-Dash I saw the feedback about no visible change. Just to clarify — the change from innerHTML to innerText is intentional for XSS prevention. we should keep such security updates even if they don’t result in visible UI changes
Thanks

@engcom-Dash
Copy link
Contributor

@magento run all tests

@engcom-Dash
Copy link
Contributor

Hi @Shivam7-1,

Thanks for the clarification! I understand that the change from innerHTML to innerText is intentional for XSS prevention. We actually tried addressing that via a custom script as well.

I am just curious to know where exactly this file is getting rendered in the admin as it would help us better assess the impact of the change in various scenarios. Otherwise, applying this change alone might not have any practical effect.

Appreciate your efforts on improving security!

I have fixed the static test failures and since the functional test is failing moving this PR to Extended Testing.

Thanks!

@engcom-Dash engcom-Dash moved this from Testing in Progress to Extended Testing (optional) in Pull Requests Dashboard Apr 15, 2025
@Shivam7-1
Copy link
Contributor Author

Hii @engcom-Dash Thanks For Reviewing and Continous Support on this

@engcom-Dash
Copy link
Contributor

@magento run all tests

@engcom-Dash
Copy link
Contributor

@magento run Functional Tests B2B, Functional Tests EE, Functional Tests CE, Integration Tests

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Progress: extended testing Progress: ready for testing Triage: Dev.Experience Issue related to Developer Experience and needs help with Triage to Confirm or Reject it
Projects
Status: Extended Testing (optional)
Development

Successfully merging this pull request may close these issues.

[Issue] Update js.phtml DOM text reinterpreted as HTML
5 participants