概要
AngularJSは動的なウェブアプリケーションを開発するためのJavaScriptフレームワークです。HTMLをテンプレート言語として使用し、HTMLの構文を拡張してアプリケーションのコンポーネントを明確かつ簡潔に表現することができます。
An improper sanitization vulnerability (CVE-2024-8373) has been identified in AngularJS, which allows attackers to bypass common image source restrictions normally applied to the value of the [srcset] attribute on <source> HTML elements. This bypass can further lead to a form of Content Spoofing.
OWASP によるコンテンツ・インジェクション、「任意のテキスト・インジェクション」、仮想的な改ざんとも呼ばれるコンテンツ・スプーフィング は、ウェブ・アプリケーションのインジェクションの脆弱性によって可能となる、ユーザを標的にした攻撃です。アプリケーションがユーザから供給されたデータを適切に扱わない場合、攻撃者はウェブ・アプリケーションにコンテンツを供給することができます。これにより、ユーザは信頼されたドメイ ンのコンテキストで変更されたページを見ることになります。
この問題はすべてのバージョンのAngularJSに影響します。
詳細
モジュール情報
- 製品AngularJS
- 影響を受けるパッケージ angular
- 影響を受けるバージョン>=0.0.0
- GitHubリポジトリ: https://github.com/angular/angular.js
- 公開パッケージ :https://www.npmjs.com/package/angular
- パッケージマネージャ:npm
脆弱性情報
このMedium-severityの脆弱性は、すべての公開されたバージョンのAngularJSのメインのangularパッケージで発見されています。
Normally, setting an <img> or <source> element's srcset attribute value is subject to image source sanitization, which allows improving the security of an application by setting restrictions on the sources of images that can be shown. For example, only allowing images from a specific domain.
However, due to a bug in AngularJS, setting a <source> element’s srcset attribute via the ngAttrSrcset directive or interpolation is not subject to image source sanitization. This allows bypassing the image source restrictions configured in the application, which can also lead to a form of Content Spoofing.
注:
ngSrcsetとngPropSrcsetディレクティブは影響を受けません。これらのディレクティブでは、サニタイズは意図したとおりに動作します。
再現の手順
- AngularJSアプリケーションを作成し、特定のドメインからの画像のみを許可するように$compileProviderを設定します。例えば
angular
.module('app', [])
.config(['$compileProvider', $compileProvider => {
$compileProvider.imgSrcSanitizationTrustedUrlList(
// Only allow images from `angularjs.org`.
/^https:\/\/angularjs\.org\//);
}]);
- Use a specially-crafted value in the ngAttrSrcset directive on a <source> element to bypass the domain restriction and show an image from a disallowed domain. For example:
<picture>
<source ng-attr-srcset="https://angular.dev/favicon.ico" />
<img src="" />
</picture>
- data:image/svg+xmlフォーマットを使えば、任意のSVG画像を表示することもできる。例えば
<picture>
<source ng-attr-srcset="data:image/svg+xml;base64,..." />
<img src="" />
</picture>
- 同様に、srcsetHTML属性に補間を使うことでも同じことが実現できます。例えば
<picture>
<source srcset="{{ 'https://angular.dev/favicon.ico' }}" />
<!--
OR:
<source srcset="{{ 'data:image/svg+xml;base64,...' }}" />
-->
<img src="" />
</picture>
概念実証
A full reproduction with code similar to the above can be found here:
<source> sanitization vulnerability POC
緩和
AngularJSプロジェクトはEnd-of-Lifeであり、この問題に対処するためのアップデートは行われません。詳細はこちらをご覧ください。
影響を受けるコンポーネントのユーザーは、以下のいずれかの緩和策を適用してください:
- 影響を受けたアプリケーションをAngularJSから移行する。
- EOL後のセキュリティ・サポートには、HeroDevsのような商用サポート・パートナーを活用する。
弊社がサポートするオープンソースソフトウェアに新たな脆弱性が修正された場合、いつでもアラートを受け取ることができます。