You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on May 4, 2022. It is now read-only.
Repository navigation
This repository was archived by the owner on May 4, 2022. It is now read-only.
Security risks for ion-alert and other components #900
cli packages: (/usr/local/lib/node_modules)
@ionic/cli-utils : 1.19.0
ionic (Ionic CLI) : 3.19.0
System:
Node : v8.9.1
npm : 5.7.1
OS : macOS High Sierra
Misc:
backend : pro
Describe the Feature Request
Components that use innerHTML to set html content based on property values create a potential security risk when used with user entered content.
Warning: If your project is one that will undergo any form of security review, using innerHTML most likely will result in your code being rejected. For example, if you use innerHTML in a browser extension and submit the extension to addons.mozilla.org, it will not pass the automated review process.
The use of innerHTML with external Prop() values is used by <ion-alert>, <ion-refresher-content>, <ion-infinite-scroll-content>, <ion-searchbar> and maybe others.
In addition to the security risk there is also potential problems due to html escaping if the string content contains valid html characters (<. >, &, ...) that were entered by the end user.
Describe Preferred Solution
Change the data type of the property from string to JSX.Element and use normal JSX rendering. This allows the component to still provide rich html rendering without risking html injection. String values could still be used for simple messages.
For example, in <ion-alert>:
// Current ion-alert
@Prop()message?: string;<divid={msgId}class="alert-message"innerHTML={this.message}></div>// Proposed ion-alert
@Prop()message?: JSX.Element;<divid={msgId}class="alert-message">{this.message}</div>// Calling with JSXconstalert=awaitalertController.create({message: <span>Hello <b>{this.name}</b>!</span>});// Calling with simple stringconstalert=awaitalertController.create({message: 'Hello!'});
Activity