HTML サニタイザーの詳細

  • リリースバージョン: Zurich
  • 更新日 2025年07月31日
  • 所要時間:8分
  • HTML フィールドと翻訳された HTML フィールドの HTML マークアップをサニタイズして不要なコードを削除し、クロスサイトスクリプト攻撃などのセキュリティ上の懸念から保護します。

    HTML のサニタイズを使用して、インスタンス内の HTML コンテンツに潜在的に有害なコンテンツが含まれないようにします。HTML のサニタイズは、インスタンスで不要なスクリプトを実行したり、ユーザーを不要なコンテンツに誘導したりするために使用できる <![CDATA[<script>]]>、<link><embed> タグなど、インスタンスを侵害するために使用される可能性のある HTML タグを削除することで機能します。コンテンツのフォーマットを制御する安全なタグは保持されます。アドミニストレーターは、削除または保持するコンテンツをカスタマイズできます。また、サニタイズをすべてのコンテンツに適用するか、指定したフィールドのみに適用するかを制御することもできます。

    HTML サニタイザーは、常に保持する必要があるマークアップのビルトイン包含リストをチェックすることで機能します。サニタイザーは、アドミニストレーターがビルトイン包含リストを変更するために使用できる HTMLSanitizerConfig スクリプトインクルードを提供します。アイテムを除外リストに追加して、HTML マークアップを削除することもできます。除外リストの内容で包含リストは上書きされます。

    次のタイプのアイテムを包含リストと除外リストに追加できます。
    • グローバル属性
    • HTML 要素
    注:
    デフォルトでは、hrefsrc などの URL 属性は次のプロトコルのみをサポートしています。
    • http
    • https
    • mailto
    • data
    例:
    <a href="https://community.servicenow.com/community">ServiceNow コミュニティ</a>
    注:
    HTML サニタイザーの使用を制御する glide.html.sanitize_all_fields プロパティの詳細については、「インスタンスセキュリティ強化設定」の「HTML サニタイザーを有効にする (セキュリティセンター 1.3 で更新)」を参照してください。

    urlAttributes とプロトコルを設定する

    HTMLSanitizer スクリプトインクルードで urlAttributes とそのプロトコルを設定できます。例:

    HTML_WHITELIST : {
    urlAttributes: { "protocols" : [ "file", "notes" ] },
                    -  -
                    -  -
            }

    この例では、メモ が包含リストに含まれているため、この URL はサニタイズされません。

    <a title=“Lotus” href=“Notes://ABC/X575C90019DE33/ABC594DCB76D86EB4925653E0011C4C1/ZZ90B7E2D33964749257EEA003456FD”>Lotus</a></p> 

    デフォルト包含リスト

    注:
    デフォルト包含リストはシステムリストであり、インスタンス内のユーザーはアクセスできません。
    BUILTIN_HTML_WHITELIST :{
     
        globalAttributes:{ attribute:["id","class","lang","title","style"],
     
                                     attributeValuePattern:{}},
     
        label:{ attribute:["for"]},
     
        font:{ attribute:["color","face","size"]},
     
        a:{ attribute:["href","nohref","name","shape"]},
     
        img:{ attribute:["src","name","alt","border","hspace","vspace","align","height","width"},
     
        table:{ attribute:["border","cellpadding","cellspacing","bgcolor","background","align","no resize","height","width","summary","frame","rules"]},
     
        th:{ attribute:["background","bgcolor","abbr","axis","headers","scope","nowrap","height","width","align","valign","char off","char","colspan","rowspan"]},
     
        td:{ attribute:["background","bgcolor","abbr","axis","headers","scope","nowrap","height","width","align","valign","char off","char","colspan","rowspan"]},
     
        tr:{ attribute:["background","height","width","align","valign","char off","char"]},
     
        thead:{attribute:["align","valign","char off","char"]}, 
     
        tbody:{attribute:["align","valign","char off","char"]}, 
     
        tfoot:{attribute:["align","valign","char off","char"]}, 
     
        colgroup:{attribute:["align","valign","char off","char","span","width"]}, 
     
        col:{attribute:["align","valign","char off","char","span","width"]},
     
        p:{attribute:["align"]},
     
        style:{attributeValuePattern:{"type":"text/css"}}
     
        canvas:{ attribute:["height","width"]},
     
        details:{ attribute:["open"]},
     
        summary:{ attribute:["open","valign","char off","char"]},
     
        button:{ attribute:["disabled","accesskey","type"]},
     
        form:{},
     
        input:{ attribute:["size","maxlength","checked","alt","src","type","disabled","readonly","accesskey","border","usemap"]},
     
        select:{ attribute:["disabled","multiple","size"]},
     
        textarea:{ attribute:["rows","cols","disabled","readonly","accesskey"]},
     
        option:{ attribute:["disabled","label","selected"]},
     
        div:{ attribute:["align"]},
     
        ol:{ attribute:["start","type","square"]},
     
        ul:{ attribute:["type","square","itemscope","itemtype","itemref"]},
     
        li:{ attribute:["value","fb__id","itemprop"]},
     
        span:{ attribute:["color","size","data-mce-bogus","itemprop","face"]},
     
        br:{ attribute:["clear"]},
     
        h3:{ attribute:["itemprop"]},
     
        html:{ attribute:["xmlns","lang","xml:lang"]},
     
        link:{ attribute:["rel","type","href","charset"]},
     
        meta:{ attribute:["name","content","scheme","charset","http-equiv"]},
     
        pre:{ attribute:["xml:space"]},
     
        noscript:{},    h1:{},    h2:{},      h4:{},    h5:{},    h6:{},   
     
        i:{},    b:{},    u:{},    strong:{},    em:{},    small:{},    big:{},   
     
        pre:{},    code:{},    cite:{},    samp:{},    sub:{},    sup:{},    
     
        strike:{},   center:{},  blockquote:{},    hr:{},      map:{},
     
        dd:{},    dt:{},    dl:{},  fieldset:{},    legend:{}, figure:{},  tt:{},
     
        body:{},   caption:{},   head:{},   title:{},  shape:{},},

    HTML フィールドでの変数とテンプレートの使用

    HTML/翻訳された HTML フィールドは、デフォルトで HTML サニタイズされます。このプロセスは、入力 HTML をサニタイズして、クロスサイトスクリプティング (XSS) および関連するセキュリティ攻撃から保護します。${description}や{{description}}などのテンプレートまたは変数を格納し、サニタイズ後に真の説明に置き換えると、サニタイズプロセスの有効性が低下します。これは、サニタイズがプレースホルダーテンプレートでのみ呼び出され、HTML コンテンツでは呼び出されないためです。[HTML]/[翻訳された HTML] フィールドに HTML コンテンツのみを格納すると、効果的なサニタイズプロセスを確保できます。