Update handling of Trusted Types

オープン
#55 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
35/100
issue の種類
機能追加
明瞭さ
説明が足りない
活発さ
静か
技術スタック
csharp
領域
security

調査の方向性

まず既存の security-header UI と sources table を確認し、trusted-types と require-trusted-types-for の要件を、リンクされている MDN および W3C のリファレンスと比較します。これらのディレクティブを sources table に含めるのか custom properties に含めるのかを判断し、実装前にドロップダウン、policy-name の扱い、チェックボックスを定義します。両方のディレクティブを正しく設定および生成できれば完了です。

索引モデルが issue の本文から書いたものです。

説明

enhancement Under Consideration

Note: This is now CSP baseline functionality as of 2026, but not technically part of the CSP 3 spec

Add support for trusted-types and require-trusted-types-for require a different type of UI to be functional compared to standard sources.

Key Articles:

Trusted Types Directive

<policyName> : A valid policy name consists only of alphanumeric characters, or one of -#=_/@.%. A star (*) as a policy name instructs the user agent to allow any unique policy name

Content-Security-Policy: trusted-types;
Content-Security-Policy: trusted-types 'none';
Content-Security-Policy: trusted-types <policyName>;
Content-Security-Policy: trusted-types <policyName> <policyName> 'allow-duplicates';
Example Trusted Types Usage
// Content-Security-Policy: require-trusted-types-for 'script'; trusted-types foo;

const attackerInput = '<svg onload="alert(/cross-site-scripting/)" />';
const el = document.createElement("div");

if (typeof trustedTypes !== "undefined") {
  // Create a policy that can create TrustedHTML values
  // after sanitizing the input strings with DOMPurify library.
  const sanitizer = trustedTypes.createPolicy("foo", {
    createHTML: (input) => DOMPurify.sanitize(input),
  });

  el.innerHTML = sanitizer.createHTML(attackerInput); // Puts the sanitized value into the DOM.
  el.innerHTML = attackerInput; // Rejects a string value; throws a TypeError.
}

Require Trusted Types Directive

Note this currently only supports 'script'

Content-Security-Policy: require-trusted-types-for 'script';

UI Considerations

  • Dropdown for "Trusted Types":
    • Disabled (Not Generated)
    • None (Generates the 'none')
    • Allow Specific (requires policy names)
    • Allow All (Uses *)
  • Require For Scripts (Checkbox)
    • True (generates: require-trusted-types-for 'script';)
  • Allow Duplicates (Checkbox)
    • Adds 'allow-duplicates' to Trusted Types;

Data Storage ... do we store this in the sources table or create custom properties?

e.g.

Source Directives
<policyName> <policyName> 'allow-duplicates' trusted-types
'script' require-trusted-types-for

Usage Complications

  • Brand sites with GTM usage will require additional scripting to work this functionality
  • Investigate if Optimizely WebEx supports this
主要言語
C#
スター
11
フォーク
6
PR マージ指標
30日以内にマージされた PR はありません

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

GeekInTheNorth/Stott.Security.Optimizely のほかの issue

GeekInTheNorth/Stott.Security.Optimizely の issue をすべて見る

似ている issue

C# の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。