次の HTML を含む .cshtml ページがあります。
<div class="content rowBody">
<span class="rowText" title="@description">
@description
</span>
</div>
@description の値が次の場合: title<img src=x onerror=alert(/XSS/.source)>
属性
にこのように表示されて実行されていることがわかりますが、span タグの間の値はエンコードされているように見え、アラート ボックスをトリガーしません。
私の仮定では、Razor エンジン ビューは @ が前にあるものをすべてエンコードしようとするものでした。これは HTML 属性には適用されませんか?
生成されたソース:
<div style="margin-left: 31px;" class="content rowBody unselectable" unselectable="on">
<span class="rowText unselectable" title="<img src=x onerror=alert(/XSS/.source)>" unselectable="on">
<img src=x onerror=alert(/XSS/.source)>
</span>
</div>