[Samba] CVE-2021-44142: Details on a Samba Code Execution Bug Demonstrated at Pwn2Own Austin

https://www.zerodayinitiative.com/blog/2022/2/1/cve-2021-44142-details-on-a-samba-code-execution-bug-demonstrated-at-pwn2own-austin

CVE-2021-44142: Details on a Samba Code Execution Bug Demonstrated at Pwn2Own Austin

 

The Vulnerability

The fruit module that ships with Samba is designed to provide interoperability between Samba and Netatalk. Netatalk is an open-source implementation of the Apple Filing Protocol (AFP). It allows Unix-like systems to serve as file servers for Apple devices. Once a session is established, smbd allows an unauthenticated user to set extended file attributes of a file via SMB2_SET_INFO. This is done by the set_ea function found in “source3/smbd/trans2.c”. The name of the attribute must not be within the private Samba attribute name list, which includes user.SAMBA_PAI, user.DOSATTRIB, user.SAMBA_STREAMS, and security.NACL. With the exception of these attributes, an attacker can set arbitrary extended attributes.

The fruit module handles requests that access a file with the stream name :AFP_AfpInfo or :AFP_Resource. If using the stream name :AFP_AfpInfo, an attacker can open, read, and write Netatalk metadata of a file. Netatalk metadata is stored in a adouble structure, which is initialized by the ad_get/ad_fget functions.

The Netatalk metadata of a file is stored in the value of the extended attribute identified by the name org.netatalk.Metadata. The metadata will be parsed to fill the adouble (AppleDouble) structure. Since org.netatalk.Metadata isn’t in the private Samba attribute name list discussed above, an attacker can set an arbitrary value for this attribute. Therefore, it’s possible for an attacker to inject malformed metadata values. This can lead to multiple out-of-bounds memory accesses when the adouble structure is later used.

Let’s take a more detailed look at the bugs used to exploit this vulnerability during the Pwn2Own competition.


 

Sambaに同梱されるfruitモジュールは、SambaとNetatalkの間の相互運用性を提供 するように設計されている。NetatalkはApple Filing Protocol (AFP)のオープンソースの実装である。NetatalkはApple Filing Protocol (AFP)のオープンソース実装であり、 Unix系システムがAppleデバイスのためのファイルサーバーとして機能することを 可能にする。セッションが確立されると、smbd は認証されていないユーザーが SMB2_SET_INFO を介してファイルの拡張ファイル属性を設定することを可能にする。これは “source3/smbd/trans2.c” にある set_ea 関数によって行われます。属性名は、user.SAMBA_PAI, user.DOSATTRIB, user.SAMBA_STREAMS, and security.NACL を含むプライベートSamba属性名リストに含まれてはならない。これらの属性を除けば、攻撃者は任意の拡張属性を設定することができます。

fruit モジュールは、ストリーム名 :AFP_AfpInfo または :AFP_Resource を持つファイルにアクセスするリクエストを処理します。ストリーム名 :AFP_AfpInfo を使用すると、攻撃者はファイルの Netatalk メタデータを開いたり、読んだり、書いたりすることができます。Netatalk のメタデータは adouble 構造体に格納され、ad_get/ad_fget 関数で初期化されます。

ファイルのNetatalkメタデータは、org.netatalk.Metadataという名前で識別される拡張属性の値に格納されます。メタデータはadouble(AppleDouble)構造体を埋めるためにパースされます。org.netatalk.Metadataは、上で議論されたプライベートSamba属性名リストにないので、攻撃者は、この属性に任意の値を設定することができます。したがって、攻撃者が不正なメタデータ値を注入することが可能です。これは、adouble 構造体が後で使用されるとき、複数の境界外メモリアクセスにつながる可能性がある。

Pwn2Own大会において、この脆弱性を悪用するために使用されたバグについて、より詳細に見てみましょう。

www.DeepL.com/Translator(無料版)で翻訳しました。

Linux、Netatalk、Samba、NFSを使用したファイルサーバーについて研究・運用しています。

fsをフォローする
課題ログ

コメント