Skip to content
New issue

transmission_risk_levelの値について #14

Open
zaruudon opened this issue on Nov 24, 2020 · 6 comments

Comments

@zaruudon

現在通知サーバーから配信されているファイルではtransmission_risk_levelに0が設定されていますが、
AndroidではtransmissionRiskScoreがExposureConfigurationに従って設定されるのはtransmission_risk_levelが1~8の場合であり、
0だった場合はtransmissionRiskScoreには1が入るようになっているようです。
https://github.com/google/exposure-notifications-internals/blob/7dadb83aa5c4b02ed4ae98cd8cf13f89b96962d2/exposurenotification/src/main/java/com/google/samples/exposurenotification/matching/RiskScoreCalculator.java#L69-L72

transmissionRiskScoreが1のときにriskScoreがminimumRiskScore以上になることはないので、
transmission_risk_levelが0だと、現在のAndroid版では接触が検知されることはないと思われます。

@zaruudon
Author

zaruudon commented on Dec 8, 2020

以下の方法でOSにキーの一致を検出させることができましたが、アプリでは検知されませんでした。
https://gist.github.com/zaruudon/5d01b848e50d5a63df50479e27b0df9d

動作情報には以下のような出力がありました。

2020/12/09 06:28:21,Info,Start,ExposureDetectedAsync
2020/12/09 06:28:21,Info,ExposureSummary.MatchedKeyCount: 1,ExposureDetectedAsync
2020/12/09 06:28:21,Info,ExposureSummary.DaysSinceLastExposure: 7,ExposureDetectedAsync
2020/12/09 06:28:21,Info,ExposureSummary.HighestRiskScore: 0,ExposureDetectedAsync
2020/12/09 06:28:21,Info,"ExposureSummary.AttenuationDurations: 00:27:00,00:00:00,00:00:00",ExposureDetectedAsync
2020/12/09 06:28:21,Info,ExposureSummary.SummationRiskScore: 0,ExposureDetectedAsync
2020/12/09 06:28:21,Info,Start,GetConfigurationAsync
2020/12/09 06:28:21,Info,Get configuration from config,GetConfigurationAsync
2020/12/09 06:28:21,Info,"configuration: { ""MinimumRiskScore"": 21, ""AttenuationWeight"": 50, ""TransmissionWeight"": 50, ""DurationWeight"": 50, ""DaysSinceLastExposureWeight"": 50, ""TransmissionRiskScores"": [ 7, 7, 7, 7, 7, 7, 7, 7 ], ""AttenuationScores"": [ 1, 2, 3, 4, 5, 6, 7, 8 ], ""DurationScores"": [ 0, 0, 0, 0, 1, 1, 1, 1 ], ""DaysSinceLastExposureScores"": [ 1, 1, 1, 1, 1, 1, 1, 1 ], ""DurationAtAttenuationThresholds"": [ 50, 70 ]}",GetConfigurationAsync
2020/12/09 06:28:21,Info,End,GetConfigurationAsync
2020/12/09 06:28:21,Info,Save ExposureSummary. MatchedKeyCount: 1,ExposureDetectedAsync
2020/12/09 06:28:21,Info,Save ExposureInformation. Count: 0,ExposureDetectedAsync

AttenuationDurationsによればAttenuationが50dB以下で27分接触したということなので正しく判定されていないことがわかりますが、
HighestRiskScoreはMinimumRiskScore未満であるため0で上書きされており、元の値はわかりません。
そこでmitmproxyを使ってConfigration.jsonをMinimumRiskScoreを1にしたものに差し替えたところ、アプリで検知されました。HighestRiskScoreは4でした。

2020/12/09 06:39:03,Info,Start,ExposureDetectedAsync
2020/12/09 06:39:03,Info,ExposureSummary.MatchedKeyCount: 1,ExposureDetectedAsync
2020/12/09 06:39:03,Info,ExposureSummary.DaysSinceLastExposure: 7,ExposureDetectedAsync
2020/12/09 06:39:03,Info,ExposureSummary.HighestRiskScore: 4,ExposureDetectedAsync
2020/12/09 06:39:03,Info,"ExposureSummary.AttenuationDurations: 00:27:00,00:00:00,00:00:00",ExposureDetectedAsync
2020/12/09 06:39:03,Info,ExposureSummary.SummationRiskScore: 4,ExposureDetectedAsync
2020/12/09 06:39:03,Info,Start,GetConfigurationAsync
2020/12/09 06:39:03,Info,Get configuration from config,GetConfigurationAsync
2020/12/09 06:39:03,Info,"configuration: { ""MinimumRiskScore"": 1, ""AttenuationWeight"": 50, ""TransmissionWeight"": 50, ""DurationWeight"": 50, ""DaysSinceLastExposureWeight"": 50, ""TransmissionRiskScores"": [ 7, 7, 7, 7, 7, 7, 7, 7 ], ""AttenuationScores"": [ 1, 2, 3, 4, 5, 6, 7, 8 ], ""DurationScores"": [ 0, 0, 0, 0, 1, 1, 1, 1 ], ""DaysSinceLastExposureScores"": [ 1, 1, 1, 1, 1, 1, 1, 1 ], ""DurationAtAttenuationThresholds"": [ 50, 70 ]}",GetConfigurationAsync
2020/12/09 06:39:03,Info,End,GetConfigurationAsync
2020/12/09 06:39:03,Info,ExposureInfo: 1,ExposureDetectedAsync
2020/12/09 06:39:03,Info,Exposure.Timestamp: 2020/12/01 0:00:00,ExposureDetectedAsync
2020/12/09 06:39:03,Info,Exposure.Duration: 00:30:00,ExposureDetectedAsync
2020/12/09 06:39:03,Info,Exposure.AttenuationValue: 44,ExposureDetectedAsync
2020/12/09 06:39:03,Info,Exposure.TotalRiskScore: 4,ExposureDetectedAsync
2020/12/09 06:39:03,Info,Exposure.TransmissionRiskLevel: Invalid,ExposureDetectedAsync
2020/12/09 06:39:03,Info,Save ExposureSummary. MatchedKeyCount: 1,ExposureDetectedAsync
2020/12/09 06:39:03,Info,Save ExposureInformation. Count: 1,ExposureDetectedAsync

@kvaluation

@zaruudon さん 分析とデータをありがとうございます。通知サーバーに登録される診断キーTEKのtransmission_risk_levelno
設定値が0だと、ExposureConfigurationのTransmissionRiskScoresの初期値7が1に上書きされてしまう、ということをやっと理解できました。

解決策として

案1 診断キーのtransmission_risk_level を1にする。

案2 ExposureNotificationHandler.csについて

 MinimumRiskScore = 3, //必須
 TransmissionRiskScores = new int[] { 1, 1, 1, 1, 1, 1, 1, 1 }, //可読性のため

とする

の2案、思いついたのですが、どのような解決策が良いか、ご知見を賜れましたら幸いです。

(参考)リスク評価部分は正しいと確認しようとして、zaruudon さんのこの分析でその方針の誤りを発見する過程
https://twitter.com/info_kvaluation/status/1356957108873252864

@zaruudon
Author

zaruudon commented 16 days ago

transmission_risk_levelは使っていなければ無視するという意図だと思うので、そうであればtransmission_risk_levelは変えずにConfigration.jsonを変更するのがよさそうです。
しかし、APIの仕様にはそのようなことは全く書かれていないので、Googleに確認をとる必要があるということになるのではないかと思います。

@kvaluation

zaruudon さんありがとうございます。

transmission_risk_levelを中心とした経緯を整理しました。

2020年4月29日 Google

Exposure Notification Android API Documentation
https://www.blog.google/documents/68/Android_Exposure_Notification_API_documentation_v1.2.pdf

  • 4つのリスク項目を加算しており掛け算をしている現状とは相違
  • リスク項目の値は0を含まない1から8

2020年5月26日 日本政府 新型コロナウイルス感染症対策テックチーム

接触確認アプリ及び関連システム仕様書
https://cio.go.jp/sites/default/files/uploads/documents/techteam_20200526_01.pdf

  • transmission_risk_levelを使わなければならない要件はない。

2020年6月10日 Microsoft (米,Xamarin)

https://github.com/xamarin/ExposureNotification.Sample/blob/32767bf13d26e3cff6e0e332b8c6a0bf0d1603aa/Shared/ExposureKey.cs#L19

  • transmission_risk_levelを0以上8以下にせよとのコメント
  • EN APIの変化に応じた保守や修正はされていない。

2020年7月12日  castellamanさん コミット

(自称OSSの最後のコミット)
Filtering over 14days key data
https://github.com/cocoa-mhlw/cocoa/commits/3eac4f45e6bcb5f488cc8116854725eaf5dd62cb/Covid19Radar/Covid19Radar/Services/ExposureNotificationHandler.cs

(Covid19Radarの方ではcastellamanさんは削除されている)
Covid-19Radar/Covid19Radar#740

2020年7月13日 iOS版の修正版「1.1.2」の配布を開始
2020年7月14日 Android版の修正版「1.1.2」の配布を開始
2020年7月15日 処理番号(陽性登録に必要な番号)の発行を再開
2020年7月17日 Google Play 開発者サービス更新

2020年7月21日 Apple

iOSでの照合処理等のソースコードを公開
https://developer.apple.com/exposure-notification/

2020年8月13日 iOS 13.6.1 更新

2020年8月21日(遅くとも) Apple

Exposure Risk Value Calculation in ExposureNotification Version 1
https://developer.apple.com/documentation/exposurenotification/enexposureconfiguration/exposure_risk_value_calculation_in_exposurenotification_version_1

  • 4つのリスク項目を掛けていて、最大値は8^4だが255へとしている。

transmissionの説明がいつ入ったかは不明だが、
https://developer.apple.com/documentation/exposurenotification/enexposureconfiguration/3586323-transmissionrisklevelvalues

0 = Unused/Custom ←日本が該当(transmission値は未使用)
1 = Confirmed test: Low transmission risk level
2 = Confirmed test: Standard transmission risk level ←値をいれるのであれば、日本はPCR陽性確認なのでこの値。Lowリスクの1でも問題ないと思われる。
3 = Confirmed test: High transmission risk level
4 = Confirmed clinical diagnosis ←日本では陽性登録されているか否か不明
5 = Self report
6 = Negative case (ランダム比較のコントロール?)
7 = Recursive case (何が再帰的か不明、アプリ側との通信か?)

2020/8/26 Google transmissionRiskScore =

https://github.com/google/exposure-notifications-internals/blob/7dadb83aa5c4b02ed4ae98cd8cf13f89b96962d2/exposurenotification/src/main/java/com/google/samples/exposurenotification/matching/RiskScoreCalculator.java#L69-L72

  • transmission_risk_levelを0であれば1に上書き(zaruudonさん指摘)
  • transmission_risk_levelの値について、0をUnusedとして許容するAppleと不整合
  • L74では4つのリスク項目を掛けていて、AndroidのソースもAppleの仕様に寄せていることがわかる。Android版のv1.2には準拠していない。

時期不明 Google Webでの仕様も改訂された 

https://developers.google.com/android/exposure-notifications/exposure-notifications-api#data-structures

"RiskScore = "で検索
255に丸める仕様は発見できない。

"transmissionRiskLevel"で検索して(Legacy v1 mode)をみると、

0: Unused
8: Unused/custom

となっている。Unusedはプログラムとして使わないから1に上書きした可能性があるが、UnusedはApple仕様ではcustom使用もでき当事国の保健当局としてtransmissionRiskLevelを使わないときの値とも解される。

2020年9月9日 現開発会社さん

(cocoa-dev, たぶんエムティーアイや再委託先)
Fixed default exposure configuration
868e291

  • transmission_risk_levelの値を7に設定

2020年9月18日 現開発会社さん

Fixed configuration instructed by apple
20f3e8c

  • Appleの要請に応じて AttenuationScores を修正
  • その結果、MinimumRiskScore を1から 21に修正
  • transmission_risk_levelの7はAppleの要請ではなかった
  • Appleの要請とあるが、iOSでは強制的に上書きしていた模様

https://developer.apple.com/documentation/exposurenotification/enexposureconfiguration/3586319-attenuationlevelvalues

2020年9月28日 厚生労働省

Android版の修正版「1.1.4」配布開始(リンク先はiOS版1.1.4の説明)
https://www.mhlw.go.jp/stf/newpage_13736.html

2020年11月25日 zaruudonさん

transmission_risk_levelの値について #14

2021年2月3日 厚生労働省

Android版接触確認アプリの障害について
https://www.mhlw.go.jp/stf/newpage_16532.html

  • 不具合に関してごまかしのない誠実な説明と思われる。

「接触リスクに関する値がAndroid端末については想定と異なる形で接触通知APIから出力され」
→意味: transmission_risk_levelを7に設定しているのに、1に上書きされて返ってきている

「その結果、接触が正しく通知されないこととなっている」
→意味: 3×7でしきい値の21以上だと濃厚接触ありと評価するが、7が1に上書きされていて、3×1で21未満となり、実際には濃厚接触の条件を満たすのに、アプリで濃厚接触なしと評価していた。結果、濃厚接触が通知されない。

2021年2月5日 菅内閣総理大臣

首相、コロナ接触アプリ障害陳謝
https://jp.reuters.com/article/idJP2021020501001241
https://english.kyodonews.net/news/2021/02/6437947c3d50-suga-apologizes-for-glitch-in-japans-covid-19-contact-tracing-app.html

  • 政府が隠蔽や歪曲をせず改修に向けた取り組みを開始することができたのは、第1にオープンソースだからであり、第2にエムティーアイ殿が作成したcocoa-logの機能が正確だからである。
  • オープンソースであることとエムティーアイ殿に感謝します。

2021年2月5日 平井デジタル改革担当大臣

そんなに難しいアプリではない
https://news.tv-asahi.co.jp/news_economy/articles/000206268.html

  • 開発会社や開発者に必要な対価と必要な期間を準備する、という簡単なことができない政府のデジタル改革担当大臣殿が、「そんなに難しいアプリではない」と発言してしまう程度に、日本ではアプリの開発は難しいことが改めて明らかとなった。

上記より まとめ

  • 日本のコードの transmission_risk_level=7 は、Apple | Googleの仕様にあっていない。検査陽性を示す1-3となる。
  • 日本のコードのアプリ側のtransmission_risk_level設定値と、通知サーバーに登録する診断キーのtransmission_risk_level は同じ値にしておくべき。現状、診断キーのtransmission_risk_levelは全て0。
  • Googleの transmission_risk_level=0のときに1に上書きするのは、GoogleのAPIの定義をGoogle自身が読み間違えている可能性もある。Unusedの解釈。または、Appleでは0はUnused/customなのだから、0をCustomとして使うのかどうか、話し合ってどちらかにしておくべき。
  • Microsoftはサンプルを書きっぱなしでメンテナンスしておらず、採用した日本その他の国の役に立っていない。

■日本の接触確認アプリ→transmission_risk_levelをアプリ側、診断キー側も1にして、minimumRiskScoreを3にするのが良さそう。

■Google | Apple→transmissionRiskLevelがアプリ側と診断キー側で異なるときにどちらに合わせるかの仕様と、transmission_risk_level=0, 8のUnusedの仕様及び意味の確定し、必要なコード修正をすべき。

■日本政府→陽性登録の登録率向上のための改修、非推奨のAPIを使わない次世代アプリの開発に着手するか、それともExpressに乗るかの検討を始めるべき。
Apple提唱の次世代のリスク評価(V2)は複雑でかなり現場が混乱することが想定されます。
https://developer.apple.com/documentation/exposurenotification/enexposureconfiguration

@keiji

keiji commented 13 days ago

2020年7月にリリースされたv1.5でExposureWindow modeが追加されています。
注意書きを見る限り、v1.5のロールアウトと同時にtransmissionRiskScore関連が「legacy v1」の位置づけになったと考えられます。

https://developers.google.com/android/exposure-notifications/release-notes#v15_july_2020

When ExposureWindow mode was introduced in v1.5, we began referring to legacy v1 functionality as v1 mode (or the legacy v1 mode).

https://developers.google.com/android/exposure-notifications/exposure-notifications-api#modes

@moonmile

moonmile commented 9 days ago

ドイツのコード

https://github.com/corona-warn-app/cwa-app-ios
https://github.com/corona-warn-app/cwa-app-android

を確認してからとは思ったのですが。

Xamarin の場合、iOS と Android を実行時に判別できるので、transmission_risk_level の判断をアプリ側で切り替えることができます。Device.RuntimePlatform を使います。

こんな形で切り替えることができます。
https://github.com/cocoa-mhlw/cocoa/blob/master/Covid19Radar/Covid19Radar/Common/AppUtils.cs#L25

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants