Skip to content

fix(core): reject script element as a dynamic component host#68711

Closed
alan-agius4 wants to merge 1 commit into
angular:mainfrom
alan-agius4:script-host-element
Closed

fix(core): reject script element as a dynamic component host#68711
alan-agius4 wants to merge 1 commit into
angular:mainfrom
alan-agius4:script-host-element

Conversation

@alan-agius4
Copy link
Copy Markdown
Contributor

@alan-agius4 alan-agius4 commented May 13, 2026

To enhance application security and prevent accidental or malicious script execution, this change ensures that dynamically mounting a component via createComponent directly onto a <script> element throws a runtime error in development mode. SVG <script> elements are also rejected. The error message is designed to be fully tree-shakable under production builds where ngDevMode is disabled.

More context in: #68689 (comment)

@alan-agius4 alan-agius4 requested a review from AndrewKushnir May 13, 2026 09:50
@alan-agius4 alan-agius4 added action: review The PR is still awaiting reviews from at least one requested reviewer target: patch This PR is targeted for the next patch release labels May 13, 2026
@angular-robot angular-robot Bot added the area: core Issues related to the framework runtime label May 13, 2026
@ngbot ngbot Bot added this to the Backlog milestone May 13, 2026
@SkyZeroZx
Copy link
Copy Markdown
Contributor

So I think the solution to this other problem lies there? I think it's worth looking into.
https://issuetracker.google.com/u/1/issues/510537066

@alan-agius4
Copy link
Copy Markdown
Contributor Author

Yes, this change would also address what is mentioned in https://issuetracker.google.com/u/1/issues/510537066

@alan-agius4 alan-agius4 force-pushed the script-host-element branch from 1f24df7 to 6e865df Compare May 13, 2026 10:04
To enhance application security and prevent accidental or malicious script execution, this change ensures that dynamically mounting a component via createComponent directly onto a <script> element throws a runtime error in development mode. SVG <script> elements are also rejected. The error message is designed to be fully tree-shakable under production builds where ngDevMode is disabled.
@alan-agius4 alan-agius4 force-pushed the script-host-element branch from 6e865df to 3cd005e Compare May 13, 2026 10:12
@SkyZeroZx
Copy link
Copy Markdown
Contributor

Then the issue mentioned could be reclassified because, as I understand it, this can be a common pattern in applications

@alan-agius4 alan-agius4 reopened this May 13, 2026
@alan-agius4 alan-agius4 requested review from AndrewKushnir and removed request for AndrewKushnir May 13, 2026 12:05
@alan-agius4
Copy link
Copy Markdown
Contributor Author

alan-agius4 commented May 13, 2026

Closing the PR as I am unable to update review requests will open a new one.

#68713

@alan-agius4 alan-agius4 deleted the script-host-element branch May 13, 2026 12:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

action: review The PR is still awaiting reviews from at least one requested reviewer area: core Issues related to the framework runtime target: patch This PR is targeted for the next patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants